MainPage   Related pages 
CoreAPI.h
1 
2 //
3 // $Id: CoreAPI.h 6077 2022-03-22 11:30:05Z stefan.losch $
4 // (c) ceapoint aec technologies GmbH
5 //
6 
7 
8 
9 #pragma once
10 
11 
12 #include <basic/IProgressDelegate.h>
13 #include <model/IProject.h>
14 #include <model/IObject.h>
15 
16 #include <domainDocuments/DocumentProject.h>
17 #include <domainDocuments/Document.h>
18 
19 #include <domainQTO/QTOProject.h>
20 #include <domainQTO/ConstructionElement.h>
21 
22 
23 // test reading and parsing a json file with cache
24 //#define ENABLE_READJSON 1
25 
26 
27 namespace domainGeometry3D {
28  class Project;
29 }
30 
31 
32 namespace domainBim
33 {
34 
35  class BimProject;
36 
53  class CoreAPI : public QObject, public basic::IProgressDelegate
54  {
55  Q_OBJECT
56 
57  public:
58 
59  static bool BLOCK_UNSAFE;
60 
62 
63  CoreAPI::CoreAPI( BimProject* bimPrj, QObject* parent = 0);
64  virtual ~CoreAPI();
65 
66  BimProject* getBimProject() const { return _bimProject; }
68 
70 
71  public slots:
72 
73 
74 #pragma region TOOLS
75 
88  QString addDays(QString dateStr, int nrDays);
89 
97  QString timeStamp( QString format = QString() );
98 
111  int getCalendarWeek( QDateTime dt );
112 
126  QString format( double v, int dec = 2, QString frmt = "%L1", int fieldWidth = 10, QChar fillChar = QChar::Nbsp ) { return frmt.arg(v,fieldWidth,'f',dec,fillChar); }
127 
164  QString formatDateTime( QDateTime dt, QString formatstr = "iso" );
165 
170  QString createID();
171 
176  long calcHashcode( QString str );
177 
196  QString compressToIfcGuid(QString id);
197 
204  QString uncompressFromIfcGuid(QString ifcGuid);
205 
224  bool checkRegExp( QString value, QString pattern );
225 
238  double calcSlantedArea(QString objId, double angleMin = 0.0, double angleMax = 45.0);
239 
272  QVariantMap calcGpsCoordsByStation( QString objId, double station );
273 
296  QVariantMap calcGpsCoordsByModelCoords( double x, double y );
297 
318  QVariantMap calcModelCoordsByGpsCoords( double lat, double lon );
319 
346  QVariantMap calcGkCoordsByModelCoords( double x, double y, double z );
347 
352  QVariantMap calcModelCoordsByGkCoords( double r, double h );
353 
375  QVariantMap calcGkCoordsByGpsCoords( double lat, double lon );
376 
399  QVariantMap calcGpsCoordsByGkCoords( double rw, double hw );
400 
405  QString idListToStr( QStringList idList );
406 
411  QStringList strToIdList( QString strIDList );
412 
413 
415 #pragma endregion
416 
417 
418 #pragma region TOOLS - FILES
419 
434  QVariantMap getFileInfo( QString filePath );
435 
443  QString getAbsolutePath( QString filePath );
444 
453  QString getBaseName( QString filePath );
454 
462  QString getFileName( QString filePath );
463 
464 
465 
466 
467  /*
468  test of caching a parsed json file
469  */
470 #ifdef ENABLE_READJSON
471  QVariantMap readJsonFromTextFile( QString filename, bool useCache = true, QString codec = QString() );
472 #endif
473 #pragma endregion
475 
476 
477 #pragma region APPLICATION
478 
483  QString getApplicationDirectory();
484 
489  QString getApplicationFilename();
490 
495  virtual QString getApplicationLanguage();
496 
502  QString getVersionAsString();
503 
514  int getVersionMAJOR();
515 
526  int getVersionMINOR();
527 
538  int getVersionBUILD();
539 
550  QVariantMap getVersion();
551 
557  bool requireVersion( int major, int minor, int patch );
558 
559 
561 #pragma endregion
562 
563 
564 #pragma region PROJECT
565 
570  QString getUserName();
571 
575  QString getProjectID();
576 
581  int getProjectVariantNumber();
582 
592  int getProjectVersionNumber();
593 
598  QString getProjectNumber();
599 
603  int setProjectNumber(QString s, bool overwriteExisting = false);
604 
608  QString getProjectName();
609 
613  QString getProjectShortDescription();
614 
618  int setProjectShortDescription(QString s, bool overwriteExisting = false);
619 
623  QString getProjectLongDescription();
624 
628  int setProjectLongDescription(QString s, bool overwriteExisting = false);
629 
633  QString getProjectDirectory();
634 
635 
654  QString getLocation();
655 
656 
668  QVariantMap getProjectLocation() const;
669 
683  QVariantMap getCloudSettings();
684 
710  QVariantMap getProjectInfo();
711 
713 #pragma endregion
714 
715 
716 #pragma region DOMAINS
717 
744  QString getDomainByElement( QString objId );
745 
747 #pragma endregion
748 
749 
750 #pragma region PROPERTIES
751 
791  QVariant getPropertyValue(QString objId, QString propName, QString propType, bool inh = true ); // , bool evaluate = true, bool formatAsString = false );
792 
840  QList<QVariant> getPropertyValuesByObject( QString objId, QString filterpattern = "*" );
841 
847  QVariant getPropertySource( QString objId, QString propName, QString propType, bool inh = true );
848 
849 
860  QString getPropertyUnit(QString objId, QString propName, QString propType, bool inh = true );
861 
862 
867  QString getPropertyUnit( QString propName, QString propType );
868 
889  QVariant getPropertyValueByDate(QString objId, QString propName, QString propType, bool inh = true );
890 
909  QDateTime getPropertyLastDate(QString objId, QString propName, QString propType, bool inh = true );
910 
926  QDateTime getPropertyFirstDate(QString objId, QString propName, QString propType, bool inh /* = true */ );
927 
994  QVariantMap getPropertyDateListAsJSON( QString objId, QString propName, QString propType, bool inh = true );
995 
1031  QVariantList getPropertyDateList(QString objectId, QString propertyBaseName, QString propertyType );
1032 
1068  QVariantMap getPropertyTypesByObject( QString objId, QString filterPattern = "*" );
1069 
1070 
1104  QVariantMap getPropertyTypesByDomain( QString domainName, QString filterPattern = "*" );
1105 
1106 
1128  QVariantMap getPropertyTypeMetaData( QString propName, QString propType );
1129 
1130 
1165  QList<QVariant> getPropertyTypeList( QString domain = "all", QString filterPattern = "*", bool activeOnly = false );
1166 
1167 
1206  QList<QVariant> getPropertyTypeListByObject( QString objId, QString filterPattern = "*" );
1207 
1208 
1214  bool isPropertyInherited(QString objId, QString propName, QString propType );
1215 
1216 
1226  QString getPropertyValueRange(QString idList, QString propName, QString propType, QString domainFilter = "geometry" );
1227 
1228 
1239  QStringList getPropertyValueList( QString propName, QString propType, int maxValues );
1240 
1241 
1253  QString getPropertyValueAsString(QString objId, QString propName, QString propType, bool inh = true );
1254 
1255 
1304  QVariant evaluateFormula( QString code, QString id, QString id_otherdomain = QString() );
1305 
1306 
1319  QString prepareJsCode( QString code, QString id, int dec = -1, QString frmt = "%L1", int fieldWidth = 10, QChar fillChar = QChar() );
1320 
1340  QStringList extractPropertyNames( const QString& code, const QString& startTag = "[[", const QString& endTag = "]]" );
1341 
1343 #pragma endregion
1344 
1345 
1346 #pragma region LINKS BETWEEN OBJECTS
1347 
1386  QStringList getLinkedObjects(QString objectIDList, QString resultDomains = "all", QString objectLookupDomains = "all");
1387 
1388 
1402  QStringList getTasksByObjectList(QString idList);
1403 
1413  QStringList getObjectsByTaskList(QString idList);
1414 
1415 
1425  QStringList getDocumentsByObjectList(QString idList);
1426 
1436  QStringList getObjectsByDocumentList(QString idList);
1437 
1438 
1448  QStringList getSectionsByObjectList(QString idList);
1449 
1459  QStringList getObjectsBySectionList(QString idList);
1460 
1461 
1471  QStringList getTypesByObjectList(QString idList);
1472 
1483  QStringList getObjectsByTypeList(QString idList);
1484 
1485 
1495  QStringList getResourcesByObjectList(QString idList);
1496 
1506  QStringList getObjectsByResourcesList(QString idList);
1507 
1508 
1516  QStringList getBoQItemsByObjectList(QString idList);
1517 
1524  QStringList getObjectsByBoQItemList(QString idList);
1525 
1526 
1535  QStringList getPcItemsByObjectList(QString idList);
1536 
1545  QStringList getObjectsByPcItemList(QString idList);
1546 
1548 #pragma endregion
1549 
1550 
1551 #pragma region OBJECT HIERARCHY
1552 
1567  QStringList getContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1568 
1580  int countContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1581 
1588  QString getParent(QString objId);
1589 
1599  QStringList getOpenings(QString objId);
1600 
1610  QStringList getParts(QString objId);
1611 
1613 #pragma endregion
1614 
1615 
1616 #pragma region STATUS
1617 
1626  bool isVisible(QString objId);
1627 
1632  bool isSelected(QString objId);
1633 
1638  bool isLocked(QString objId);
1639 
1644  bool isWired(QString objId);
1645 
1647 #pragma endregion
1648 
1649 
1650 #pragma region GEOMETRY
1651 
1667  QVariantList getPointList( QString objId );
1668 
1670 #pragma endregion
1671 
1672 
1673 #pragma region ALIGNMENTS / REGIONS
1674 
1693  QVariantMap getPointOnAlignmentAtStation( QString alignmentId, double d );
1694 
1710  double getStationOfProjectedPoint( QString alignmentId, double x, double y, double z = 0.0 );
1711 
1722  QStringList getRegionsOfAlignment( QString alignmentId );
1723 
1735  QVariantList getRangesOfRegion( QString alignmentID, QString regionID );
1736 
1737 
1749  double getValueOfAlignmentRegion( QString alignmentID, QString regionID );
1750 
1751 
1753 #pragma endregion
1754 
1755 
1756 #pragma region ACTIVITIES
1757 
1767  int getTaskMode(QString taskID);
1768 
1779  QString getTaskVisualisation(QString taskID);
1780 
1790  QString getTaskRestrictionsByTask(QString taskID);
1791 
1793 #pragma endregion
1794 
1795 #pragma region LINKRULES
1796 
1806  int updateRuleBasedLinks(QString domainName, bool visibleOnly = false);
1807 
1815  int removeRuleBasedLinks(QString domainName);
1816 
1818 #pragma endregion
1819 
1822  protected:
1823 
1824  /*
1825  Get object, looks up also containers in project
1826  */
1827  model::IContainerObject* getIContainerObject(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1828  model::IContainer* getIContainer(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1829  model::Element* getElement(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1830 
1831  model::IProperty* _getProperty( QString objId, QString propName, QString propType, bool inh );
1832  QVariant _getPropertyValue( const QString& objId, const QString& propName, const QString& propType, bool inh, bool evaluate, bool formatAsString );
1833 
1834  /*
1835  Collect geometric elements and composite elements.
1836  */
1837  void collectGeoObjects( const QString& idList, QList<model::IObject*>& list );
1838 
1839 
1840  private:
1841 
1842  QList<QDateTime> _getPropertyDateList(const QString& objId, const QString& propBaseName, const QString& propType, const QTime& defaultTime );
1843 
1844 
1845  CoreAPI(QObject* parent = 0);
1846 
1847  BimProject* _bimProject;
1848 
1851 #ifdef ENABLE_READJSON
1852  bool _firsttime;
1853  QVariantMap _fileCache;
1854 #endif
1855 
1856  };
1857 
1858 }
Definition: CoreAPI.h:32
Definition: CoreAPI.h:27
Definition: CoreAPI.h:53
QString format(double v, int dec=2, QString frmt="%L1", int fieldWidth=10, QChar fillChar=QChar::Nbsp)
Definition: CoreAPI.h:126

Created: Tue Dec 13 2022 13:14:00