Skip to content

Commit

Permalink
Activate only UI tree leaf as to display properly colors when browsin…
Browse files Browse the repository at this point in the history
…g a STEP (there is currently a limitation within the reader which creates compound which are totally grey) and accelerate browsing by de-activating Compound rendering
  • Loading branch information
Jean-Marie Verdun authored and wwmayer committed Jan 30, 2017
1 parent bcea759 commit fc4a1c6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Mod/Import/App/ImportOCAF.cpp
Expand Up @@ -75,6 +75,9 @@
#include <Mod/Part/App/ImportIges.h>
#include <Mod/Part/App/ImportStep.h>

#include <App/DocumentObject.h>
#include <App/DocumentObjectGroup.h>

#ifdef HAVE_TBB
#include <tbb/parallel_for.h>
#include <tbb/blocked_range.h>
Expand Down Expand Up @@ -214,6 +217,7 @@ void ImportOCAF::loadShapes(const TDF_Label& label, const TopLoc_Location& loc,
if (pcCompound) {
pcCompound->Links.setValues(localValue);
lValue.push_back(pcCompound);
Node_Shapes.push_back(pcCompound->getNameInDocument());
}
}
}
Expand Down Expand Up @@ -244,6 +248,7 @@ void ImportOCAF::createShape(const TDF_Label& label, const TopLoc_Location& loc,

pcCompound->Links.setValues(localValue);
lValue.push_back(pcCompound);
Node_Shapes.push_back(pcCompound->getNameInDocument());
if (ctSolids > 0 || ctShells > 0)
return;
}
Expand All @@ -260,6 +265,7 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location&
else
part->Shape.setValue(aShape);
part->Label.setValue(name);
Leaf_Shapes.push_back(part->getNameInDocument());
lvalue.push_back(part);

Quantity_Color aColor;
Expand Down
10 changes: 10 additions & 0 deletions src/Mod/Import/App/ImportOCAF.h
Expand Up @@ -57,6 +57,12 @@ class ImportExport ImportOCAF
ImportOCAF(Handle_TDocStd_Document h, App::Document* d, const std::string& name);
virtual ~ImportOCAF();
void loadShapes();
std::vector<const char *> return_leaf() const {
return Leaf_Shapes;
}
std::vector<const char *> return_node() const {
return Node_Shapes;
}

private:
void loadShapes(const TDF_Label& label, const TopLoc_Location&, const std::string& partname, const std::string& assembly, bool isRef, std::vector<App::DocumentObject*> &);
Expand All @@ -72,6 +78,10 @@ class ImportExport ImportOCAF
std::string default_name;
std::set<int> myRefShapes;
static const int HashUpper = INT_MAX;
// These variables are used to transfer Shape names to the UI backend and decide
// to activate / deactivate the right members for performance improvements
std::vector<const char *> Leaf_Shapes;
std::vector<const char *> Node_Shapes;
};

class ImportExport ExportOCAF
Expand Down
14 changes: 14 additions & 0 deletions src/Mod/Import/Gui/AppImportGuiPy.cpp
Expand Up @@ -112,6 +112,10 @@
#include <QHBoxLayout>
#include <QVBoxLayout>

#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/ViewProvider.h>

class OCAFBrowser
{
public:
Expand Down Expand Up @@ -403,6 +407,16 @@ class Module : public Py::ExtensionModule<Module>

ImportOCAFExt ocaf(hDoc, pcDoc, file.fileNamePure());
ocaf.loadShapes();

// Shape are loaded we must now sort the one we want to display and the one we do want to hide
Gui::Document *guiDoc = Gui::Application::Instance->activeDocument();
std::vector<const char *>keep_leaf= ocaf.return_leaf();
for (std::vector<const char *>::iterator it = keep_leaf.begin() ; it != keep_leaf.end(); ++it)
guiDoc->setShow((*it));
std::vector<const char *>hide_node= ocaf.return_node();
for (std::vector<const char *>::iterator it = hide_node.begin() ; it != hide_node.end(); ++it)
guiDoc->setHide((*it));

pcDoc->recompute();
}
catch (Standard_Failure) {
Expand Down

0 comments on commit fc4a1c6

Please sign in to comment.