MainPage   Related pages 
CoreAPI.h
1 
2 //
3 // $Id: CoreAPI.h 4371 2021-01-13 16:31:26Z eleni.kikidi $
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 
163  QString formatDateTime( QDateTime dt, QString formatstr = "iso" );
164 
169  QString createID();
170 
175  long calcHashcode( QString str );
176 
195  QString compressToIfcGuid(QString id);
196 
203  QString uncompressFromIfcGuid(QString ifcGuid);
204 
223  bool checkRegExp( QString value, QString pattern );
224 
237  double calcSlantedArea(QString objId, double angleMin = 0.0, double angleMax = 45.0);
238 
271  QVariantMap calcGpsCoordsByStation( QString objId, double station );
272 
295  QVariantMap calcGpsCoordsByModelCoords( double x, double y );
296 
317  QVariantMap calcModelCoordsByGpsCoords( double lat, double lon );
318 
345  QVariantMap calcGkCoordsByModelCoords( double x, double y, double z );
346 
351  QVariantMap calcModelCoordsByGkCoords( double r, double h );
352 
374  QVariantMap calcGkCoordsByGpsCoords( double lat, double lon );
375 
398  QVariantMap calcGpsCoordsByGkCoords( double rw, double hw );
399 
404  QString idListToStr( QStringList idList );
405 
410  QStringList strToIdList( QString strIDList );
411 
412 
414 #pragma endregion
415 
416 
417 #pragma region TOOLS - FILES
418 
433  QVariantMap getFileInfo( QString filePath );
434 
442  QString getAbsolutePath( QString filePath ) { return QFileInfo(filePath).absolutePath(); }
443 
452  QString getBaseName( QString filePath ) { return QFileInfo(filePath).baseName(); }
453 
461  QString getFileName( QString filePath ) { return QFileInfo(filePath).fileName(); }
462 
463 
464 
465 
466  /*
467  test of caching a parsed json file
468  */
469 #ifdef ENABLE_READJSON
470  QVariantMap readJsonFromTextFile( QString filename, bool useCache = true, QString codec = QString() );
471 #endif
472 #pragma endregion
474 
475 
476 #pragma region APPLICATION
477 
482  QString getApplicationDirectory();
483 
488  QString getApplicationFilename();
489 
494  virtual QString getApplicationLanguage();
495 
501  QString getVersionAsString();
502 
513  int getVersionMAJOR();
514 
525  int getVersionMINOR();
526 
537  int getVersionBUILD();
538 
549  QVariantMap getVersion();
550 
556  bool requireVersion( int major, int minor, int patch );
557 
558 
560 #pragma endregion
561 
562 
563 #pragma region PROJECT
564 
569  QString getUserName();
570 
574  QString getProjectID();
575 
580  int getProjectVariantNumber();
581 
591  int getProjectVersionNumber();
592 
597  QString getProjectNumber();
598 
602  int setProjectNumber(QString s, bool overwriteExisting = false);
603 
607  QString getProjectName();
608 
612  QString getProjectShortDescription();
613 
617  int setProjectShortDescription(QString s, bool overwriteExisting = false);
618 
622  QString getProjectLongDescription();
623 
627  int setProjectLongDescription(QString s, bool overwriteExisting = false);
628 
632  QString getProjectDirectory();
633 
634 
653  QString getLocation();
654 
655 
667  QVariantMap getProjectLocation() const;
668 
682  QVariantMap getCloudSettings();
683 
709  QVariantMap getProjectInfo();
710 
712 #pragma endregion
713 
714 
715 #pragma region DOMAINS
716 
743  QString getDomainByElement( QString objId );
744 
746 #pragma endregion
747 
748 
749 #pragma region PROPERTIES
750 
790  QVariant getPropertyValue(QString objId, QString propName, QString propType, bool inh = true ); // , bool evaluate = true, bool formatAsString = false );
791 
839  QList<QVariant> getPropertyValuesByObject( QString objId, QString filterpattern = "*" );
840 
846  QVariant getPropertySource( QString objId, QString propName, QString propType, bool inh = true );
847 
848 
859  QString getPropertyUnit(QString objId, QString propName, QString propType, bool inh = true );
860 
861 
866  QString getPropertyUnit( QString propName, QString propType );
867 
888  QVariant getPropertyValueByDate(QString objId, QString propName, QString propType, bool inh = true );
889 
908  QDateTime getPropertyLastDate(QString objId, QString propName, QString propType, bool inh = true );
909 
925  QDateTime getPropertyFirstDate(QString objId, QString propName, QString propType, bool inh /* = true */ );
926 
993  QVariantMap getPropertyDateListAsJSON( QString objId, QString propName, QString propType, bool inh = true );
994 
1030  QVariantList getPropertyDateList(QString objectId, QString propertyBaseName, QString propertyType );
1031 
1067  QVariantMap getPropertyTypesByObject( QString objId, QString filterPattern = "*" );
1068 
1069 
1103  QVariantMap getPropertyTypesByDomain( QString domainName, QString filterPattern = "*" );
1104 
1105 
1129  QVariantMap getPropertyTypeMetaData( QString propName, QString propType );
1130 
1131 
1166  QList<QVariant> getPropertyTypeList( QString domain = "all", QString filterPattern = "*", bool activeOnly = false );
1167 
1168 
1207  QList<QVariant> getPropertyTypeListByObject( QString objId, QString filterPattern = "*" );
1208 
1209 
1215  bool isPropertyInherited(QString objId, QString propName, QString propType );
1216 
1217 
1227  QString getPropertyValueRange(QString idList, QString propName, QString propType, QString domainFilter = "geometry" );
1228 
1229 
1240  QStringList getPropertyValueList( QString propName, QString propType, int maxValues );
1241 
1242 
1254  QString getPropertyValueAsString(QString objId, QString propName, QString propType, bool inh = true );
1255 
1256 
1295  QVariant evaluateFormula( QString code, QString id, QString id_otherdomain = QString() );
1296 
1297 
1310  QString prepareJsCode( QString code, QString id, int dec = -1, QString frmt = "%L1", int fieldWidth = 10, QChar fillChar = QChar() );
1311 
1331  QStringList extractPropertyNames( const QString& code, const QString& startTag = "[[", const QString& endTag = "]]" );
1332 
1334 #pragma endregion
1335 
1336 
1337 #pragma region LINKS BETWEEN OBJECTS
1338 
1380  QStringList getLinkedObjects(QString objectIDList, QString resultDomains = "all", QString objectLookupDomains = "all");
1381 
1382 
1396  QStringList getTasksByObjectList(QString idList);
1397 
1407  QStringList getObjectsByTaskList(QString idList);
1408 
1409 
1419  QStringList getDocumentsByObjectList(QString idList);
1420 
1430  QStringList getObjectsByDocumentList(QString idList);
1431 
1432 
1442  QStringList getSectionsByObjectList(QString idList);
1443 
1453  QStringList getObjectsBySectionList(QString idList);
1454 
1455 
1465  QStringList getTypesByObjectList(QString idList);
1466 
1477  QStringList getObjectsByTypeList(QString idList);
1478 
1479 
1489  QStringList getResourcesByObjectList(QString idList);
1490 
1500  QStringList getObjectsByResourcesList(QString idList);
1501 
1502 
1510  QStringList getBoQItemsByObjectList(QString idList);
1511 
1518  QStringList getObjectsByBoQItemList(QString idList);
1519 
1520 
1529  QStringList getPcItemsByObjectList(QString idList);
1530 
1539  QStringList getObjectsByPcItemList(QString idList);
1540 
1542 #pragma endregion
1543 
1544 
1545 #pragma region OBJECT HIERARCHY
1546 
1561  QStringList getContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1562 
1574  int countContainedElements(QString containerId, int maxDepth, bool loadExternal = true);
1575 
1582  QString getParent(QString objId);
1583 
1593  QStringList getOpenings(QString objId);
1594 
1604  QStringList getParts(QString objId);
1605 
1607 #pragma endregion
1608 
1609 
1610 #pragma region STATUS
1611 
1620  bool isVisible(QString objId);
1621 
1626  bool isSelected(QString objId);
1627 
1632  bool isLocked(QString objId);
1633 
1638  bool isWired(QString objId);
1639 
1641 #pragma endregion
1642 
1643 
1644 #pragma region GEOMETRY
1645 
1661  QVariantList getPointList( QString objId );
1662 
1664 #pragma endregion
1665 
1666 
1667 #pragma region ALIGNMENTS / REGIONS
1668 
1688  QVariantMap getPointOnAlignmentAtStation( QString objId, double d );
1689 
1706  double getStationOfProjectedPoint( QString objId, double x, double y, double z = 0.0 );
1707 
1718  QStringList getRegionsOfAlignment( QString alignmentId );
1719 
1731  QVariantList getRangesOfRegion( QString alignmentID, QString regionID );
1732 
1733 
1745  double getValueOfAlignmentRegion( QString alignmentID, QString regionID );
1746 
1747 
1749 #pragma endregion
1750 
1751 
1752 #pragma region ACTIVITIES
1753 
1763  int getTaskMode( QString taskId );
1764 
1771  QString getTaskVisualisation( QString taskId );
1772 
1774 #pragma endregion
1775 
1776 #pragma region LINKRULES
1777 
1787  int updateRuleBasedLinks(QString domainName, bool visibleOnly = false);
1788 
1796  int removeRuleBasedLinks(QString domainName);
1797 
1799 #pragma endregion
1800 
1803  protected:
1804 
1805  /*
1806  Get object, looks up also containers in project
1807  */
1808  model::IContainerObject* getIContainerObject(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1809  model::IContainer* getIContainer(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1810  model::Element* getElement(const QString& id, model::eDomainType domainFilter = model::typeDomainAll );
1811 
1812  model::IProperty* _getProperty( QString objId, QString propName, QString propType, bool inh );
1813  QVariant _getPropertyValue( const QString& objId, const QString& propName, const QString& propType, bool inh, bool evaluate, bool formatAsString );
1814 
1815  /*
1816  Collect geometric elements and composite elements.
1817  */
1818  void collectGeoObjects( const QString& idList, QList<model::IObject*>& list );
1819 
1820 
1821  private:
1822 
1823  QList<QDateTime> _getPropertyDateList(const QString& objId, const QString& propBaseName, const QString& propType, const QTime& defaultTime );
1824 
1825 
1826  CoreAPI(QObject* parent = 0);
1827 
1828  BimProject* _bimProject;
1829 
1832 #ifdef ENABLE_READJSON
1833  bool _firsttime;
1834  QVariantMap _fileCache;
1835 #endif
1836 
1837  };
1838 
1839 }
Definition: CoreAPI.h:32
Definition: CoreAPI.h:27
QString getBaseName(QString filePath)
Definition: CoreAPI.h:452
QString getFileName(QString filePath)
Definition: CoreAPI.h:461
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:442

Created: Wed May 5 2021 15:16:11