From e3e6c75094bbaae5e1f82c16a717341cdd070d41 Mon Sep 17 00:00:00 2001 From: Haocheng Liu Date: Fri, 7 Apr 2017 19:03:06 -0400 Subject: [PATCH 1/2] Add assign color to ENTITY_LIST feature Add logic in processModifiedEntities function to check ENTITY_LIST color stored on model. SMTK side commit b36a4ee9f238ba2eb988a87d07d920a999cc91cf. --- .../pqCMBModelBuilderMainWindowCore.cxx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx index e9749d6a..1e695cc4 100644 --- a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx +++ b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx @@ -84,8 +84,10 @@ #include "smtk/attribute/IntItem.h" #include "smtk/model/AuxiliaryGeometry.h" #include "smtk/model/Face.h" +#include "smtk/model/FloatData.h" #include "smtk/model/Group.h" #include "smtk/model/Tessellation.h" +#include "smtk/model/Entity.h" #include "smtk/model/EntityRef.h" #include "smtk/model/Volume.h" #include "smtk/model/Operator.h" @@ -1150,7 +1152,27 @@ void pqCMBModelBuilderMainWindowCore::processModifiedEntities( curRef.hasIntegerProperty("block_index")) // a geometric entity && (minfo = this->Internal->smtkModelManager->modelInfo(curRef))) { - pqCMBContextMenuHelper::getValidEntityColor(color, curRef); + smtk::model::FloatList rgba = curRef.color(); + if ((rgba.size() == 4) && (rgba[3] < 0 || rgba[3] > 1)) + { + // invalid color. Maybe the color is assigned by ENTITY_LIST, check model + if (curRef.owningModel().isValid()) + { + smtk::model::Model model = curRef.owningModel(); + std::string colorName; + colorName = smtk::model::Entity::flagSummary(curRef.entityFlags()); + colorName += " color"; + if (model.hasFloatProperty(colorName)) + { + smtk::model::FloatList colorList = model.floatProperty(colorName); + color.setRgbF(colorList[0], colorList[1], colorList[2], colorList[3]); + } + } + } + else + { + pqCMBContextMenuHelper::getValidEntityColor(color, curRef); + } // this could also be removing colors already being set, // so if even the color is invalid, we still record it colorEntities[minfo].insert(curRef, color); -- GitLab From ae02f6210176b3568fd4abae4204f000a54747c9 Mon Sep 17 00:00:00 2001 From: Haocheng Liu Date: Fri, 7 Apr 2017 19:22:26 -0400 Subject: [PATCH 2/2] Fix logic error for entity color render and deprecate EntityColorTable This MR updates the valid color logic in pqCMBContextMenuHelper to support color by ENTITY_LIST and make Color by combobox default to "Entity". Several logic errors are fixed and now blockIndex would be handled properly. --- CMakeLists.txt.user | 1271 +++++++++++++++++ .../ModelBuilder/pqCMBContextMenuHelper.cxx | 30 +- .../pqCMBModelBuilderMainWindow.cxx | 1 + .../pqCMBModelBuilderMainWindowCore.cxx | 39 +- .../pqCMBModelBuilderMainWindowCore.h | 5 + .../pqModelBuilderViewContextMenuBehavior.cxx | 48 +- .../ModelBuilder/pqSMTKModelInfo.cxx | 2 +- 7 files changed, 1335 insertions(+), 61 deletions(-) create mode 100644 CMakeLists.txt.user diff --git a/CMakeLists.txt.user b/CMakeLists.txt.user new file mode 100644 index 00000000..baf6e6fb --- /dev/null +++ b/CMakeLists.txt.user @@ -0,0 +1,1271 @@ + + + + + + EnvironmentId + {a0c2bcb0-82d3-4b3f-8ec7-f550f54c16dc} + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + true + false + true + + Cpp + + CppGlobal + + + + QmlJS + + QmlJSGlobal + + + 2 + UTF-8 + false + 4 + false + 80 + true + true + 1 + true + false + 0 + true + true + 0 + 8 + true + 1 + true + true + true + false + + + + ProjectExplorer.Project.PluginSettings + + + + ProjectExplorer.Project.Target.0 + + Desktop Qt 5.7.1 GCC 64bit + Desktop Qt 5.7.1 GCC 64bit + qt.57.gcc_64_kit + 0 + 0 + 10 + + + CMAKE_CXX_COMPILER:FILEPATH=/usr/bin/c++ + QT_QMAKE_EXECUTABLE:FILEPATH=/home/haochengliu/Kitware/CMB/buildAll2/install/bin/qmake + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build + + + + + all + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + + + all + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Default + Default + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Debug + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build-src-Desktop_Qt_5_7_1_GCC_64bit-Debug + + + + + + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=Release + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build-src-Desktop_Qt_5_7_1_GCC_64bit-Release + + + + + + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=RelWithDebInfo + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build-src-Desktop_Qt_5_7_1_GCC_64bit-Release with Debug Information + + + + + + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release with Debug Information + Release with Debug Information + CMakeProjectManager.CMakeBuildConfiguration + + + + CMAKE_BUILD_TYPE:STRING=MinSizeRel + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build-src-Desktop_Qt_5_7_1_GCC_64bit-Minimum Size Release + + + + + + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Build + + ProjectExplorer.BuildSteps.Build + + + + + + clean + + true + Make + + CMakeProjectManager.MakeStep + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Minimum Size Release + Minimum Size Release + CMakeProjectManager.CMakeBuildConfiguration + + 5 + + + 0 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy locally + + ProjectExplorer.DefaultDeployConfiguration + + 1 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + meshingReader + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + 2 + + meshingReader + + CMakeProjectManager.CMakeRunConfiguration.meshingReader + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + testMedialAxisFilter + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + testMedialAxisFilter + + CMakeProjectManager.CMakeRunConfiguration.testMedialAxisFilter + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + ModelBuilder + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + 2 + + ModelBuilder + + CMakeProjectManager.CMakeRunConfiguration.ModelBuilder + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + ModelBuilder-launcher + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + ModelBuilder-launcher + + CMakeProjectManager.CMakeRunConfiguration.ModelBuilder-launcher + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + PointsBuilder + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + PointsBuilder + + CMakeProjectManager.CMakeRunConfiguration.PointsBuilder + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + PointsBuilder-launcher + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + PointsBuilder-launcher + + CMakeProjectManager.CMakeRunConfiguration.PointsBuilder-launcher + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + SceneBuilder + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + SceneBuilder + + CMakeProjectManager.CMakeRunConfiguration.SceneBuilder + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + SceneBuilder-launcher + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + SceneBuilder-launcher + + CMakeProjectManager.CMakeRunConfiguration.SceneBuilder-launcher + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + GrabCuts + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + GrabCuts + + CMakeProjectManager.CMakeRunConfiguration.GrabCuts + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + CmbArcTests + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + CmbArcTests + + CMakeProjectManager.CMakeRunConfiguration.CmbArcTests + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + LIDARConverter + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + LIDARConverter + + CMakeProjectManager.CMakeRunConfiguration.LIDARConverter + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + testDiscreteColorLookupTable + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + testDiscreteColorLookupTable + + CMakeProjectManager.CMakeRunConfiguration.testDiscreteColorLookupTable + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + testVTKObjectMethods + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + testVTKObjectMethods + + CMakeProjectManager.CMakeRunConfiguration.testVTKObjectMethods + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + testDataReader + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + testDataReader + + CMakeProjectManager.CMakeRunConfiguration.testDataReader + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + delosMeshReader + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + delosMeshReader + + CMakeProjectManager.CMakeRunConfiguration.delosMeshReader + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + MeshViewer + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + MeshViewer + + CMakeProjectManager.CMakeRunConfiguration.MeshViewer + 3768 + false + true + false + false + true + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + /usr/bin/valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + MeshViewer-launcher + + + /home/haochengliu/Kitware/CMB/buildAll2/superbuild/cmb/build/bin + -1 + + MeshViewer-launcher + + CMakeProjectManager.CMakeRunConfiguration.MeshViewer-launcher + 3768 + false + true + false + false + true + + 17 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 18 + + + Version + 18 + + diff --git a/Source/Applications/ModelBuilder/pqCMBContextMenuHelper.cxx b/Source/Applications/ModelBuilder/pqCMBContextMenuHelper.cxx index d4214720..bc11935c 100644 --- a/Source/Applications/ModelBuilder/pqCMBContextMenuHelper.cxx +++ b/Source/Applications/ModelBuilder/pqCMBContextMenuHelper.cxx @@ -104,24 +104,38 @@ void pqCMBContextMenuHelper::accumulateChildGeometricEntities( blockIds.insert(bidx); } -// only use valid color, the rest will be colored -// randomly with CTF +// only use valid color, the rest will be colored white bool pqCMBContextMenuHelper::getValidEntityColor(QColor& color, const smtk::model::EntityRef& entref) { smtk::model::FloatList rgba = entref.color(); -if ((rgba.size() == 3 || rgba.size() ==4) && +if ( rgba.size() ==4 && (rgba[0]>=0. && rgba[0]<=1.0 && rgba[1]>=0. && rgba[1]<=1.0 && rgba[2]>=0. && rgba[2]<=1.0 && - rgba[0]+rgba[1]+rgba[2] != 0)) + (rgba[3]>= 0. && rgba[3]<= 1.0))) { - float alpha = rgba.size() == 4 ? std::max(0., std::min(rgba[3], 1.0)) : 1.; - // alpha can't be zero - alpha = alpha == 0. ? 1.0 : alpha; - color.setRgbF(rgba[0], rgba[1], rgba[2], alpha); + color.setRgbF(rgba[0], rgba[1], rgba[2], rgba[3]); return true; } +// if the color is invalid, it might got assigned by ENTITY_LIST. Look up the +// default color from the entity's model properties. +if (entref.owningModel().isValid()) +{ + smtk::model::Model model = entref.owningModel(); + std::string colorName = smtk::model::Entity:: + flagSummary(entref.entityFlags()); + colorName += " color"; + if (model.hasFloatProperty(colorName)) + { + rgba = model.floatProperty(colorName); + float alpha = rgba.size() == 4 ? std::max(0., std::min(rgba[3], 1.0)) : 1.; + // alpha can't be zero + alpha = alpha == 0. ? 1.0 : alpha; + color.setRgbF(rgba[0], rgba[1], rgba[2], alpha); + return true; + } +} return false; } diff --git a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindow.cxx b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindow.cxx index 537efa0e..44833623 100644 --- a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindow.cxx +++ b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindow.cxx @@ -545,6 +545,7 @@ void pqCMBModelBuilderMainWindow::setupToolbars() // this->getMainDialog()->actionEdit_Color_Map); this->getThisCore()->setupColorByAttributeToolbar(colorToolbar); + this->getThisCore()->setupColorByComboBox(colorbyBox); this->addToolBar(Qt::TopToolBarArea, colorToolbar); this->insertToolBarBreak(colorToolbar); diff --git a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx index 1e695cc4..4582c13c 100644 --- a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx +++ b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.cxx @@ -165,6 +165,7 @@ class pqCMBModelBuilderMainWindowCore::vtkInternal QPointer RepresentationWidget; QPointer SelectByBox; QPointer ColorByAttToolbar; + QPointer ColorByComboBox; int SelectByMode; @@ -222,6 +223,12 @@ void pqCMBModelBuilderMainWindowCore::setupColorByAttributeToolbar(QToolBar* too this->Internal->ColorByAttToolbar = toolbar; } +//----------------------------------------------------------------------------- +void pqCMBModelBuilderMainWindowCore::setupColorByComboBox(QComboBox* comboBox) +{ + this->Internal->ColorByComboBox = comboBox; +} + //----------------------------------------------------------------------------- void pqCMBModelBuilderMainWindowCore::setRubberSelectionMode(int mode) { @@ -839,6 +846,11 @@ int pqCMBModelBuilderMainWindowCore::loadModelFile(const QString& filename) succeeded = this->Internal->smtkModelManager->startOperation(fileOp); else qCritical() << "No proper file operator found for: " << filename; + // after load a file, update render view by `color by` combobox value + if (!this->Internal->ColorByComboBox.isNull()) + { + this->onColorByModeChanged(this->Internal->ColorByComboBox->currentText()); + } return succeeded ? 1 : 0; /* if(this->getCMBModel() && @@ -1152,27 +1164,7 @@ void pqCMBModelBuilderMainWindowCore::processModifiedEntities( curRef.hasIntegerProperty("block_index")) // a geometric entity && (minfo = this->Internal->smtkModelManager->modelInfo(curRef))) { - smtk::model::FloatList rgba = curRef.color(); - if ((rgba.size() == 4) && (rgba[3] < 0 || rgba[3] > 1)) - { - // invalid color. Maybe the color is assigned by ENTITY_LIST, check model - if (curRef.owningModel().isValid()) - { - smtk::model::Model model = curRef.owningModel(); - std::string colorName; - colorName = smtk::model::Entity::flagSummary(curRef.entityFlags()); - colorName += " color"; - if (model.hasFloatProperty(colorName)) - { - smtk::model::FloatList colorList = model.floatProperty(colorName); - color.setRgbF(colorList[0], colorList[1], colorList[2], colorList[3]); - } - } - } - else - { - pqCMBContextMenuHelper::getValidEntityColor(color, curRef); - } + pqCMBContextMenuHelper::getValidEntityColor(color, curRef); // this could also be removing colors already being set, // so if even the color is invalid, we still record it colorEntities[minfo].insert(curRef, color); @@ -1232,8 +1224,9 @@ void pqCMBModelBuilderMainWindowCore::processModifiedEntities( { this->Internal->ViewContextBehavior->updateColorForEntities( minfo->Representation, minfo->ColorMode, colorEntities[minfo]); - this->Internal->smtkModelManager->updateEntityColorTable( - minfo->Representation, colorEntities[minfo], minfo->ColorMode); + // EntityColorTable is no longer used to avoid random color + // this->Internal->smtkModelManager->updateEntityColorTable( + // minfo->Representation, colorEntities[minfo], minfo->ColorMode); minfo->Representation->renderViewEventually(); } } diff --git a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.h b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.h index 990e34bf..5e8116e7 100644 --- a/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.h +++ b/Source/Applications/ModelBuilder/pqCMBModelBuilderMainWindowCore.h @@ -26,6 +26,7 @@ class pqCMBSceneTree; class pqCMBModelManager; class pqSMTKModelPanel; class pqSMTKMeshPanel; +class QComboBox; class vtkSMModelManagerProxy; class pqCMBModelBuilderMainWindowCore : public pqCMBCommonMainWindowCore @@ -41,6 +42,10 @@ public: // Setup a representation-selection toolbar void setupColorByAttributeToolbar(QToolBar* parent); + // Description + // Setup a representation-selection comboBox + void setupColorByComboBox(QComboBox* parent); + // Description: // Get flag to determine how selection is performed in display // 0 = Model Faces, 1 = Shells, 2 = Materials diff --git a/Source/Applications/ModelBuilder/pqModelBuilderViewContextMenuBehavior.cxx b/Source/Applications/ModelBuilder/pqModelBuilderViewContextMenuBehavior.cxx index 99523f0c..a7b840ea 100644 --- a/Source/Applications/ModelBuilder/pqModelBuilderViewContextMenuBehavior.cxx +++ b/Source/Applications/ModelBuilder/pqModelBuilderViewContextMenuBehavior.cxx @@ -113,7 +113,7 @@ void pqModelBuilderViewContextMenuBehavior::syncBlockVisibility( { outport->setSelectionInput(0, 0); } - // if all blocks are off, the rep should be invisible + // if all blocks are off, the rep should be invisible if(rep && outport) { vtkSMProxy *proxy = rep->getProxy(); @@ -217,7 +217,9 @@ void pqModelBuilderViewContextMenuBehavior::colorByEntity( std::map::const_iterator uit = modinfo->Info->GetUUID2BlockIdMap().begin(); for(; uit != modinfo->Info->GetUUID2BlockIdMap().end(); ++uit) - indices.append(uit->second + 1); + { + indices.append(uit->second); + } // clear all colors datapanel->clearBlockColor(indices); @@ -251,7 +253,7 @@ void pqModelBuilderViewContextMenuBehavior::colorByEntity( } else if (colorMode == vtkModelMultiBlockSource::GetEntityTagName()) { - // if colorby-entity, get entities' color, + // if colorby-entity, get entities' color, for(uit = modinfo->Info->GetUUID2BlockIdMap().begin(); uit != modinfo->Info->GetUUID2BlockIdMap().end(); ++uit) { @@ -267,8 +269,9 @@ void pqModelBuilderViewContextMenuBehavior::colorByEntity( if(colorEntities.size() > 0) { this->updateColorForEntities(activeRep, colorMode, colorEntities); - this->m_modelPanel->modelManager()->updateEntityColorTable( - activeRep, colorEntities, colorMode); + // EntityColorTable is no longer used to avoid random color + //this->m_modelPanel->modelManager()->updateEntityColorTable( + // activeRep, colorEntities, colorMode); } modinfo->ColorMode = colorMode; } @@ -278,11 +281,11 @@ void pqModelBuilderViewContextMenuBehavior::colorByEntity( std::map::const_iterator mit = meshinfo->Info->GetMesh2BlockIdMap().begin(); for(; mit != meshinfo->Info->GetMesh2BlockIdMap().end(); ++mit) - indices.append(mit->second + 1); + indices.append(mit->second); // clear all colors datapanel->clearBlockColor(indices); - // if colorby-entity, get meshes' color, + // if colorby-entity, get meshes' color, for(mit = meshinfo->Info->GetMesh2BlockIdMap().begin(); mit != meshinfo->Info->GetMesh2BlockIdMap().end(); ++mit) { @@ -303,22 +306,9 @@ void pqModelBuilderViewContextMenuBehavior::colorByEntity( modinfo = meshinfo->ModelInfo; } - // using model's LUTs for both model entities and meshes coloring - if(modinfo) - { - vtkSMProxy* lutProxy = NULL; - if(colorMode == vtkModelMultiBlockSource::GetVolumeTagName()) - lutProxy = modinfo->VolumeLUT; - else if(colorMode == vtkModelMultiBlockSource::GetGroupTagName()) - lutProxy = modinfo->GroupLUT; - else if(colorMode == vtkModelMultiBlockSource::GetEntityTagName()) - lutProxy = modinfo->EntityLUT; - - RepresentationHelperFunctions::CMB_COLOR_REP_BY_INDEXED_LUT( - activeRep->getProxy(), colorMode == "None" ? - NULL : colorMode.toStdString().c_str(), lutProxy, - vtkDataObject::FIELD); - } + // EntityColorTable is no longer used to avoid random color + // check git history e826a54cbb325016130b19b0d325e4b71e0526d4 + // for volume, group LUT activeRep->renderViewEventually(); @@ -368,7 +358,7 @@ void pqModelBuilderViewContextMenuBehavior::colorByAttribute( minfo->Info->GetUUID2BlockIdMap().begin(); for(; uit != minfo->Info->GetUUID2BlockIdMap().end(); ++uit) { - indices.append(uit->second + 1); + indices.append(uit->second); } datapanel->clearBlockColor(indices); @@ -550,7 +540,7 @@ bool pqModelBuilderViewContextMenuBehavior::eventFilter(QObject* caller, QEvent* if(rightB) { this->buildMenuFromSelections(); - this->m_contextMenu->popup(senderWidget->mapToGlobal(newPos)); + this->m_contextMenu->popup(senderWidget->mapToGlobal(newPos)); } } this->m_clickPosition = QPoint(); @@ -569,7 +559,7 @@ void pqModelBuilderViewContextMenuBehavior::pickRepresentationBlock( int height = senderWidget->size().height(); pos[1] = height - pos[1]; unsigned int blockIndex = 0; - + pqDataRepresentation* pickedRepresentation = view->pickBlock(pos, blockIndex); // we want to select this block. if(pickedRepresentation) @@ -609,12 +599,12 @@ void pqModelBuilderViewContextMenuBehavior::buildMenuFromSelections() this->m_contextMenu->addAction(QString("%1 Entities").arg(selNumBlocks)); this->m_contextMenu->addSeparator(); } -/* +/* else // only one block is selected { QString blockName = this->lookupBlockName(modit.value().value(0), modit.key()); this->m_contextMenu->addAction(QString("%1").arg(blockName)); - } + } */ // Add actions to (if no meshes are selected, and the underlying model support these operations) : @@ -1009,7 +999,7 @@ void pqModelBuilderViewContextMenuBehavior::addToGroup(QAction* action) if(this->m_selModelBlocks.count() != 1) { std::cout << "addToGroup Failed, because this operation requires one and only one model being selected!\n"; - return; + return; } QMap >::const_iterator rbit = diff --git a/Source/Applications/ModelBuilder/pqSMTKModelInfo.cxx b/Source/Applications/ModelBuilder/pqSMTKModelInfo.cxx index 0b403dc6..540dd337 100644 --- a/Source/Applications/ModelBuilder/pqSMTKModelInfo.cxx +++ b/Source/Applications/ModelBuilder/pqSMTKModelInfo.cxx @@ -106,7 +106,7 @@ void pqSMTKModelInfo::init( proxyManager->NewProxy("lookup_tables", "PVLookupTable")); vtkSMPropertyHelper(this->AttributeLUT, "IndexedLookup", true).Set(1); - this->ColorMode = "None"; + this->ColorMode = "Entity"; this->updateBlockInfo(mgr); smtk::model::Model modelEntity(mgr,this->Info->GetModelUUID()); if (modelEntity.isValid()) -- GitLab