00001
00002
00003
00004
00005
00006
00007
00041
00042
00043
00044
00045 #include "cd.h"
00046 #include "wd.h"
00047
00048 #include "dsp.h"
00049 #include "model.h"
00050 #include "prm.h"
00051 #include "prmio.h"
00052 #include "prmed.h"
00053
00054
00055
00056
00057
00058
00059
00062 Model* Model::curr_model = 0L;
00063
00064
00065
00066
00067
00068
00069
00070 Model* Model::GetCurrModel( void )
00071 {
00072 return( curr_model );
00073 }
00074
00075
00076
00077
00078
00079
00080
00081
00082 Model::Model( cdCanvas* canvas, Dsp* display )
00083 {
00084 curr_model = this;
00085 PrmEd::InitParams( canvas, display );
00086 }
00087
00088
00089
00090 Model::~Model( )
00091 {
00092 Prm::DeleteList( );
00093 }
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 bool Model::ChkEmptyModel( void )
00104 {
00105 return( Prm::ChkEmptyModel( ) );
00106 }
00107
00108
00109
00110 void Model::Reset( void )
00111 {
00112 Prm::DeleteList( );
00113 PrmEd::ResetParams( );
00114 }
00115
00116
00117
00118 int Model::Open( FILE *fd )
00119 {
00120 int status;
00121
00122
00123
00124
00125 Prm::DeleteList( );
00126 PrmEd::ResetParams( );
00127
00128
00129
00130 status = PrmIO::Interpret( fd );
00131
00132 if( status )
00133 {
00134
00135
00136
00137 double xmin, xmax, ymin, ymax;
00138 if( Prm::GetGlobalBox( &xmin, &xmax, &ymin, &ymax ) )
00139 {
00140 double sizex = xmax - xmin;
00141 double sizey = ymax - ymin;
00142 double max_height = ( sizex > sizey ) ? sizex : sizey;
00143 PrmEd::SetMaxHeight( max_height );
00144 }
00145 }
00146
00147 return( status );
00148 }
00149
00150
00151
00152 void Model::Save( FILE *fd )
00153 {
00154 if( Prm::ChkEmptyModel( ) )
00155 return;
00156
00157
00158
00159 PrmIO::WriteList( fd );
00160 }
00161
00162
00163
00164 int Model::GetGlobalBox( double* xmin, double* xmax,
00165 double* ymin, double* ymax )
00166 {
00167 int status = Prm::GetGlobalBox( xmin, xmax, ymin, ymax );
00168
00169 return( status );
00170 }
00171
00172
00173
00174 void Model::Display( cdCanvas* canvas )
00175 {
00176
00177
00178 cdCanvasMarkType( canvas, CD_BOX );
00179 cdCanvasMarkSize( canvas, 7 );
00180
00181
00182
00183
00184
00185
00186 Prm *sel_prm = NULL;
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 if( sel_prm )
00202 {
00203 cdCanvasForeground( canvas, CD_RED );
00204
00205
00206
00207 }
00208 }
00209
00210
00211
00212 void Model::SetColor( long int color )
00213 {
00214 PrmEd::SetColor( color );
00215 }
00216
00217
00218
00219 long int Model::GetColor( void )
00220 {
00221 return( PrmEd::GetColor( ) );
00222 }
00223
00224
00225
00226 void Model::SetPrmType( Prm::Type type )
00227 {
00228 PrmEd::SetCurType( type );
00229 }
00230
00231
00232
00233 void Model::UnselectAllPrm( void )
00234 {
00235 PrmEd::UnselectAllPrm( );
00236 }
00237
00238
00239
00240 void Model::InsertPrm1stPt( double x, double y, double tol )
00241 {
00242 PrmEd::InsertPrm1stPt( x, y, tol );
00243 }
00244
00245
00246
00247 void Model::EchoPrm2ndPt( double x, double y )
00248 {
00249 PrmEd::EchoPrm2ndPt( x, y );
00250 }
00251
00252
00253
00254 void Model::InsertPrm2ndPt( double x, double y )
00255 {
00256 PrmEd::InsertPrm2ndPt( x, y );
00257 }
00258
00259
00260
00261 void Model::SelectDragPrm( double x, double y, double tol )
00262 {
00263 PrmEd::SelectDragPrm( x, y, tol );
00264 }
00265
00266
00267
00268 void Model::UpdateDragPrm( double x, double y )
00269 {
00270 PrmEd::UpdateDragPrm( x, y );
00271 }
00272
00273
00274
00275 void Model::FinishDragPrm( double x, double y )
00276 {
00277 PrmEd::FinishDragPrm( x, y );
00278 }
00279
00280
00281
00282 void Model::DeleteSelPrm( void )
00283 {
00284 PrmEd::DeleteSelPrm( );
00285 }
00286
00287
00288
00289 void Model::MoveSelPrmToFront( void )
00290 {
00291 PrmEd::MoveSelPrmToFront( );
00292 }
00293
00294
00295
00296 void Model::MoveSelPrmToBack( void )
00297 {
00298 PrmEd::MoveSelPrmToBack( );
00299 }
00300
00301
00302
00303 void Model::SetHeightFac( double fac )
00304 {
00305 PrmEd::SetHeightFac( fac );
00306 }
00307
00308
00309
00310 double Model::GetHeightFac( void )
00311 {
00312 return( PrmEd::GetHeightFac( ) );
00313 }
00314