00001 #ifndef ConstraintH
00002 #define ConstraintH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00042
00043
00044 #include "ExtObject.h"
00045 #include "List.h"
00046 #include "Point.h"
00047 #include "ContainerEnumerator.h"
00048
00049
00050
00051 extern CPluginObjectInfo ConstraintObjectInfo;
00052
00053
00054
00055
00056
00057 class CConstraint;
00058 class CConstraintsList;
00059 class CMolecule;
00060 class CAtom;
00061 class CAdvancedProject;
00062 class CXMLElement;
00063 class CJob;
00064 class CMoleculeInfo;
00065
00066
00067
00069
00072 class NEMESIS_CORE_PACKAGE CPositionLock{
00073 public:
00074 bool LockX:1;
00075 bool LockY:1;
00076 bool LockZ:1;
00077
00078 public:
00079 __fastcall CPositionLock(void);
00080
00081 bool operator == (const CPositionLock& left) const;
00082 };
00083
00084
00085
00087
00090 enum EConstraintType{
00091 CT_ATOM = 0,
00092 CT_DISTANCE = 1,
00093 CT_ANGLE = 2,
00094 CT_DIHEDRAL = 3
00095 };
00096
00097
00098
00100
00103 class NEMESIS_CORE_PACKAGE CConstraintData{
00104 public:
00105
00106 __fastcall CConstraintData(void);
00107
00108
00109 void __fastcall GetFromConstraint(const CConstraint* p_con);
00110 CConstraint* __fastcall MakeConstraint(CConstraintsList* p_list,CElementsRecord* history=NULL) const;
00111 inline int __fastcall GetConstraintIndex(void) const;
00112
00113
00114 public:
00115 int ConstraintIndex;
00116 CSmallString Name;
00117 CSmallString Description;
00118 CExtObject::CStatus Status;
00119 EConstraintType Type;
00120 int AtomIndex[4];
00121 CPositionLock Lock;
00122 CPoint Value;
00123 double Sigma;
00124 bool HarmonicFreeze;
00125 };
00126
00127
00128
00129
00130
00132
00135 class NEMESIS_CORE_PACKAGE CConstraint : public CExtObject{
00136 public:
00137
00138 __fastcall CConstraint(CConstraintsList *bl);
00139 __fastcall CConstraint(CConstraintsList *bl,
00140 CAtom *a1,CAtom *a2,CAtom *a3,CAtom *a4,
00141 EConstraintType type,const CPoint& value,double sigma,
00142 const CPositionLock& lock);
00143 void __fastcall RemoveFromBaseList(CElementsRecord* history=NULL);
00144
00145
00146 bool __fastcall Delete(void);
00147 bool __fastcall ChangeData(const CPoint& value,double sigma,
00148 const CPositionLock& lock,bool harmonic,bool active);
00149 bool __fastcall ChangeActiveState(void);
00150 bool __fastcall ChangeActiveStateTo(bool set);
00151 bool __fastcall Synchronize(void);
00152
00153
00154 void __fastcall SetValue(const CPoint& value);
00155 void __fastcall SetFinalDrvValue(const CPoint& drvvalue);
00156 void __fastcall SetSigma(double sigma);
00157 void __fastcall SetActive(bool act);
00158 void __fastcall SetHarmonic(bool harmonic);
00159 void __fastcall SetLock(const CPositionLock& lock);
00160 void __fastcall SetDrivingMode(bool set);
00161
00162
00163 inline double __fastcall GetSigma(void) const;
00164 inline bool __fastcall IsActive(void) const;
00165 inline bool __fastcall IsHarmonic(void) const;
00166 inline EConstraintType __fastcall GetConstraintType(void) const;
00167 int __fastcall GetTypeImage(void) const;
00168 inline const CPoint& __fastcall GetValue(void) const;
00169 CPoint __fastcall GetActualValue(void);
00170 CPoint __fastcall GetValueForMoleculeInfo(CMoleculeInfo* p_minfo);
00171 inline const CPoint& __fastcall GetFinalDrvValue(void) const;
00172 inline CAtom* __fastcall GetAtom(int index) const;
00173 inline bool __fastcall IsInDrivingMode(void) const;
00174
00175 inline const CPositionLock& __fastcall GetLock(void) const;
00176 inline CMolecule* __fastcall GetMolecule(void) const;
00177
00178 __property CMolecule* Molecule = {read = GetMolecule};
00179
00180 inline CConstraintsList* __fastcall GetBaseList(void);
00181 inline CJob* __fastcall GetJob(void);
00182
00183
00184 bool __fastcall Load(CXMLElement* p_el,bool new_indexes=false);
00185 bool __fastcall Save(CXMLElement* p_el,bool molinfo_indexes=false);
00186
00187
00188 virtual void __fastcall RemoveFromRegistered(CExtObject* object,CElementsRecord* history=NULL);
00189
00190
00191 private:
00192 CConstraintsList* BaseList;
00193 EConstraintType Type;
00194 CAtom* A[4];
00195 CPoint Value;
00196 CPoint FinalDrvValue;
00197 CPositionLock Lock;
00198 double Sigma;
00199 bool Harmonic;
00200 bool DrivingMode;
00201
00202 public:
00203 static int CTAtomIndex;
00204 static int CTDistanceIndex;
00205 static int CTAngleIndex;
00206 static int CTDihedralIndex;
00207 };
00208
00209
00210
00211
00212 DECLARE_EVENT(Constraint_DataChange);
00213 DECLARE_EVENT(Constraint_Activate);
00214 DECLARE_EVENT(Constraint_SetDrvMode);
00215 DECLARE_EVENT(Constraint_SetDrvParm);
00216
00217
00218
00219
00220
00222
00225 class NEMESIS_CORE_PACKAGE CConstraintsList:public CExtObject,public CTemplList<CConstraint> {
00226 public:
00227
00228 __fastcall CConstraintsList(CMolecule *p_mol,CJob* p_job);
00229
00230
00231 static bool __fastcall CreateConstraint(CSimpleList<CExtObject>& list);
00232
00233 CConstraint* __fastcall AddConstraintWithHistory(
00234 CAtom *a1,CAtom *a2,CAtom *a3,CAtom *a4,
00235 EConstraintType type,const CPoint& value,double sigma,
00236 const CPositionLock& lock,
00237 const CSmallString& name,const CSmallString& descrip);
00238
00239 bool __fastcall ChangeActiveStatusForAllConstraints(bool active);
00240 bool __fastcall DeleteAllConstraints(void);
00241 bool __fastcall DeleteNonActiveConstraints(void);
00242 bool __fastcall SynchronizeAllConstraints(void);
00243
00244
00245 CConstraint* __fastcall AddConstraint(
00246 CAtom *a1,CAtom *a2,CAtom *a3,CAtom *a4,
00247 EConstraintType type,const CPoint& value,double sigma,
00248 const CPositionLock& lock,
00249 CElementsRecord* history=NULL);
00250 CConstraint* __fastcall AddConstraint(CConstraintData& sc,CElementsRecord* history=NULL);
00251
00252
00253 CConstraint* __fastcall SearchByName(const CSmallString& name);
00254 CConstraint* __fastcall SearchByDescription(const CSmallString& descrip);
00255 CConstraint* __fastcall FindConstraint(CAtom* a1,CAtom* a2=NULL,CAtom* a3=NULL,CAtom* a4=NULL);
00256
00257
00258 __property CMolecule* Molecule = {read = FMolecule};
00259 __property CJob* Job = {read = FJob};
00260
00261
00262 void __fastcall Lock(bool set);
00263 inline bool __fastcall IsLocked(void);
00264
00265
00266 bool __fastcall Load(CXMLElement* p_el,bool new_indexes=false,CElementsRecord* history=NULL);
00267 bool __fastcall Save(CXMLElement* p_el);
00268
00269
00270 private:
00271 CMolecule* FMolecule;
00272 CJob* FJob;
00273 bool Locked;
00274 };
00275
00276
00277
00278 DECLARE_EVENT(ConstraintsList_AddConstraint);
00279 DECLARE_EVENT(ConstraintsList_Lock);
00280 DECLARE_EVENT(ConstraintsList_RemoveConstraint);
00281
00282
00283
00284
00285
00286 extern CPluginObjectInfo ConstraintEnumObjectInfo;
00287 extern CExtUUID ID_ConstraintEnum;
00288
00289
00290
00292
00295 class CConstraintEnumerator : public CContainerEnumerator {
00296 public:
00297 __fastcall CConstraintEnumerator(CComObject* owner,CConstraintsList* p_conlist);
00298 __fastcall ~CConstraintEnumerator(void);
00299
00300 virtual int __fastcall NumOfCommands(void);
00301 virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00302 virtual bool __fastcall DoCommand(int i);
00303
00304 virtual int __fastcall NumOfObjects(void);
00305 virtual bool __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00306 virtual CExtObject* __fastcall GetObject(int pos);
00307
00308
00309 virtual int __fastcall NumOfColumns(void);
00310 virtual const CSmallString __fastcall GetColumnCaption(int index);
00311 virtual const CSmallString __fastcall GetObjectProperty(int index);
00312 virtual int __fastcall GetObjectImageIndex(void);
00313
00314 virtual CExtObject* __fastcall GetCurrentObject(void);
00315 virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00316
00317 private:
00318 CConstraintsList* Constraints;
00319 CTemplIterator<CConstraint> Pointer;
00320 CConstraint* CurrentObject;
00321 int StartPos;
00322 int EndPos;
00323 bool Changed;
00324 CSimpleList<CConstraint> CurrentView;
00325 CEventReciever Receiver;
00326
00327 virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00328 void __fastcall RecieveEvent(const CEventIdentifier& EventType,void* Data,void* Sender);
00329 void __fastcall TestCondition(EEventCondition CondType,bool& Result);
00330 };
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340 class CConstraintDataHistory : public CElementData{
00341 public:
00342
00343 __fastcall CConstraintDataHistory(CConstraint *p_con,bool create);
00344
00345 private:
00346 CProject* Project;
00347 int ConstraintsListIndex;
00348 CConstraintData Data;
00349 virtual void __fastcall Forward(void);
00350 virtual void __fastcall Backward(void);
00351 };
00352
00353
00354
00355
00356
00357
00358
00359
00360 class CConstraintListAddConstraintHistory : public CCoreElementsRecord {
00361 public:
00362 __fastcall CConstraintListAddConstraintHistory(CConstraint *p_con,bool create);
00363
00364 private:
00365 CSmallString Name;
00366 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00367 };
00368
00369
00370
00371 class CConstraintChangeDataHistory : public CCoreElementsRecord {
00372 public:
00373 __fastcall CConstraintChangeDataHistory(CConstraint *p_con,const CPoint& value,
00374 double sigma,const CPositionLock& lock,
00375 bool harmonic,bool active);
00376
00377 private:
00378
00379 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00380 virtual void __fastcall Forward(void);
00381 virtual void __fastcall Backward(void);
00382
00383 int ConstraintIndex;
00384 CSmallString Name;
00385 CProject* Project;
00386 int ConstraintsListIndex;
00387
00388 CPoint NewValue;
00389 double NewSigma;
00390 CPositionLock NewLock;
00391 bool NewHarmonic;
00392 bool NewActive;
00393
00394 CPoint OldValue;
00395 double OldSigma;
00396 CPositionLock OldLock;
00397 bool OldHarmonic;
00398 bool OldActive;
00399 };
00400
00401
00402
00403 class CConstraintChangeActiveStateHistory : public CCoreElementsRecord {
00404 public:
00405 __fastcall CConstraintChangeActiveStateHistory(CConstraint *p_con);
00406
00407 private:
00408 CSmallString Name;
00409 int ConstraintIndex;
00410 CProject* Project;
00411 int ConstraintsListIndex;
00412
00413 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00414 virtual void __fastcall Forward(void);
00415 virtual void __fastcall Backward(void);
00416 };
00417
00418
00419
00420 class CConstraintChangeActiveStateToHistory : public CCoreElementsRecord {
00421 public:
00422 __fastcall CConstraintChangeActiveStateToHistory(CConstraint *p_con, bool newvalue);
00423
00424 private:
00425 CSmallString Name;
00426 int ConstraintIndex;
00427 CProject* Project;
00428 int ConstraintsListIndex;
00429 bool OldValue;
00430 bool NewValue;
00431
00432 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00433 virtual void __fastcall Forward(void);
00434 virtual void __fastcall Backward(void);
00435 };
00436
00437
00438
00439 class CConstraintsChangeAllActiveStateHistory : public CCoreElementsRecord {
00440 public:
00441 __fastcall CConstraintsChangeAllActiveStateHistory(CConstraintsList* p_list,bool activate);
00442 __fastcall ~CConstraintsChangeAllActiveStateHistory(void);
00443
00444 private:
00445 CProject* Project;
00446 int ConstraintsListIndex;
00447 bool Activate;
00448 int NumOfObjects;
00449 int* Indexes;
00450 bool* Statuses;
00451
00452 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00453 virtual void __fastcall Forward(void);
00454 virtual void __fastcall Backward(void);
00455 };
00456
00457
00458
00459 class CDeleteAllConstraintsHistory : public CCoreElementsRecord {
00460 public:
00461 __fastcall CDeleteAllConstraintsHistory(void);
00462 };
00463
00464
00465
00466 class CDeleteNonActiveConstraintsHistory : public CCoreElementsRecord {
00467 public:
00468 __fastcall CDeleteNonActiveConstraintsHistory(void);
00469 };
00470
00471
00472
00473 class CSynchronizeAllConstraintsHistory : public CCoreElementsRecord {
00474 public:
00475 __fastcall CSynchronizeAllConstraintsHistory(void);
00476 };
00477
00478
00479
00480 class CSynchronizeConstraintHistory : public CCoreElementsRecord {
00481 public:
00482 __fastcall CSynchronizeConstraintHistory(CConstraint *p_con);
00483
00484 private:
00485 CProject* Project;
00486 int ConstraintIndex;
00487 int ConstraintsListIndex;
00488 CSmallString Name;
00489 CPoint OldValue;
00490 CPoint NewValue;
00491
00492 virtual CSmallString __fastcall GetDescription(const CSmallString& format);
00493 virtual void __fastcall Forward(void);
00494 virtual void __fastcall Backward(void);
00495 };
00496
00497
00498
00499
00500
00501 inline int __fastcall CConstraintData::GetConstraintIndex(void) const
00502 {
00503 return(ConstraintIndex);
00504 }
00505
00506
00507
00508 inline double __fastcall CConstraint::GetSigma(void) const
00509 {
00510 return(Sigma);
00511 }
00512
00513
00514
00515 inline bool __fastcall CConstraint::IsActive(void) const
00516 {
00517 return(GetStatus().Active);
00518 }
00519
00520
00521
00522 inline EConstraintType __fastcall CConstraint::GetConstraintType(void) const
00523 {
00524 return(Type);
00525 }
00526
00527
00528
00529 inline const CPoint& __fastcall CConstraint::GetValue(void) const
00530 {
00531 return(Value);
00532 }
00533
00534
00535
00536 inline const CPoint& __fastcall CConstraint::GetFinalDrvValue(void) const
00537 {
00538 return(FinalDrvValue);
00539 }
00540
00541
00542
00543 inline CAtom* __fastcall CConstraint::GetAtom(int index) const
00544 {
00545 if( (index < 0) || (index > 3) ) return(NULL);
00546 return(A[index]);
00547 }
00548
00549
00550
00551 inline const CPositionLock& __fastcall CConstraint::GetLock(void) const
00552 {
00553 return(Lock);
00554 }
00555
00556
00557
00558 inline CMolecule* __fastcall CConstraint::GetMolecule(void) const
00559 {
00560 return(BaseList->Molecule);
00561 }
00562
00563
00564
00565 inline bool __fastcall CConstraint::IsHarmonic(void) const
00566 {
00567 return(Harmonic);
00568 }
00569
00570
00571
00572 inline CConstraintsList* __fastcall CConstraint::GetBaseList(void)
00573 {
00574 return(BaseList);
00575 }
00576
00577
00578
00579 inline CJob* __fastcall CConstraint::GetJob(void)
00580 {
00581 return(BaseList->Job);
00582 }
00583
00584
00585
00586 inline bool __fastcall CConstraint::IsInDrivingMode(void) const
00587 {
00588 return(DrivingMode);
00589 }
00590
00591
00592
00593 inline bool __fastcall CConstraintsList::IsLocked(void)
00594 {
00595 return(Locked);
00596 }
00597
00598
00599
00600 #endif
00601