1 /* Copyright (c) 2015 Gerald Knizia 2 * 3 * This file is part of the IboView program (see: http://www.iboview.org) 4 * 5 * IboView is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, version 3. 8 * 9 * IboView is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with bfint (LICENSE). If not, see http://www.gnu.org/licenses/ 16 * 17 * Please see IboView documentation in README.txt for: 18 * -- A list of included external software and their licenses. The included 19 * external software's copyright is not touched by this agreement. 20 * -- Notes on re-distribution and contributions to/further development of 21 * the IboView software 22 */ 23 24 #ifndef ORBVIEW_DOCUMENT_H 25 #define ORBVIEW_DOCUMENT_H 26 27 #include "Iv.h" 28 29 #include <map> 30 #include <set> 31 #include <vector> 32 33 #include <QString> 34 #include <QAbstractTableModel> 35 #include <QAction> 36 #include <QExplicitlySharedDataPointer> 37 #include <QSharedData> 38 39 40 #include "CtAtomSet.h" 41 #include "CtBasisSet.h" 42 #include "CxPodArray.h" 43 // #include "CxColor.h" 44 #include "IvMesh.h" 45 #include "IvGl.h" 46 #include "IvIsoSurface.h" 47 #include "CtMatrix.h" 48 #include "IvLog.h" 49 #include "IvTables.h" 50 51 52 using ct::FAtomSetPtr; 53 using ct::FBasisSetPtr; 54 using ct::TArray; 55 using ct::FIntrusivePtrDest; 56 namespace ct { 57 struct FHfOptions; 58 struct FWfDecl; 59 } 60 61 62 // // abstract base class for storing intermediate data for rendering, 63 // // which is associated with data sets 64 // struct FRenderCache : public ct::FIntrusivePtrDest 65 // { 66 // virtual ~FRenderCache(); 67 // private: 68 // FRenderCache(FRenderCache const &); // not implemented 69 // void operator = (FRenderCache const &); // not implemented 70 // }; 71 // 72 // typedef boost::intrusive_ptr<FRenderCache> 73 // FRenderCachePtr; 74 75 class FView3d; 76 class FDocument; 77 78 class FWfOptions : public QObject 79 { 80 Q_OBJECT 81 82 public: 83 #include "prop_FWfOptions.h.inl" 84 85 public: 86 FWfOptions(QObject *parent = 0); 87 88 // assign basis sets from HfOptions to pAtoms 89 void AssignBasisSets(ct::FAtomSet *pAtoms); 90 91 void AssignScfOptions(ct::FHfOptions &HfOptions); 92 void AssignWfDecl(ct::FWfDecl &WfDecl, ct::FAtomSet *pAtoms); 93 }; 94 95 struct FDataSet : public FIntrusivePtrDest 96 { 97 explicit FDataSet(QString const &Desc_, FAtomSetPtr pAtoms_ = 0, FDocument *pDocument_ = 0); 98 99 bool 100 Active; 101 FAtomSetPtr 102 pAtoms; 103 enum FDescFlags { 104 DESC_Full = 0x01, 105 DESC_Compact = 0x02 106 }; 107 108 // FRenderCachePtr 109 // pRenderCache; // may be 0. may be set to 0 at any point in time. 110 virtual QString GetType() const = 0; 111 virtual QString GetDesc(uint Flags=0) const; // default: return m_Desc 112 113 // rebuild the visual representation of the object on next rendering. 114 virtual void InvalidateRenderCache(); 115 virtual void BuildRenderCache(FView3d *pView3d); 116 117 virtual uint32_t GetBaseColor() const; 118 119 virtual bool DependsOnWaveFunction() const; 120 121 // return pointer to its parent object. GetDocumentFDataSet122 FDocument *GetDocument() { return m_pDocument; }; 123 protected: 124 QString m_Desc; 125 FDocument *m_pDocument; 126 }; 127 typedef boost::intrusive_ptr<FDataSet> 128 FDataSetPtr; 129 130 enum FBondFlags { 131 BOND_Partial = 0x01, 132 BOND_Grey = 0x02 // make the bond grey instead of the usual half-bond with their attached atom colors. 133 }; 134 135 struct FBondLine { 136 int 137 iAt, jAt; 138 uint 139 Flags; FBondLineFBondLine140 FBondLine() {}; FBondLineFBondLine141 FBondLine(int iAt_, int jAt_, uint Flags_) : iAt(iAt_), jAt(jAt_), Flags(Flags_) {} 142 }; 143 144 enum FAtomFlag { 145 // do not show the atom in renderings 146 ATOM_Hidden = 0x01, 147 // if aligning the molecule in space, ignore this atom when determining 148 // the aligning transformation. 149 ATOM_NoAlign = 0x02, 150 // atom is part of an currently active selection 151 ATOM_Selected = 0x04 152 }; 153 154 struct FGeometry : public FDataSet 155 { 156 explicit FGeometry(QString const &Desc_, FAtomSetPtr pAtoms_, FDocument *pDocument_); 157 QString GetType() const; // override 158 // add a dotted bond to indicate the formation/breaking of a bond between the indexed atoms. 159 void AddBond(FBondLine const &bl); 160 void AddBond(int iAt, int jAt, QString const &Flags); 161 void DeleteBond(int iAt, int jAt, bool ComplainIfNotThere=true); 162 void FindBondLines(FDocument *pDocument); 163 public: 164 std::vector<FBondLine> 165 m_BondLines; 166 protected: 167 void FixMinBasis(); 168 }; 169 170 171 struct FOrbital; 172 173 // describes the configuration of the visual representation of an orbital iso surface. 174 // These objects are *shared* between associated orbitals in different frames. 175 struct FOrbitalVisualConfig : public FIntrusivePtrDest 176 { 177 bool 178 bColorSet; 179 FIsoType 180 iIsoType; 181 float 182 fIsoValue; 183 uint32_t 184 cIsoPlus, cIsoMinus; 185 void AssignDefaultColor(FDocument *pDocument); 186 187 FOrbitalVisualConfig(); 188 public: 189 typedef std::set<FOrbital*> 190 FOrbitalChain; 191 FOrbitalChain 192 // list of all orbitals which are linked with this configuration object 193 // (note: these are weak refs; the orbitals own the config object (via 194 // ref), not the other way around!) 195 LinkedOrbitals; 196 void Link(FOrbital *pOrbital); 197 void Unlink(FOrbital *pOrbital); 198 199 enum FUpdateFlags { 200 UPDATE_InvalidateIsoSettings = 0x01, 201 UPDATE_InvalidateColors = 0x02, 202 UPDATE_Rebuild = 0x04 // <- for this pView3d must be supplied! 203 }; 204 205 // Apply given update/change to all data sets which share this object. 206 // argument: bit field of UPDATE_* flags. 207 void UpdateLinkedRepresentations(uint32_t Flags, FView3d *pView3d=0); 208 private: 209 void operator = (FOrbitalVisualConfig const &); // not implemented 210 FOrbitalVisualConfig(FOrbitalVisualConfig const &); // not implemented 211 // ^- note: it is not the actual config part of which copying is the problem... 212 // the linked reference chain is. It might be useful to split this class into 213 // two parts: one "shared dataset properties" class which represents the links, 214 // and one for the actual visual configuration. This may become useful once other 215 // kinds of data sets besides orbitals and geometries are introduced. 216 }; 217 typedef boost::intrusive_ptr<FOrbitalVisualConfig> 218 FOrbitalVisualConfigPtr; 219 220 typedef std::vector<int> 221 FAtomIdList; 222 223 // encodes the result of a partial charge analysis 224 struct FChargeAnalysis 225 { 226 struct FKey { 227 int iAt; // atom number (in frame, not element) 228 int AngMom; // angular momentum of the AO carrying the current entry. 229 FKeyFChargeAnalysis::FKey230 FKey() {} FKeyFChargeAnalysis::FKey231 explicit FKey(int iAt_, int AngMom_) : iAt(iAt_), AngMom(AngMom_) {} 232 bool operator < (FKey const &other) const { 233 if (iAt < other.iAt) return true; 234 if (other.iAt < iAt) return false; 235 return AngMom < other.AngMom; 236 } 237 }; 238 struct FValue { 239 double fCharge; 240 double fSpin; FValueFChargeAnalysis::FValue241 FValue() {} FValueFChargeAnalysis::FValue242 explicit FValue(double fCharge_, double fSpin_) : fCharge(fCharge_), fSpin(fSpin_) {} 243 }; 244 typedef std::map<FKey, FValue> 245 FMap; 246 FMap 247 m_Data; 248 bool 249 m_RestrictAtoms; // if given: exclude atoms not in m_SelectedAtoms. 250 FAtomIdList 251 m_SelectedAtoms; 252 ct::FAtomSet 253 &m_Atoms; 254 255 void Add(int iAt, int AngMom, double fCharge, double fSpin); 256 void MakeReport(ct::FLog &Log); // document only used for making labels.. 257 bool IsIncluded(int iAt) const; 258 259 std::string AtomLabel(int iAt) const; 260 261 int CountAtoms() const; 262 int FindMaxL() const; 263 bool bNonzeroSpin() const; 264 double MakeAtomTotalCharge(int iAt, double fCharge) const; 265 266 explicit FChargeAnalysis(ct::FAtomSet *pAtoms, FAtomIdList *pSelectedAtoms=0); 267 ~FChargeAnalysis(); 268 }; 269 270 271 // Maybe I should even use bitfields for Alpha and Beta? Then closed would be ALPHA | BETA. 272 enum FOrbitalSpin { 273 ORBSPIN_SpinFree, 274 ORBSPIN_Alpha, 275 ORBSPIN_Beta, 276 ORBSPIN_Unknown 277 }; 278 char const *pOrbDescFromType(FOrbitalSpin Type, double fOcc); 279 280 struct FOrbitalInfo { 281 double 282 fEnergy, 283 fOcc; 284 int 285 iSym; 286 FOrbitalSpin 287 Spin; 288 int 289 iOriginalIndex; 290 explicit FOrbitalInfo(double fEnergy_=0, double fOcc_=0., int iSym_=0, FOrbitalSpin OrbSpin_=ORBSPIN_Unknown); 291 QString MakeDesc(QString RefName) const; 292 QString MakeDesc(size_t iOrb) const; 293 294 double fChargeFactor() const; 295 double fSpinFactor() const; 296 }; 297 298 enum FWfType { 299 WFTYPE_Rhf, // only orbitals with occupancy closed or alpha 300 WFTYPE_Uhf, // only orbitals with occupancy alpha or beta 301 WFTYPE_Mcscf, // spin-free orbitals, but with occupation numbers other than 1.0 or 2.0 (can still make IAO charges, but not bond orders or IBOs for the active space) 302 WFTYPE_Other 303 }; 304 305 struct FOrbital : public FDataSet 306 { 307 typedef FDataSet 308 FBase; 309 310 explicit FOrbital(QString const &Desc_, FAtomSetPtr pAtoms_, FDocument *pDocument_, FBasisSetPtr pBasisSet_, double *pCoeffs_, FOrbitalInfo const &info_, FOrbitalVisualConfigPtr pRefVisConfig, double *pDm=0, double *pQm=0); 311 ~FOrbital(); 312 313 FOrbitalVisualConfigPtr 314 pVisConfig; 315 void LinkVisualConfig(FOrbitalVisualConfigPtr p); 316 317 bool HaveMoments; 318 double vDipMom[3]; // dipole moment and quadrupole moment. 319 double mQuadMom[3][3]; 320 321 322 FOrbitalInfo 323 info; 324 FBasisSetPtr 325 pBasisSet; 326 TArray<double> 327 pCoeffs; 328 // ^- if this is a orbital-like-quantity, then these are its expansion 329 // coefficients. over pBasisSet. 330 331 // minimal basis and IAO coefficients of the orbitals; used for tracking 332 // orbital changes. 333 FBasisSetPtr 334 pMinBasis; 335 TArray<double> 336 pIaoCoeffs; 337 TArray<double> MakeIaoCharges(bool UseOccupationNumbers=true) const; // make IAO charges from IAO coeffs. 338 void AddChargeContributions(FChargeAnalysis &Charges) const; 339 340 QString GetType() const; // override 341 342 enum FFullDescOptions { 343 ORBDESC_ChargesOnly = 0x01, 344 ORBDESC_CompactSpace = 0x02 345 }; 346 QString MakeFullDesc(double ThrPrint = 0.02, uint Flags = 0, int nMaxAtoms = -1) const; 347 348 QString GetDesc(uint Flags=0) const; // override 349 void UpdateDescFromInfo(size_t iOrb); 350 351 // multiply coefficients by -1. 352 void FlipPhase(); 353 354 // just update the colors of the mesh (i.e., rebuild the GL mesh), but leave 355 // the mesh itself alone. 356 void InvalidateColors(); 357 358 virtual uint32_t GetBaseColor() const; 359 virtual bool DependsOnWaveFunction() const; // override 360 public: 361 FGlMeshPtr 362 pGlMesh; // should probably not be here (and wasn't before), but need it for 363 // changing color data/iso surface settings. 364 365 void InvalidateRenderCache(); // override 366 void BuildRenderCache(FView3d *pView3d); // override 367 }; 368 typedef boost::intrusive_ptr<FOrbital> 369 FOrbitalPtr; 370 371 typedef std::vector<FDataSetPtr> 372 FDataSetList; 373 struct FFrame : public QObject, FIntrusivePtrDest 374 { 375 explicit FFrame(QString Desc_, FDocument *pDocument_); 376 377 enum FOrbitalMatrixFlags { 378 ORBMAT_OccupiedOnly = 0x01, 379 ORBMAT_VirtualOnly = 0x02, 380 ORBMAT_AlphaAndClosedOnly = 0x04, 381 ORBMAT_BetaAndClosedOnly = 0x08, 382 ORBMAT_AlphaOnly = 0x10, 383 ORBMAT_ClosedOnly = 0x20, 384 ORBMAT_BetaOnly = 0x40 385 }; 386 387 FGeometry *pGetGeometry(); pGetGeometryFFrame388 FGeometry const *pGetGeometry() const{ return const_cast<FFrame*>(this)->pGetGeometry(); }; 389 ct::FAtomSet *pGetAtoms(); pGetAtomsFFrame390 ct::FAtomSet const *pGetAtoms() const { return const_cast<FFrame*>(this)->pGetAtoms(); }; 391 FOrbital *pGetOrbital(int iMo); // note: this is an "orbital number" (i.e., starts a 1, goes to nMo). 392 double GetEnergy() const; 393 double GetGradient() const; 394 395 QString GetBaseInputFileName() const; 396 QString GetFullInputFileName() const; 397 398 // collect all coefficients (and the current basis) of orbitals in *this. 399 // notes: 400 // - COrb (output) is allocated on Mem. 401 // - If pRefOrbitals != 0, then a pointer to COrb(:,iOrb) will be stored in (*pRefOrbitals)[iOrb]. 402 void MakeOrbitalMatrix(ct::FMatrixView &COrb, FBasisSetPtr &pBasis2, TArray<FOrbital*> *pRefOrbitals, uint32_t Flags, ct::FMemoryStack &Mem); 403 // void MakeIaoCoeffs(FWfOptions *pWfOptions, ct::FMemoryStack &Mem); 404 void RunIaoAnalysis(ct::FLog &Log, FWfOptions *pWfOptions, bool AllowLocalize, ct::FMemoryStack &Mem); 405 void MakeOrbitalMoments(ct::FMemoryStack &Mem); 406 void LinkOrbitalsToPreviousFrame(FFrame *pPrevFrame, ct::FMemoryStack &Mem); 407 // bool CanDoIaoAnalysis(); 408 409 ct::FMatrixView MakeIaoBasis(ct::FAtomSet *pAtoms, ct::FMemoryStack &Mem); 410 411 void RunChargeAnalysis(ct::FLog &Log, FAtomIdList *pSelectedAtoms = 0); 412 413 // returns whether or not any orbital data sets are present. 414 bool HaveOrbitals() const; 415 // delete all electronic structure stuff we might be keeping. 416 void ClearOrbitals(); 417 418 FWfType GetWfType(); 419 420 // find the data set row in which a given object is currently stored. 421 int FindRow(FDataSet* pSet); rowCountFFrame422 int rowCount() const { return (int)m_Data.size(); } 423 424 FDataSetList 425 m_Data; 426 LogFFrame427 FMemoryLogQt &Log() { return *m_pFrameLog; } 428 protected: 429 FMemoryLogQt 430 *m_pFrameLog; 431 QString 432 m_InputFileName; 433 FBasisSetPtr 434 m_pOrbBasis, 435 m_pMinBasis; 436 TArray<double> 437 m_CIaoData; // coefficients of IAOs in terms of main basis 438 ct::FMatrixView 439 m_CIb; 440 FDocument 441 *m_pDocument; // parent of the frame. used to take settings from. 442 }; 443 444 445 // script interface 446 class IFrame : public FFrame 447 { 448 Q_OBJECT 449 450 Q_PROPERTY(QString name READ get_name WRITE set_name); 451 public slots: 452 // add/remove bond lines. Atom indices are 1-based here. 453 virtual void add_bond(int iAt, int jAt, QString const &Flags); // = 0; 454 virtual void delete_bond(int iAt, int jAt); // = 0; 455 virtual void reset_bonds(); // = 0; // reset all bonds to normal. 456 virtual QString get_name(); 457 virtual void set_name(QString const &Name); 458 459 virtual void scale_mo(int iMo, double fFactor); // = 0; 460 virtual void rot_mos_2x2(int iMo, int jMo, double fAngle); // = 0; 461 public: 462 explicit IFrame(QString Desc_, FDocument *pDocument_); 463 }; 464 465 typedef boost::intrusive_ptr<IFrame> 466 FFramePtr; 467 468 469 enum FSelectionMode { 470 SELECT_Select, // delete previous selection and make a new selection with given objects 471 SELECT_Toggle, // toggle selection state of given objects 472 SELECT_Add // add to previous selection 473 }; 474 475 476 struct FBondChangeAction : public QAction 477 { 478 Q_OBJECT 479 public: 480 enum FBondChangeActionType { 481 ACTION_Hide, 482 ACTION_SetStyleDotted, 483 ACTION_Reset 484 }; 485 FBondChangeActionFBondChangeAction486 FBondChangeAction(int iAt_, int jAt_, FBondChangeActionType Type_, QString Text_, QObject *Parent_) 487 : QAction(Text_, Parent_), m_Type(Type_), m_iAt(iAt_), m_jAt(jAt_) 488 {} 489 490 FBondChangeActionType 491 m_Type; 492 int 493 m_iAt, m_jAt; 494 }; 495 496 typedef std::vector<int> 497 FFrameIndexList; 498 499 500 int const ColorNotSet = 0x04030201; // if you are thinking of using this: Use black instead 8). 501 502 // this class doubles as element properties and per-atom settings container. 503 // It is used for exposing these settings to user modification and to scripts. 504 // It is a bit more complicated than the other property classes, as all the properties 505 // just default to "not set"... 506 class FElementOptions : public QObject, public QSharedData { 507 Q_OBJECT 508 public: 509 #include "prop_FElementOptions.h.inl" 510 511 explicit FElementOptions(int iElement_, QObject *parent=0); 512 explicit FElementOptions(FElementOptions const *other, QObject *parent=0); 513 iElement()514 int iElement() const { return m_iElement; } 515 // return the bond color if explicitly set, and otherwise the atom color. 516 uint32_t GetBondColor1() const; 517 protected: 518 // these ones get stuff from tables. 519 uint32_t GetDefaultColor() const; 520 uint32_t GetDefaultBondColor() const; 521 double GetDefaultCovalentRadius() const; 522 double GetDefaultDrawRadius() const; 523 char const *ElementName() const; 524 525 int 526 m_iElement; 527 void InitForElement(int iElement_); 528 }; 529 typedef QExplicitlySharedDataPointer<FElementOptions> 530 FElementOptionsPtr; 531 typedef QList<FElementOptionsPtr> 532 FElementOptionsList; 533 534 struct FAtomOptions { 535 uint 536 // bitfield of FAtomFlag type. (ATOM_*) 537 Flags; 538 int64_t 539 // sequence number in order to keep track of order in which things were selected 540 // (important for bond angle and dihedral measures) 541 iSelectionSequenceId; 542 FElementOptionsPtr 543 // used to provide values to the atom which differ from the default element properties. 544 pPropertiesOverride; 545 FAtomOptionsFAtomOptions546 FAtomOptions() : Flags(0), iSelectionSequenceId(-1) {} 547 }; 548 549 // used for alignment and IRC/other arc-length purposes. 550 struct FFrameCoords : public FIntrusivePtrDest 551 { 552 ct::FAtomSet// const 553 *pAtoms; 554 std::vector<double> 555 pAtMass; 556 std::vector<ct::FVector3> 557 pAtPos; 558 FDocument 559 *pDocument; 560 explicit FFrameCoords(FGeometry *pGeometry); 561 virtual ~FFrameCoords(); 562 emptyFFrameCoords563 bool empty() const { return pAtMass.empty(); } 564 }; 565 typedef boost::intrusive_ptr<FFrameCoords> 566 FFrameCoordsPtr; 567 568 // idea: rows == associated data sets per frame, 569 // cols == frames. 570 // (note that they may come in non-natural orders for later frames and that 571 // some cells might be missing) 572 class FDocument : public QAbstractTableModel 573 { 574 Q_OBJECT 575 576 public: Q_PROPERTY(QString atom_weight_mode READ GetAtomWeightMode WRITE SetAtomWeightMode NOTIFY AtomWeightModeChanged)577 Q_PROPERTY(QString atom_weight_mode READ GetAtomWeightMode WRITE SetAtomWeightMode NOTIFY AtomWeightModeChanged) 578 Q_SLOT void SetAtomWeightMode(QString o) { m_AtomWeightMode = o; } 579 Q_SIGNAL void AtomWeightModeChanged(QString o); GetAtomWeightMode()580 QString GetAtomWeightMode() const { return m_AtomWeightMode; }; 581 Q_PROPERTY(bool skip_virtual_orbitals READ GetSkipVirtualOrbitals WRITE SetSkipVirtualOrbitals NOTIFY SkipVirtualOrbitalsChanged)582 Q_PROPERTY(bool skip_virtual_orbitals READ GetSkipVirtualOrbitals WRITE SetSkipVirtualOrbitals NOTIFY SkipVirtualOrbitalsChanged) 583 Q_SLOT void SetSkipVirtualOrbitals(bool o) { m_SkipVirtualOrbitals = o; } 584 Q_SIGNAL void SkipVirtualOrbitalsChanged(bool o); GetSkipVirtualOrbitals()585 bool GetSkipVirtualOrbitals() const { return m_SkipVirtualOrbitals; }; 586 587 // hmpf... doc is not actually exposed to script currently. Script's 'doc' variable actually links to IApplication. 588 // needs bigger re-design to work.. Q_PROPERTY(FElementOptionsList elements READ GetElementOptions)589 Q_PROPERTY(FElementOptionsList elements READ GetElementOptions) // note: this COPIES the list! 590 FElementOptionsList const &GetElementOptions() const { return m_ElementOptions; }; GetElementOptions()591 FElementOptionsList &GetElementOptions() { return m_ElementOptions; }; 592 public: 593 FDocument(QObject *parent); 594 int rowCount(const QModelIndex &parent = QModelIndex()) const; 595 int columnCount(const QModelIndex &parent = QModelIndex()) const; 596 QVariant headerData(int section, Qt::Orientation orientation, int role) const; 597 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 598 599 uint &AtomFlags(int iAt); 600 FAtomOptions &AtomOptions(int iAt); 601 bool IsAtomHidden(int iAt); 602 bool IsAtomSelected(int iAt); 603 bool IsAtomExcludedFromAlignment(int iAt); 604 FElementOptions *pElementOptions(int iAt, ct::FAtomSet *pAtoms = 0); 605 // ^- pAtoms: if given, take data for atoms from this atom set. Otherwise: from current frame. 606 607 void UnselectAll(bool EmitUpdate=true); 608 void SelectAtom(int iAt, FSelectionMode SelectMode); 609 void UpdateSelectedAtomsStatusText(); 610 // count the number of atoms which presently are selected. 611 int nSelectedAtoms(); 612 int nAtomsWithFlags(); // count largest number of defined centers. 613 614 QString AtomLabel(int iAt) const; 615 616 public: 617 typedef std::vector<FFramePtr> 618 FFrameList; 619 FDataSetPtr GetActiveDataSet(); 620 // ct::FAtomSet 621 // Atoms; 622 void Load(QStringList FileNames); 623 624 // this will change the document by either re-ordering frames or deleting a 625 // subset of the previous frames. iNewIndices gives the indices of the new 626 // frames in the new order they are supposd to appear in. Any frame not 627 // contained herein will be removed. 628 void ReorderOrRestrictFrameSet(FFrameIndexList const &iNewIndices); 629 630 IFrame *GetCurrentFrame(); 631 IFrame *GetCurrentFrame() const; 632 FDataSetList *GetCurrentFrameData(); 633 FDataSetList *GetFrameData(int iFrame); 634 635 IFrame *GetFrame(int Idx, bool AssertExists=true); 636 FDataSet *GetRow(int Idx, bool AssertExists=true); 637 FDataSet *GetRowCol(int iRow, int iCol, bool AssertExists=true); 638 IFrame const *GetFrame(int Idx, bool AssertExists=true) const; 639 FDataSet const *GetRow(int Idx, bool AssertExists=true) const; 640 FDataSet const *GetRowCol(int iRow, int iCol, bool AssertExists=true) const; GetActiveColIndex()641 int GetActiveColIndex() const { return m_ActiveCol; }; GetActiveRowIndex()642 int GetActiveRowIndex() const { return m_ActiveRow; }; GetNumFrames()643 int GetNumFrames() const { return int(m_Frames.size()); } 644 645 void GetNextOrbitalColors(uint32_t &cIsoPlus, uint32_t &cIsoMinus); 646 647 QString GetCurrentInputFileName(); 648 QString GetCurrentInputBaseFileName(); 649 QString GetCommonInputFileName(); 650 // public slots: 651 // void onToggleDataset(const QModelIndex &index); 652 // void onSelectDataset(const QModelIndex &index); 653 654 void AlignFrames(QString Mode); SetInputFileName(QString FileName_)655 void SetInputFileName(QString FileName_) { m_InputFileName = FileName_; } 656 QString GetAtomLabel(int iAt); 657 GetWfOptions()658 FWfOptions *GetWfOptions() { return m_pWfOptions; }; // should this be here? 659 void ClearOrbitals(bool EmitSignals=true); 660 GetMeasures()661 FDocumentMeasures *GetMeasures() { return m_pMeasures; }; 662 663 size_t iFrameId(FFrame *pFrame) const; 664 bool HaveEnergies() const; 665 bool HaveGradients() const; 666 bool HaveOrbitals() const; 667 public slots: 668 void ToggleDataRow(int iIndex); 669 void SetActiveCol(int iIndex); 670 // ForceUpdate: force emit signal even if new row is equal to old row 671 // (e.g., if properties of the row have changed, like its activity status) 672 void SetActiveRow(int iIndex, bool ForceUpdate = false, bool UpdateStatus=true); 673 674 void HideSelectedAtoms(); 675 void ClearAtomFlags(bool EmitUpdate=true); 676 void FindOrbitalsOnSelectedAtoms(); 677 void CalcChargesOnSelectedAtoms(); 678 void MakeHybridsForSelectedAtomGroup(); 679 void ToggleActiveDataRow(); 680 void MakeBondLinesForSelectedAtoms(); 681 void ResetBondLines(); 682 683 // link most-similar orbitals between all frames 684 void LinkOrbitals(); 685 686 // data comes in over the QAction (sender), which should be a FBondChangeAction 687 void ChangeSelectedBond(); 688 689 // these control the way new orbital colors are assigned. 690 void SetNextOrbitalColorIndex(int Value); 691 void SetNextOrbitalColorScheme(int Index); 692 693 void RebuildWf(FLogQt &Log); 694 void Clear(); // delete everything. 695 696 // make a list of the smart pointers (in order to keep references to them) 697 // to defer their point of deletion to a later point. Required due to GL-weiredness. 698 // See rebuid wf code in IvMain.cpp. 699 void AcquireFrameObjectLock(FDataSetList &ObjectLock); 700 701 signals: 702 void ActiveDatasetChanged(); 703 void ActiveColChanged(int iIndex); 704 void ActiveRowChanged(int iIndex); 705 void SelectionChanged(); 706 707 // i.e., "please update the 3d view" 708 void VisualRepresentationChanged(); 709 void NextOrbitalColorIndexChanged(int Value); 710 protected: 711 FElementOptionsList 712 m_ElementOptions; 713 714 FFrameList 715 m_Frames; 716 int 717 m_ActiveRow, 718 m_ActiveCol; 719 QString 720 m_InputFileName; // only set if this is a script? 721 int64_t 722 m_SelectionSequenceId; 723 724 typedef std::map<int, FAtomOptions> 725 FAtomOptionMap; 726 FAtomOptionMap 727 m_AtomOptions; 728 QString 729 // default mode for aligning frame geometries to each other 730 // and/or weighting atoms for arc lengths. 731 m_AtomWeightMode; 732 bool 733 // if set, do not load or compute virtual orbitals 734 m_SkipVirtualOrbitals; 735 736 FDocumentMeasures 737 *m_pMeasures; 738 739 // these two control the way new orbital colors are chosen. 740 // (used when orbitals are first rendered iff they have no color sets 741 // assigned otherwise) 742 ptrdiff_t 743 m_iNextOrbitalColor; 744 size_t 745 m_iNextOrbitalColorScheme; 746 747 // void FindAligningTrafo(double pR[9], double pD[3], ct::FAtomSet *pAtoms, std::string const &Mode, ct::FMemoryStack &Mem); 748 FFrameCoordsPtr MakeFrameCoords(int iFrame); 749 void FindAligningTrafo(double pR[9], double pD[3], FFrameCoords *pThis, FFrameCoords *pLast, ct::FMemoryStack &Mem); 750 751 // delete all cached geometric data of orbitals 752 void ClearOrbitalRepresentations(); 753 754 void LoadFile(FFrameList &LoadedFrames, QString FileName); 755 // returns true if the given file was identified as an orbital file (independent of whether loading it worked or not). 756 bool LoadOrbitalFile(FFrameList &LoadedFrames, QString FileName); 757 void LoadXyzFile(FFrameList &LoadedFrames, QString FileName); 758 759 void MakeOrbitalMoments(); 760 void MakeOrbitalCharges(); 761 void MakeOrbitalCachedData(); 762 763 // not: may be called only during document load. 764 void BeginInsertFrames(); 765 void InsertFrame(FFramePtr pFrame); 766 void EndInsertFrames(); 767 768 void BeginTotalReset(); 769 void EndTotalReset(); 770 771 int 772 m_CallEndInsertRows; // -1: BeginInsertFrames not called. 773 FFrameList 774 m_FramesToInsert; // used only during InsertFrame operatations. 775 FWfOptions 776 *m_pWfOptions; 777 778 typedef std::vector<int> 779 FAtomIdList; 780 FAtomIdList GetSelectedAtoms(bool SortedBySelectionSequence = true); 781 }; 782 783 784 // ^- note: automoc requires Q_OBJECT derived classes to be defined in 785 // HEADER FILES. Otherwise it won't find them. Will result in "undefined 786 // reference to 'vtable for ...'" errors. 787 788 789 790 791 #endif // ORBVIEW_DOCUMENT_H 792