From 98e8c177214dcc9d7b48f00048f165526aeca06e Mon Sep 17 00:00:00 2001 From: vsr Date: Tue, 11 Sep 2018 14:51:38 +0300 Subject: [PATCH] 0023580: [EDF] AsterStudy: more distinct display of selected items in 3D view --- resources/SalomeApp.xml.in | 2 + src/OBJECT/CMakeLists.txt | 2 + src/OBJECT/SMESH_Actor.cxx | 63 ++++++++++++-------------- src/OBJECT/SMESH_Actor.h | 8 +--- src/OBJECT/SMESH_ActorDef.h | 6 +-- src/OBJECT/SMESH_ActorProps.cxx | 73 ++++++++++++++++++++++++++++++ src/OBJECT/SMESH_ActorProps.h | 48 ++++++++++++++++++++ src/SMESHGUI/SMESHGUI.cxx | 12 ++++- src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 10 ++-- src/SMESHGUI/SMESH_msg_en.ts | 4 ++ src/SMESHGUI/SMESH_msg_fr.ts | 4 ++ src/SMESHGUI/SMESH_msg_ja.ts | 4 ++ 12 files changed, 184 insertions(+), 52 deletions(-) create mode 100644 src/OBJECT/SMESH_ActorProps.cxx create mode 100644 src/OBJECT/SMESH_ActorProps.h diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index 9c1b51daf..a9ffc18cb 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -115,6 +115,8 @@ + +
diff --git a/src/OBJECT/CMakeLists.txt b/src/OBJECT/CMakeLists.txt index 21b5ead3f..29ff1303f 100644 --- a/src/OBJECT/CMakeLists.txt +++ b/src/OBJECT/CMakeLists.txt @@ -79,6 +79,7 @@ SET(SMESHObject_HEADERS SMESH_Actor.h SMESH_Object.h SMESH_ObjectDef.h + SMESH_ActorProps.h SMESH_ActorUtils.h SMESH_ActorDef.h SMESH_DeviceActor.h @@ -98,6 +99,7 @@ SET(SMESHObject_SOURCES SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx + SMESH_ActorProps.cxx SMESH_PreviewActorsCollection.cxx SMESH_ExtractGeometry.cxx SMESH_ActorUtils.cxx diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index dac3d4a0d..0bf3b4176 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -28,6 +28,7 @@ #include "SMESH_ActorDef.h" #include "SMDS_UnstructuredGrid.hxx" +#include "SMESH_ActorProps.h" #include "SMESH_ActorUtils.h" #include "SMESH_CellLabelActor.h" #include "SMESH_ControlsDef.hxx" @@ -87,9 +88,6 @@ static int MYDEBUG = 0; static int MYDEBUG = 0; #endif -static int aLineWidthInc = 2; - - SMESH_ActorDef* SMESH_ActorDef::New(){ return new SMESH_ActorDef(); } @@ -141,6 +139,9 @@ SMESH_ActorDef::SMESH_ActorDef() myIsFacesOriented = false; + int controlsIncrement = SMESH_ActorProps::props()->controlsIncrement(); + int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement(); + myControlsPrecision = -1; SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); @@ -240,6 +241,7 @@ SMESH_ActorDef::SMESH_ActorDef() anRGB[0] = 1 - anRGB[0]; anRGB[1] = 1 - anRGB[1]; anRGB[2] = 1 - anRGB[2]; + my2DExtProp->SetLineWidth(aLineWidth + controlsIncrement); my2DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); my2DExtActor = SMESH_DeviceActor::New(); @@ -290,6 +292,7 @@ SMESH_ActorDef::SMESH_ActorDef() anRGB[0] = 1 - anRGB[0]; anRGB[1] = 1 - anRGB[1]; anRGB[2] = 1 - anRGB[2]; + my3DExtProp->SetLineWidth(aLineWidth + controlsIncrement); my3DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); my3DExtActor = SMESH_DeviceActor::New(); @@ -345,7 +348,7 @@ SMESH_ActorDef::SMESH_ActorDef() my1DProp = vtkProperty::New(); my1DProp->DeepCopy(myEdgeProp); - my1DProp->SetLineWidth(aLineWidth + aLineWidthInc); + my1DProp->SetLineWidth(aLineWidth + controlsIncrement); my1DProp->SetPointSize(aElem0DSize); my1DExtProp = vtkProperty::New(); @@ -354,7 +357,7 @@ SMESH_ActorDef::SMESH_ActorDef() anRGB[1] = 1 - anRGB[1]; anRGB[2] = 1 - anRGB[2]; my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc); + my1DExtProp->SetLineWidth(aLineWidth + controlsIncrement); my1DExtProp->SetPointSize(aElem0DSize); // my1DExtActor is used to show filtered edges or links between nodes @@ -485,7 +488,7 @@ SMESH_ActorDef::SMESH_ActorDef() SMESH::GetColor( "SMESH", "selection_object_color", anRGB[0], anRGB[1], anRGB[2], QColor( 255, 255, 255 ) ); myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myHighlightProp->SetPointSize(aElem0DSize); // ?? - myHighlightProp->SetLineWidth(aLineWidth); + myHighlightProp->SetLineWidth(aLineWidth + selectionIncrement); myHighlightProp->SetRepresentation(1); myOutLineProp = vtkProperty::New(); @@ -504,7 +507,7 @@ SMESH_ActorDef::SMESH_ActorDef() SMESH::GetColor( "SMESH", "highlight_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 255, 255 ) ); myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreselectProp->SetPointSize(aElem0DSize); // ?? - myPreselectProp->SetLineWidth(aLineWidth); + myPreselectProp->SetLineWidth(aLineWidth + selectionIncrement); myPreselectProp->SetRepresentation(1); myHighlitableActor = SMESH_DeviceActor::New(); @@ -2197,29 +2200,19 @@ void SMESH_ActorDef::GetBallColor(double& r,double& g,double& b) ::GetColor(myBallProp,r,g,b); } -void SMESH_ActorDef::SetHighlightColor(double r,double g,double b) -{ - myHighlightProp->SetColor(r,g,b); - Modified(); -} - -void SMESH_ActorDef::GetHighlightColor(double& r,double& g,double& b) -{ - ::GetColor(myHighlightProp,r,g,b); -} - -void SMESH_ActorDef::SetPreHighlightColor(double r,double g,double b) -{ - myPreselectProp->SetColor(r,g,b); +void SMESH_ActorDef::UpdateSelectionProps() +{ + QColor selectionColor = SMESH_ActorProps::props()->selectionColor(); + QColor highlightColor = SMESH_ActorProps::props()->highlightColor(); + int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement(); + double width = GetLineWidth(); + myHighlightProp->SetColor(selectionColor.redF(), selectionColor.greenF(), selectionColor.blueF()); + myHighlightProp->SetLineWidth(width + selectionIncrement); + myPreselectProp->SetColor(highlightColor.redF(), highlightColor.greenF(), highlightColor.blueF()); + myPreselectProp->SetLineWidth(width + selectionIncrement); Modified(); } -void SMESH_ActorDef::GetPreHighlightColor(double& r,double& g,double& b) -{ - ::GetColor(myPreselectProp,r,g,b); -} - - double SMESH_ActorDef::GetLineWidth() { return myEdgeProp->GetLineWidth(); @@ -2228,15 +2221,17 @@ double SMESH_ActorDef::GetLineWidth() void SMESH_ActorDef::SetLineWidth(double theVal) { + int controlsIncrement = SMESH_ActorProps::props()->controlsIncrement(); + int selectionIncrement = SMESH_ActorProps::props()->selectionIncrement(); + myEdgeProp->SetLineWidth(theVal); - my1DProp->SetLineWidth(theVal + aLineWidthInc); - my1DExtProp->SetLineWidth(theVal + aLineWidthInc); - my2DExtProp->SetLineWidth(theVal + aLineWidthInc); - my3DExtProp->SetLineWidth(theVal + aLineWidthInc); - myOutLineProp->SetLineWidth(theVal); - myHighlightProp->SetLineWidth(theVal); - myPreselectProp->SetLineWidth(theVal); + my1DProp->SetLineWidth(theVal + controlsIncrement); + my1DExtProp->SetLineWidth(theVal + controlsIncrement); + my2DExtProp->SetLineWidth(theVal + controlsIncrement); + my3DExtProp->SetLineWidth(theVal + controlsIncrement); + myHighlightProp->SetLineWidth(theVal + selectionIncrement); + myPreselectProp->SetLineWidth(theVal + selectionIncrement); Modified(); } diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 7ad9d2f88..c72ca7e16 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -83,12 +83,8 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor virtual void SetBallColor(double r,double g,double b) = 0; virtual void GetBallColor(double& r,double& g,double& b) = 0; - virtual void SetHighlightColor(double r,double g,double b) = 0; - virtual void GetHighlightColor(double& r,double& g,double& b) = 0; - - virtual void SetPreHighlightColor(double r,double g,double b) = 0; - virtual void GetPreHighlightColor(double& r,double& g,double& b) = 0; - + virtual void UpdateSelectionProps() = 0; + virtual double GetLineWidth() = 0; virtual void SetLineWidth(double theVal) = 0; diff --git a/src/OBJECT/SMESH_ActorDef.h b/src/OBJECT/SMESH_ActorDef.h index 833e8253f..3488f4401 100644 --- a/src/OBJECT/SMESH_ActorDef.h +++ b/src/OBJECT/SMESH_ActorDef.h @@ -127,11 +127,7 @@ class SMESH_ActorDef : public SMESH_Actor virtual void SetBallColor(double r,double g,double b); virtual void GetBallColor(double& r,double& g,double& b); - virtual void SetHighlightColor(double r,double g,double b); - virtual void GetHighlightColor(double& r,double& g,double& b); - - virtual void SetPreHighlightColor(double r,double g,double b); - virtual void GetPreHighlightColor(double& r,double& g,double& b); + virtual void UpdateSelectionProps(); virtual double GetLineWidth(); virtual void SetLineWidth(double theVal); diff --git a/src/OBJECT/SMESH_ActorProps.cxx b/src/OBJECT/SMESH_ActorProps.cxx new file mode 100644 index 000000000..800dc7ca8 --- /dev/null +++ b/src/OBJECT/SMESH_ActorProps.cxx @@ -0,0 +1,73 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#include "SMESH_ActorProps.h" + +#include +#include + +SMESH_ActorProps* SMESH_ActorProps::props() +{ + static SMESH_ActorProps* g_props = 0; + if (!g_props) + g_props = new SMESH_ActorProps(); + return g_props; +} + +void SMESH_ActorProps::reset() +{ + props()->initialize(); +} + +SMESH_ActorProps::SMESH_ActorProps() +{ + initialize(); +} + +void SMESH_ActorProps::initialize() +{ + SUIT_ResourceMgr* mgr = SUIT_Session::session()->resourceMgr(); + m_selection_color = mgr->colorValue("SMESH", "selection_object_color", Qt::white); + m_highlight_color = mgr->colorValue("SMESH", "highlight_color", Qt::cyan); + m_selection_increment = qBound(0, mgr->integerValue("SMESH", "selection_increment", 0), 5); + m_controls_increment = qBound(0, mgr->integerValue("SMESH", "controls_increment", 2), 5); +} + +QColor SMESH_ActorProps::selectionColor() const +{ + return m_selection_color; +} + +QColor SMESH_ActorProps::highlightColor() const +{ + return m_highlight_color; +} + +int SMESH_ActorProps::selectionIncrement() const +{ + return m_selection_increment; +} + +int SMESH_ActorProps::controlsIncrement() const +{ + return m_controls_increment; +} diff --git a/src/OBJECT/SMESH_ActorProps.h b/src/OBJECT/SMESH_ActorProps.h new file mode 100644 index 000000000..c2139e268 --- /dev/null +++ b/src/OBJECT/SMESH_ActorProps.h @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef SMESH_ACTORPROPS_H +#define SMESH_ACTORPROPS_H + +#include "SMESH_Object.h" +#include + +class SMESHOBJECT_EXPORT SMESH_ActorProps +{ +public: + static SMESH_ActorProps* props(); + static void reset(); + + QColor selectionColor() const; + QColor highlightColor() const; + int selectionIncrement() const; + int controlsIncrement() const; + +private: + SMESH_ActorProps(); + void initialize(); + + QColor m_selection_color, m_highlight_color; + int m_selection_increment, m_controls_increment; +}; + +#endif //SMESH_ACTORPROPS_H diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index d3d701490..ce6896da3 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -5137,6 +5137,11 @@ void SMESHGUI::createPreferences() setPreferenceProperty( doubleNodesTol, "max", 1000000.0 ); setPreferenceProperty( doubleNodesTol, "step", 0.0000001 ); + /* + int cinc = addPreference(tr("PREF_CONTROLS_INCREMENT"), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_increment"); + setPreferenceProperty( cinc, "min", 0 ); + setPreferenceProperty( cinc, "max", 5 ); + */ int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab ); setPreferenceProperty( exportgroup, "columns", 2 ); @@ -5370,6 +5375,10 @@ void SMESHGUI::createPreferences() addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" ); addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" ); + int sinc = addPreference(tr("PREF_SELECTION_INCREMENT"), selTab, LightApp_Preferences::IntSpin, "SMESH", "selection_increment"); + setPreferenceProperty( sinc, "min", 0 ); + setPreferenceProperty( sinc, "max", 5 ); + // Scalar Bar tab ------------------------------------------------------------------------ int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) ); int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab ); @@ -5469,7 +5478,8 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name ) name== "highlight_color" || name=="selection_precision_node" || name=="selection_precision_element" || - name=="selection_precision_object" ) + name=="selection_precision_object" || + name=="selection_increment") { SMESH::UpdateSelectionProp( this ); } diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index ef9fb3896..ac471b318 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -32,6 +32,7 @@ #include "SMESHGUI_Utils.h" #include "SMDS_Mesh.hxx" #include "SMESH_Actor.h" +#include "SMESH_ActorProps.h" #include "SMESH_ActorUtils.h" #include "SMESH_CellLabelActor.h" #include "SMESH_ControlsDef.hxx" @@ -903,6 +904,8 @@ namespace SMESH return; } + SMESH_ActorProps::props()->reset(); + QColor aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ), aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ), @@ -944,12 +947,7 @@ namespace SMESH aCollection->InitTraversal(); while ( vtkActor *anAct = aCollection->GetNextActor() ) { if ( SMESH_Actor *anActor = dynamic_cast(anAct) ) { - anActor->SetHighlightColor(aHiColor.red()/255., - aHiColor.green()/255., - aHiColor.blue()/255.); - anActor->SetPreHighlightColor(aPreColor.red()/255., - aPreColor.green()/255., - aPreColor.blue()/255.); + anActor->UpdateSelectionProps(); } } } diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index f36fa04c7..4be7190ad 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4830,6 +4830,10 @@ Please, create VTK viewer and try again PREF_OBJECTS Objects + + PREF_SELECTION_INCREMENT + Elements width increment + PREF_OBJECT_COLOR Object color diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 80ba63665..66a93961c 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -4780,6 +4780,10 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_OBJECTS Objets + + PREF_SELECTION_INCREMENT + Elements width increment + PREF_OBJECT_COLOR Couleur d'objet diff --git a/src/SMESHGUI/SMESH_msg_ja.ts b/src/SMESHGUI/SMESH_msg_ja.ts index 22e77aa54..91e3a408d 100644 --- a/src/SMESHGUI/SMESH_msg_ja.ts +++ b/src/SMESHGUI/SMESH_msg_ja.ts @@ -4731,6 +4731,10 @@ PREF_OBJECTS オブジェクト + + PREF_SELECTION_INCREMENT + Elements width increment + PREF_OBJECT_COLOR オブジェクトの色 -- 2.39.2