00001
00014 #ifndef HAMOLVIEW_H
00015 #define HAMOLVIEW_H
00016
00017
00018 #include "hastl.h"
00019 #include "habond.h"
00020 #include "haatgroup.h"
00021 #include "canvas3d.h"
00022 #include "command.h"
00023 #include "halinalg.h"
00024
00025 #include "hamolset.h"
00026
00027 const long LOAD_AMBER_RESTART_TIMER_ID = 100301;
00028
00029 class HaChain;
00030
00031 class HaMolecule;
00032 class Expr;
00033 class Object3D;
00034
00035 class Monitor
00036 {
00037 public:
00038 Monitor();
00039 virtual ~Monitor();
00040 HaAtom *src;
00041 HaAtom *dst;
00042
00043 bool operator ==( const Monitor& ref) const;
00044 bool operator < ( const Monitor& ref) const;
00045
00046 double dist;
00047 short col;
00048 };
00049
00050 class ShadeDesc
00052 {
00053 public:
00054 ShadeDesc();
00055 ~ShadeDesc();
00056
00057 int def;
00058 unsigned char r;
00059 unsigned char g;
00060 unsigned char b;
00061 };
00062
00063 class ShadeRef
00065 {
00066 public:
00067 short col;
00068 short shade;
00069 unsigned char r;
00070 unsigned char g;
00071 unsigned char b;
00072 };
00073
00074
00075 const int ResidueAttr = 0x00;
00076 const int ChainAttr = 0x01;
00077 const int TempAttr = 0x02;
00078 const int ChargeAttr = 0x03;
00079
00080 const int RibColInside = 0x01;
00081 const int RibColOutside = 0x02;
00082 const int RibColBoth = 0x03;
00083
00084 const int BackCol = 0;
00085 const int BoxCol = 1;
00086 const int LabelCol = 2;
00087 const int FirstCol = 3;
00088
00089
00090 const int VOXORDER = 21;
00091 const int VOXORDER2 = VOXORDER*VOXORDER;
00092 const int VOXSIZE = VOXORDER2*VOXORDER;
00093
00094 typedef void* PSItemPtr;
00095
00096 class HaMolView
00098 {
00099 public:
00100
00101 HaMolView();
00102 virtual ~HaMolView();
00103
00104 public:
00105 HaMolSet* GetMolSet();
00106
00107 int debug_level;
00108
00109 void ResetView();
00110
00111 int UseDepthCue;
00112 int UseStereo;
00113 int UseClipping;
00114
00115 int SSBondMode,HBondMode;
00116 static int ZoneBoth;
00117
00118 int UseTransparent;
00119 int UseOutLine;
00120 int KinemageFlag;
00121
00122 double StereoAngle;
00123
00124 int DrawBoundBox,DrawAxes;
00125 int DrawDoubleBonds;
00126 int DrawUnitCell;
00127
00128 double CartoonHeight;
00129 int SolventDots;
00130 double ProbeRadius;
00131
00132 int DrawDots,DrawLabels;
00133 int DrawMonitDistance;
00134 int DrawBetaArrows;
00135
00136 public:
00137 HaMolSet* host_mol_set;
00138
00139
00140 public:
00141 Partition HashTable;
00142
00143 static ShadeDesc Shade[LastShade] ;
00144
00145 static ShadeRef ScaleRef[LastShade];
00146 static int ScaleCount;
00147
00148 inline static int Colour2Shade(const int x) { return (int) (x-FirstCol)/ColourDepth; }
00149 inline static int Shade2Colour(const int x) { return x*ColourDepth+FirstCol ; }
00150
00151 int XOffset, YOffset;
00152 int ideltx, idelty;
00153
00154 double CenX, CenY, CenZ;
00155
00156 double CurRX;
00157 double CurRY;
00158 double CurRZ;
00159
00160 double CurTX;
00161 double CurTY;
00162
00163 double CurZoom;
00164 double CurSlabValue;
00165
00166 double LastRX,LastRY,LastRZ;
00167
00168
00169 double LastTX, LastTY;
00170
00171
00172 int PointX;
00173 int PointY;
00174 int InitX;
00175 int InitY;
00176
00177 static int FakeSpecular,SpecPower;
00178 static int BackR,BackG,BackB;
00179 static int LabR,LabG,LabB;
00180 static int BoxR,BoxG,BoxB;
00181 int UseLabelCol;
00182 static int UseBackFade;
00183 static double Ambient;
00184
00185
00186 HaMat_double Rot;
00187 HaVec_double Orig;
00188
00189 double Zoom;
00190
00191 double Scale;
00192 double DScale;
00193
00194 int UseScreenClip;
00195 int m_screen_transform;
00196
00197 int ReDrawFlag;
00198 int Hydrogens,HetaGroups;
00199 int DrawAtoms;
00200 int DrawBonds;
00201 int DrawRibbon;
00202 int DrawBestPath;
00203 int DrawContourSurf;
00204 int DrawSolidSurfaces;
00205
00206 protected:
00207 int StereoView;
00208
00209 int FBufX,FBufY;
00210
00211 public:
00212
00213 virtual int ExecuteCommand(CmdParser& cmd_pr);
00214 int ExecuteSetCommand(CmdParser& cmd_pr);
00215 int ExecuteColourCommand(CmdParser& cmd_pr);
00216 void ConnectObject(Object3D* pObj);
00217
00218 int BroadcastCurrAtom();
00219 int FillCurrAtomRef(char* buf);
00220
00221 bool SetImageSize(int new_ImageSize);
00222 int GetImageSize();
00223 int GetImageRadius();
00224
00225 void SetUseSlabPlane(int new_UseSlabPlane) { pCanv->m_UseSlabPlane= new_UseSlabPlane; }
00226 int UseSlabPlane() { return pCanv->m_UseSlabPlane; }
00227 void SetSlabMode(int new_SlabMode ) { pCanv->m_SlabMode= new_SlabMode; }
00228 int SlabMode() { return pCanv->m_SlabMode; }
00229 void SetSlabValue(int new_SlabValue ) { pCanv->m_SlabValue= new_SlabValue; }
00230 int SlabValue() { return pCanv->m_SlabValue; }
00231
00232 void SetSlabInten( int new_SlabInten) { pCanv->m_SlabInten= new_SlabInten; }
00233 void SetSliceValue( int new_SliceValue) { pCanv->m_SliceValue= new_SliceValue; }
00234 int SliceValue() { return pCanv->m_SliceValue; }
00235
00236
00237 void SetZOffset(int new_ZOffset) { pCanv->m_ZOffset = new_ZOffset; }
00238 int ZOffset() { return pCanv->m_ZOffset; }
00239
00240 #if !defined(_WIN32) & !defined(TWIN32)
00241 static int OpenDisplay( int, int );
00242 #endif
00243
00244 protected:
00245 void MouseMove(int status, int dx, int dy );
00246 void ClampShiftVal(int ival,double value );
00247 void WrapShiftVal(int iaxis, double value );
00248
00249 public:
00250
00251 virtual void UpdateThisView(long lHint=0);
00252 virtual void RefreshScreen() {}
00253 int CreateImage();
00254 virtual void ClearImage(){}
00255 void ClearBuffers();
00256 virtual void TransferImage(){}
00257 virtual int PrintImage(){ return True;}
00258 virtual int ClipboardImage(){ return True;}
00259 void ReSizeScreen();
00260 void ReAllocBuffers();
00261
00262 void BuildHashTable();
00263
00264 void DrawFrame();
00265 void ResetRenderer();
00266 void SetStereoMode( int );
00267 void SetPickMode( int );
00268 void PickAtom( int, int, int );
00269
00270 void SetRefreshScreen();
00271
00272
00273 public:
00274 void InitialTransform();
00275 void PrepareTransform();
00276 void ApplyTransform();
00277 void ResetTransform();
00278 void CalcRotCenter(int sel_atoms = FALSE);
00279
00280 void CenterSelected();
00281
00282 void GetTransfCoord(const double x_abs, const double y_abs, const double z_abs,
00283 double& x_tr, double& y_tr, double& z_tr);
00284
00285 public:
00286 void SetAtomScreenRadVal( double rad );
00287 void SetRadiusTemperature();
00288 void SetAtomScreenRadVdW();
00289 void DefaultRepresentation();
00290 void DisableSpacefill();
00291 void EnableWireframe( int mask, double rad );
00292 void DisableWireframe();
00293 void EnableBackbone( int mask, double rad );
00294 void DisableBackbone();
00295 void SetHBondStatus( int hbonds, int enable, double rad );
00296 void SetRibbonCartoons();
00297 void SetRibbonStatus( int enable, int flag, double width );
00298 void SetTraceTemperature();
00299
00300 static void SetMouseMode( int );
00301 static int MouseMode;
00302 static int UseHourGlass;
00303
00304
00305
00306 vector<int> min_color_map;
00307 map<int,int, less<int> > rev_color_map;
00308
00309 static void DefineColourMap();
00310
00311 int ComputeRevColourMap();
00312
00313
00314
00315 void ScaleColourMap( int count );
00316
00317 static int IsShadeDefined(unsigned char r, unsigned char g, unsigned char b );
00318 static int DefineShade( unsigned char r, unsigned char g, unsigned char b );
00319 static int SetShadeLutEntries(int shade_idx);
00320 static int GetColorIdx(unsigned char r, unsigned char g, unsigned char b );
00321
00322 void ColourBackNone();
00323 void ColourBondNone();
00324 void ColourHBondType();
00325 void ColourHBondNone( int hbonds);
00326 void ColourMonitNone();
00327 void ColourBackAttrib( int r, int g, int b);
00328 void ColourBondAttrib( int r, int g, int b);
00329 void ColourHBondAttrib( int hbonds, int r, int g, int b);
00330 void ColourMonitAttrib( int r, int g, int b);
00331 void ColourDotsAttrib( int r, int g, int b);
00332 void ColourDotsPotential();
00333 void ColourRibbonNone( int flag );
00334 void ColourRibbonAttrib( int flag, int r, int g, int b );
00335
00336 void ScaleColourAttrib( int attr );
00337 void MonoColourAttrib( int r, int g, int b );
00338 void CPKColourAttrib();
00339 void GroupsColourAttrib();
00340 void ShapelyColourAttrib();
00341 void AminoColourAttrib();
00342 void StructColourAttrib();
00343 int IsCPKColour( HaAtom* aptr );
00344
00346
00347 void FormatLabel(HaChain* chain, HaResidue* group, HaAtom* aptr,
00348 const char* label, char* ptr );
00349 int DeleteLabels();
00350 void DefineLabels( const char* label );
00351 void DefaultLabels( int enable );
00352 void DisplayLabels();
00353
00354 int LabelOptFlag;
00355
00357
00358 list<Monitor> MonitList;
00359
00360 void DeleteMonitors();
00361 void AddMonitors( HaAtom* src, HaAtom* dst );
00362 void CreateMonitor( Long src, Long dst );
00363 void DisplayMonitors();
00364
00366
00367 void DisplayETBestPath();
00368
00370
00371 void DisplayContourSurf();
00372
00374 void RestrictSelected();
00375
00377
00378 int TestDot( double x, double y, double z, bool solvent_access);
00379 void InitElemDots();
00380 void AddElemDots( int elem, int density );
00381 void FreeElemDots();
00382
00383 void DeleteDotSurfaces();
00384 void CalculateDotSurface( int density);
00385 void DisplayDotSurfaces();
00386
00388
00389 void DisplayRibbon( HaChain * );
00390
00392
00393 protected:
00394 void WriteByte( int );
00395 void WriteLSBShort( int );
00396 void WriteMSBShort( int );
00397 void WriteLSBLong( unsigned int );
00398 void WriteMSBLong( unsigned int );
00399 void WriteGIFCode(int code );
00400 void WritePPMWord(int i );
00401 void FlushRastRLE();
00402 void WriteRastRLECode( int val );
00403 void WriteRastRLEPad();
00404 void WriteRastData( int output );
00405 void OutputEPSFByte( int val );
00406 void EncodeEPSFPixel( int val, int col );
00407 void FlushBMPBuffer();
00408 void FlushBMPPackets();
00409 void ProcessBMPPacket();
00410 void WriteBMPCode( int val);
00411 void WriteBMPData( int output );
00412 int FindDepth( PSItemPtr item, int type);
00413 void DepthSort( PSItemPtr* data, char* type, int count);
00414 int ClipVectSphere( HaAtom * );
00415 int ClipVectBond( HaAtom *, HaAtom * );
00416 void WriteVectColour( int col );
00417 void WriteVectSphere( PSItemPtr *data, char *type,int index);
00418 void WriteVectWire( HaAtom* src, HaAtom* dst, int col, int dash );
00419 void WriteVectStick(HaAtom* src,HaAtom* dst, int col, int rad );
00420
00421 Long CountPSItems();
00422 void FetchPSItems( PSItemPtr *, char * );
00423 void WritePSItems( PSItemPtr *, char *, int );
00424 void WriteVectDots();
00425 void WriteVectLabels();
00426 void WriteVectMonitors();
00427 void FlushPICTBuffer();
00428 void FlushPICTPacket();
00429 void WritePICTCode(int val );
00430 void WritePICTData();
00431 void FlushIRISBuffer();
00432 void FlushIRISPacket();
00433 void WriteIRISCode(int val );
00434 void DetermineIRISSizes(Long* rowstart,short* rowsize, int* min, int* max );
00435 void WriteIRISHeader(Long* rowstart, short* rowsize, int min, int max );
00436 void WriteIRISData();
00437
00438 public:
00439 void WriteImageFile(const char* name, int type );
00440 int WritePPMFile( const char* name,int raw );
00441 int WriteGIFFile( const char* name );
00442 int WriteRastFile( const char* name, int encode );
00443 int WriteEPSFFile( const char* name, int col, int compr );
00444 int WriteBMPFile( const char* name );
00445 int WriteVectPSFile(const char* name );
00446 int WritePICTFile(const char* name );
00447 int WriteIRISFile(const char* name );
00448
00449 int WriteScriptFile(const char *name);
00450 int WriteKinemageFile(const char* name);
00451 int WriteMolScriptFile(const char* name);
00452 int WritePOVRayFile(const char* name);
00453 int WriteVRMLFile(const char* name);
00454
00455
00456
00457 public:
00458
00459 void WriteVRMLDots();
00460 void WriteVRMLColour( int indent, int shade );
00461 void WriteVRMLTriple( double x, double y, double z );
00462 void WriteVRMLAtoms();
00463 void WriteVRMLLine( int src, int dst, int shade, int* flag );
00464 void WriteVRMLWireframe();
00465
00466
00467
00468 protected:
00469 void WriteKinemageDots();
00470 void WriteKinemageData();
00471 int CheckKinemageChain( HaAtom* src, HaAtom* dst, HaChain* chain );
00472 void WriteKinemageLabels( HaChain* chain );
00473 void WriteKinemageRibbons(HaChain* chain );
00474 void WriteKinemageSpheres( HaChain* chain );
00475 void OutputKinemageVector( HaAtom* src, HaAtom* dst, int col );
00476 void WriteKinemageBonds( HaChain* chain );
00477
00478 protected:
00479 void WriteScriptAtoms();
00480 void WriteScriptBonds();
00481 void WriteScriptBackbone();
00482 void WriteScriptRibbons();
00483 void WriteScriptLabels();
00484 void WriteScriptMonitors();
00485 void WriteScriptHBonds( char* obj );
00486
00487 public:
00488
00489 Canvas3D* pCanv;
00490
00491 void DisplaySpaceFill();
00492 void DisplayWireframe();
00493 void DisplayCylinder(int x1,int y1,int z1,
00494 int x2,int y2,int z2,
00495 int c1,int c2,int rad);
00496 void DisplayDoubleBonds();
00497 void DisplayBackbone();
00498 void DisplayHBonds( int mode );
00499 void DisplayBoxes();
00500 void DisplayOnScreenInfo();
00501 void DisplayPickedAtoms();
00502 void RenderFrame();
00503
00504 void TestAtomProximity( HaAtom* ptr, int xpos, int ypos);
00505 void IdentifyAtom( int xpos, int ypos );
00506 void InitializeTables();
00507 void InitializeRenderer();
00508
00509 };
00510
00511
00512
00513
00514
00515
00516 #define ForEachMol_VIEW for(mol_itr=(GetMolSet()->HostMolecules).begin(); mol_itr != (GetMolSet()->HostMolecules).end(); mol_itr++)
00517
00518 #define ForEachChain_VIEW for(mol_itr=(GetMolSet()->HostMolecules).begin(); mol_itr != (GetMolSet()->HostMolecules).end(); mol_itr++) \
00519 for(chain=(*mol_itr)->GetFirstChain();chain;chain=(*mol_itr)->GetNextChain())
00520 #define ForEachResidue_VIEW for(mol_itr=(GetMolSet()->HostMolecules).begin(); mol_itr != (GetMolSet()->HostMolecules).end(); mol_itr++) \
00521 for(chain=(*mol_itr)->GetFirstChain();chain;chain=(*mol_itr)->GetNextChain()) \
00522 for( group=chain->GetFirstRes(); group; group=chain->GetNextRes() )
00523 #define ForEachBack_VIEW for(mol_itr=(GetMolSet()->HostMolecules).begin(); mol_itr != (GetMolSet()->HostMolecules).end(); mol_itr++) \
00524 for(chain=(*mol_itr)->GetFirstChain();chain;chain=(*mol_itr)->GetNextChain()) \
00525 for(bptr=chain->GetFirstBackB(); bptr; bptr= chain->GetNextBackB())
00526
00527
00528 const int PickNone = 0x00;
00529 const int PickIdent = 0x01;
00530 const int PickDist = 0x02;
00531 const int PickAngle = 0x03;
00532 const int PickTorsn = 0x04;
00533 const int PickLabel = 0x05;
00534 const int PickMonit = 0x06;
00535 const int PickCentr = 0x07;
00536 const int PickMolConnect = 0x08;
00537
00538 const int DefaultWide = 480;
00539 const int DefaultHigh = 480;
00540
00541 const int RFRotateX = 0x0001;
00542 const int RFRotateY = 0x0002;
00543 const int RFRotateZ = 0x0004;
00544 const int RFZoom = 0x0008;
00545 const int RFTransX = 0x0010;
00546 const int RFTransY = 0x0020;
00547 const int RFTransZ = 0x0040;
00548 const int RFSlab = 0x0080;
00549 const int RFReSize = 0x0100;
00550 const int RFColour = 0x0200;
00551 const int RFRefresh = 0x0400;
00552 const int RFPoint1 = 0x1000;
00553 const int RFPoint2 = 0x2000;
00554
00555 const int RFTrans = 0x0070;
00556 const int RFRotate = 0x0007;
00557 const int RFApply = 0x017F;
00558 const int RFDials = 0x00FF;
00559 const int RFMagnify = 0x0108;
00560 const int RFInitial = 0x01FF;
00561 const int RFPoint = 0x3000;
00562
00563
00564 const int MMRasMol = 0x00;
00565 const int MMInsight = 0x01;
00566 const int MMQuanta = 0x02;
00567
00568
00569 const int ViewLeft = 0;
00570 const int ViewRight = 1;
00571
00572 unsigned int isqrt( unsigned int );
00573
00574 #define ZValid_v(z) ((!UseSlabPlane() ) || ((z) < SlabValue()))
00575 #define XValid_v(x) (((x)>=0)&&((x)< pCanv->View.xmax))
00576 #define YValid_v(y) (((y)>=0)&&((y)< pCanv->View.ymax))
00577
00578 #ifdef HAMOLVIEW_CPP
00579
00580 HaMolView* CurMolView;
00581
00582 #else
00583
00584 extern HaMolView* CurMolView;
00585
00586 #endif
00587
00588
00589 #endif // !defined HAMOLVIEW_H