visualization/qtquick_qml/pmiviewer/main.cxx

Refer to PMI Viewer Example

PMIViewerApplication.hxx

// ****************************************************************************
// $Id$
//
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include "../baseviewer/BaseViewerApplication.hxx"
class PMIViewerApplication : public BaseViewerApplication
{
Q_OBJECT
public:
PMIViewerApplication();
void CreateSceneNodes() override;
};

PMIViewerApplication.cxx

// ****************************************************************************
// $Id$
//
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include "PMIViewerApplication.hxx"
#include <deque>
#include <iostream>
namespace {
class ModelVisitor : public ModelData_Model::CombinedElementVisitor
{
public:
ModelVisitor (const ModelPrs_SceneNode& theRoot, const ModelPrs_SceneNodeFactory& theFactory) :
myFactory (theFactory)
{
myNodes.push_back (theRoot);
}
void VisitLeave (const ModelData_SceneGraphElement& /*theSGE*/) override
{
myNodes.pop_back();
}
bool VisitEnter (const ModelData_SceneGraphElement& theSGE) override
{
auto anSGENode = myFactory.CreateNode (theSGE);
myNodes.push_back (anSGENode);
return true;
}
void operator() (const ModelData_Part& thePart) override
{
auto aPartNode = myFactory.CreateNode (thePart);
auto aRep = thePart.BRepRepresentation();
auto aRepNode = myFactory.CreateNode (aRep);
}
{
ModelData_Appearance anAppearance (ModelData_Color (0.0f, 0.0f, 0.0f, 1.0f));
ModelPrs_SceneNode aPMIRootNode;
aPMIRootNode.SetAppearance (anAppearance);
for (ModelData_PMITable::PMIDataIterator anIt (theSGE.PMI()); anIt.HasNext();) {
auto anElement = anIt.Next();
if (anElement) {
auto aPMINode = myFactory.CreateNode (anElement.GraphicalElement());
}
}
}
private:
std::deque<ModelPrs_SceneNode> myNodes;
};
} // end of unnamed namespace
PMIViewerApplication::PMIViewerApplication()
{
}
void PMIViewerApplication::CreateSceneNodes()
{
ModelVisitor aVisitor (myRoot, aFactory);
myModel.Accept (aVisitor);
}

main.cxx

// ****************************************************************************
// $Id$
//
//
// This file is part of the CAD Exchanger software.
//
// You may use this file under the terms of the BSD license as follows:
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
// ****************************************************************************
#include "PMIViewerApplication.hxx"
#include <QtCore/QUrl>
#include <QtWidgets/QApplication>
int main (int argc, char *argv[])
{
return 1;
}
// Must set dpi scaling before creating an application.
QCoreApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
// Create QApplication because Qt.labs.platform module requires Qt Widgets library.
QApplication app (argc, argv);
PMIViewerApplication anApp;
if (anApp.Initialize (QUrl ("qrc:/qml/BaseViewerWindow.qml"), "viewPort")) {
return app.exec();
}
return 0;
}
Base class for part, instance and assembly.
Definition: ModelData_SceneGraphElement.hxx:36
Iterator over added PMIData items, which contains graphical and semantical elements.
Definition: ModelData_PMITable.hxx:80
ModelData_PMITable PMI() const
Returns a PMI table.
Definition: ModelData_SceneGraphElement.cxx:233
Defines an RGBA color (with alpha channel).
Definition: ModelData_Color.hxx:33
void SetAppearance(const ModelData_Appearance &theAppearance)
Definition: ModelPrs_SceneNode.cxx:913
Provides an interface to appearance which is a collection of visual styles.
Definition: ModelData_Appearance.hxx:38
Adds theNode to children. Returns false if the node already has a parent, otherwise returns true.
Definition: ModelPrs_SceneNode.cxx:806
Represents a node in the visual scene graph.
Definition: ModelPrs_SceneNode.hxx:43
Defines classes, types, and global functions related to CAD Exchanger.
Definition: A3DSTestLib.hxx:22
Creates a scene nodes and its children from input data model objects.
Definition: ModelPrs_SceneNodeFactory.hxx:47
Provides combined methods VisitEnter() and VisitLeave() to visit all elements.
Definition: ModelData_Model.hxx:116
ModelData_BRepRepresentation BRepRepresentation() const
Definition: ModelData_Part.cxx:343
Defines a leaf node in the scene graph hiearchy.
Definition: ModelData_Part.hxx:34