Refer to PMI Viewer Example
PMIViewerApplication.hxx
#ifndef __PMIViewerApplication_HeaderFile
#define __PMIViewerApplication_HeaderFile
#include "../baseviewer/BaseViewerApplication.hxx"
class PMIViewerApplication : public BaseViewerApplication
{
Q_OBJECT
public:
PMIViewerApplication();
void CreateSceneNodes() override;
};
#endif // __PMIViewerApplication_HeaderFile
PMIViewerApplication.cxx
#define __CADEX_PREVIEW_PMI 1
#include "PMIViewerApplication.hxx"
#include <cadex/ModelData_Appearance.hxx>
#include <cadex/ModelData_Color.hxx>
#include <cadex/ModelData_Instance.hxx>
#include <cadex/ModelData_PMIData.hxx>
#include <cadex/ModelData_PMIGraphicalElement.hxx>
#include <cadex/ModelData_PMITable.hxx>
#include <cadex/ModelPrs_SceneNodeFactory.hxx>
#include <deque>
#include <iostream>
namespace {
{
public:
myFactory (theFactory)
{
myNodes.push_back (theRoot);
}
{
myNodes.pop_back();
}
{
auto anSGENode = myFactory.CreateNode (theSGE);
myNodes.back().AddChildNode (anSGENode);
myNodes.push_back (anSGENode);
AddPMINodes (theSGE);
return true;
}
{
auto aPartNode = myFactory.CreateNode (thePart);
myNodes.back().AddChildNode (aPartNode);
AddPMINodes (thePart);
auto aRepNode = myFactory.CreateNode (aRep);
aPartNode.AddChildNode (aRepNode);
}
{
auto anElement = anIt.Next();
if (anElement) {
auto aPMINode = myFactory.CreateNode (anElement.GraphicalElement());
}
}
myNodes.back().AddChildNode (aPMIRootNode);
}
private:
std::deque<ModelPrs_SceneNode> myNodes;
};
}
PMIViewerApplication::PMIViewerApplication()
{
myReaderParameters.ReadPMI() = true;
}
void PMIViewerApplication::CreateSceneNodes()
{
ModelVisitor aVisitor (myRoot, aFactory);
myModel.Accept (aVisitor);
}
main.cxx
#include "PMIViewerApplication.hxx"
#include <cadex/LicenseManager_Activate.h>
#include <QtCore/QUrl>
#include <QtWidgets/QApplication>
#include "../../../cadex_license.cxx"
int main (int argc, char *argv[])
{
auto aKey = LicenseKey::Value();
if (!CADExLicense_Activate (aKey)) {
qCritical ("Failed to activate CAD Exchanger license.");
return 1;
}
QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
QApplication app (argc, argv);
PMIViewerApplication anApp;
if (anApp.Initialize (QUrl ("qrc:/qml/BaseViewerWindow.qml"), "viewPort")) {
return app.exec();
}
return 0;
}