MainPage   Related pages 
CoreAPI.h
1 
2 //
3 // $Id: CoreAPI.h 4018 2020-09-29 14:00:39Z ansgar.horstmann $
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 
61 
62  CoreAPI::CoreAPI( BimProject* bimPrj, QObject* parent = 0);
63  virtual ~CoreAPI();
64 
65  BimProject* getBimProject() const { return _bimProject; }
67 
69 
70  public slots:
71 
72 
73 #pragma region TOOLS
74 
87  QString addDays(QString dateStr, int nrDays);
88 
96  QString timeStamp( QString format = QString() );
97 
110  int getCalendarWeek( QDateTime dt );
111 
125  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); }
126 
151  QString formatDateTime( QDateTime dt, QString formatstr = "iso" );
152 
157  QString createID();
158 
163  long calcHashcode( QString str );
164 
183  QString compressToIfcGuid(QString id);
184 
191  QString uncompressFromIfcGuid(QString ifcGuid);
192 
211  bool checkRegExp( QString value, QString pattern );
212 
225  double calcSlantedArea(QString objId, double angleMin = 0.0, double angleMax = 45.0);
226 
259  QVariantMap calcGpsCoordsByStation( QString objId, double station );
260 
283  QVariantMap calcGpsCoordsByModelCoords( double x, double y );
284 
305  QVariantMap calcModelCoordsByGpsCoords( double lat, double lon );
306 
333  QVariantMap calcGkCoordsByModelCoords( double x, double y, double z );
334 
339  QVariantMap calcModelCoordsByGkCoords( double r, double h );
340 
362  QVariantMap calcGkCoordsByGpsCoords( double lat, double lon );
363 
386  QVariantMap calcGpsCoordsByGkCoords( double rw, double hw );
387 
392  QString idListToStr( QStringList idList );
393 
398  QStringList strToIdList( QString strIDList );
399 
400 
402 #pragma endregion
403 
404 
405 #pragma region TOOLS - FILES
406 
421  QVariantMap getFileInfo( QString filePath );
422 
430  QString getAbsolutePath( QString filePath ) { return QFileInfo(filePath).absolutePath(); }
431 
440  QString getBaseName( QString filePath ) { return QFileInfo(filePath).baseName(); }
441 
449  QString getFileName( QString filePath ) { return QFileInfo(filePath).fileName(); }
450 
451 
452 
453 
454  /*
455  test of caching a parsed json file
456  */
457 #ifdef ENABLE_READJSON
458  QVariantMap readJsonFromTextFile( QString filename, bool useCache = true, QString codec = QString() );
459 #endif
460 #pragma endregion
462 
463 
464 #pragma region APPLICATION
465 
470  QString getApplicationDirectory();
471 
476  QString getApplicationFilename();
477 
482  virtual QString getApplicationLanguage();
483 
489  QString getVersionAsString();
490 
501  int getVersionMAJOR();
502 
513  int getVersionMINOR();
514 
525  int getVersionBUILD();
526 
537  QVariantMap getVersion();
538 
544  bool requireVersion( int major, int minor, int patch );
545 
546 
548 #pragma endregion
549 
550 
551 #pragma region PROJECT
552 
557  QString getUserName();
558 
562  QString getProjectID();
563 
568  int getProjectVariantNumber();
569 
579  int getProjectVersionNumber();
580 
585  QString getProjectNumber();
586 
590  int setProjectNumber(QString s, bool overwriteExisting = false);
591 
595  QString getProjectName();
596 
600  QString getProjectShortDescription();
601 
605  int setProjectShortDescription(QString s, bool overwriteExisting = false);
606 
610  QString getProjectLongDescription();
611 
615  int setProjectLongDescription(QString s, bool overwriteExisting = false);
616 
620  QString getProjectDirectory();
621 
622 
641  QString getLocation();
642 
643 
655  QVariantMap getProjectLocation() const;
656 
670  QVariantMap getCloudSettings();
671 
697  QVariantMap getProjectInfo();
698 
700 #pragma endregion
701 
702 
703 #pragma region DOMAINS
704 
731  QString getDomainByElement( QString objId );
732 
734 #pragma endregion
735 
736 
737 #pragma region PROPERTIES
738 
773  QVariant getPropertyValue(QString objId, QString propName, QString propType, bool inh = true ); // , bool evaluate = true, bool formatAsString = false );
774 
822  QList<QVariant> getPropertyValuesByObject( QString objId, QString filterpattern = "*" );
823 
829  QVariant getPropertySource( QString objId, QString propName, QString propType, bool inh = true );
830 
831 
842  QString getPropertyUnit(QString objId, QString propName, QString propType, bool inh = true );
843 
844 
849  QString getPropertyUnit( QString propName, QString propType );
850 
871  QVariant getPropertyValueByDate(QString objId, QString propName, QString propType, bool inh = true );
872 
891  QDateTime getPropertyLastDate(QString objId, QString propName, QString propType, bool inh = true );
892 
908  QDateTime getPropertyFirstDate(QString objId, QString propName, QString propType, bool inh /* = true */ );
909 
976  QVariantMap getPropertyDateListAsJSON( QString objId, QString propName, QString propType, bool inh = true );
977 
1013  QVariantList getPropertyDateList(QString objectId, QString propertyBaseName, QString propertyType );
1014 
1050  QVariantMap getPropertyTypesByObject( QString objId, QString filterPattern = "*" );
1051 
1052 
1086  QVariantMap getPropertyTypesByDomain( QString domainName, QString filterPattern = "*" );
1087 
1088 
1112  QVariantMap getPropertyTypeMetaData( QString propName, QString propType );
1113 
1114 
1149  QList<QVariant> getPropertyTypeList( QString domain = "all", QString filterPattern = "*", bool activeOnly = false );
1150 
1151 
1190  QList<QVariant> getPropertyTypeListByObject( QString objId, QString filterPattern = "*" );
1191 
1192 
1198  bool isPropertyInherited(QString objId, QString propName, QString propType );
1199 
1200 
1210  QString getPropertyValueRange(QString idList, QString propName, QString propType, QString domainFilter = "geometry" );
1211 
1212 
1223  QStringList getPropertyValueList( QString propName, QString propType, int maxValues );
1224 
1225 
1237  QString getPropertyValueAsString(QString objId, QString propName, QString propType, bool inh = true );
1238 
1239 
1278  QVariant evaluateFormula( QString code, QString id, QString id_otherdomain = QString() );
1279 
1280 
1293  QString prepareJsCode( QString code, QString id, int dec = -1, QString frmt = "%L1", int fieldWidth = 10, QChar fillChar = QChar() );
1294 
1314  QStringList extractPropertyNames( const QString& code, const QString& startTag = "[[", const QString& endTag = "]]" );
1315 
1317 #pragma endregion
1318 
1319 
1320 #pragma region LINKS BETWEEN OBJECTS
1321 
1363  QStringList getLinkedObjects(QString objectIDList, QString resultDomains = "all", QString objectLookupDomains = "all");
1364 
1365 
1379  QStringList getTasksByObjectList(QString idList);
1380 
1390  QStringList getObjectsByTaskList(QString idList);
1391 
1392 
1402  QStringList getDocumentsByObjectList(QString idList);
1403 
1413  QStringList getObjectsByDocumentList(QString idList);
1414 
1415 
1425  QStringList getSectionsByObjectList(QString idList);
1426 
1436  QStringList getObjectsBySectionList(QString idList);
1437 
1438 
1448  QStringList getTypesByObjectList(QString idList);
1449 
1460  QStringList getObjectsByTypeList(QString idList);
1461 
1462 
1472  QStringList getResourcesByObjectList(QString idList);
1473 
1483  QStringList getObjectsByResourcesList(QString idList);
1484 
1485 
1493  QStringList getBoQItemsByObjectList(QString idList);
1494 
1501  QStringList getObjectsByBoQItemList(QString idList);
1502 
1503 
1512  QStringList getPcItemsByObjectList(QString idList);
1513 
1522  QStringList getObjectsByPcItemList(QString idList);
1523 
1525 #pragma endregion
1526 
1527 
1528 #pragma region OBJECT HIERARCHY
1529 
1544  QStringList getContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1545 
1557  int countContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1558 
1565  QString getParent(QString objId);
1566 
1576  QStringList getOpenings(QString objId);
1577 
1587  QStringList getParts(QString objId);
1588 
1590 #pragma endregion
1591 
1592 
1593 #pragma region STATUS
1594 
1603  bool isVisible(QString objId);
1604 
1609  bool isSelected(QString objId);
1610 
1615  bool isLocked(QString objId);
1616 
1621  bool isWired(QString objId);
1622 
1624 #pragma endregion
1625 
1626 
1627 #pragma region GEOMETRY
1628 
1644  QVariantList getPointList( QString objId );
1645 
1647 #pragma endregion
1648 
1649 
1650 #pragma region ALIGNMENTS / REGIONS
1651 
1671  QVariantMap getPointOnAlignmentAtStation( QString objId, double d );
1672 
1689  double getStationOfProjectedPoint( QString objId, double x, double y, double z = 0.0 );
1690 
1701  QStringList getRegionsOfAlignment( QString alignmentId );
1702 
1714  QVariantList getRangesOfRegion( QString alignmentID, QString regionID );
1715 
1716 
1728  double getValueOfAlignmentRegion( QString alignmentID, QString regionID );
1729 
1730 
1732 #pragma endregion
1733 
1734 
1735 #pragma region ACTIVITIES
1736 
1746  int getTaskMode( QString taskId );
1747 
1754  QString getTaskVisualisation( QString taskId );
1755 
1757 #pragma endregion
1758 
1759 #pragma region LINKRULES
1760 
1770  int updateRuleBasedLinks(QString domainName, bool visibleOnly = false);
1771 
1779  int removeRuleBasedLinks(QString domainName);
1780 
1782 #pragma endregion
1783 
1786  protected:
1787 
1788  /*
1789  Get object, looks up also containers in project
1790  */
1791  model::IContainerObject* getIContainerObject(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1792  model::IContainer* getIContainer(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1793  model::Element* getElement(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1794 
1795  model::IProperty* _getProperty( QString objId, QString propName, QString propType, bool inh );
1796  QVariant _getPropertyValue( const QString& objId, const QString& propName, const QString& propType, bool inh, bool evaluate, bool formatAsString );
1797 
1798  /*
1799  Collect geometric elements and composite elements.
1800  */
1801  void collectGeoObjects( const QString& idList, QList<model::IObject*>& list );
1802 
1803 
1804  private:
1805 
1806  QList<QDateTime> _getPropertyDateList(const QString& objId, const QString& propBaseName, const QString& propType, const QTime& defaultTime );
1807 
1808 
1809  CoreAPI(QObject* parent = 0);
1810 
1811  BimProject* _bimProject;
1812 
1815 #ifdef ENABLE_READJSON
1816  bool _firsttime;
1817  QVariantMap _fileCache;
1818 #endif
1819 
1820  };
1821 
1822 }
Definition: CoreAPI.h:32
Definition: CoreAPI.h:27
QString getBaseName(QString filePath)
Definition: CoreAPI.h:440
QString getFileName(QString filePath)
Definition: CoreAPI.h:449
Definition: CoreAPI.h:53
QString format(double v, int dec=2, QString frmt="%L1", int fieldWidth=10, QChar fillChar=QChar::Nbsp)
Definition: CoreAPI.h:125
QString getAbsolutePath(QString filePath)
Definition: CoreAPI.h:430

Created: Fri Feb 5 2021 09:33:06