]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Implementation of "EDF 1702 GEOM: Displaying of GEOM object in 3D viewer while editin...
authorana <ana@opencascade.com>
Tue, 29 Jan 2013 14:16:52 +0000 (14:16 +0000)
committerana <ana@opencascade.com>
Tue, 29 Jan 2013 14:16:52 +0000 (14:16 +0000)
resources/SalomeApp.xml.in
src/GEOMBase/GEOMBase_Helper.cxx
src/GEOMBase/GEOMBase_Helper.h
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GeometryGUI.cxx
src/GroupGUI/GroupGUI_GroupDlg.cxx
src/GroupGUI/GroupGUI_GroupDlg.h

index 2d32d28fe2bfab923e7c55090cbdcd23b8051b70..2925e464d6ab047bbc121b724930ebd0bd00856d 100644 (file)
@@ -51,6 +51,7 @@
     <parameter name="isos_color"          value="200, 200, 200" />
     <parameter name="toplevel_color"      value="170, 85, 0" />
     <parameter name="toplevel_dm"         value="0" />
+    <parameter name="editgroup_color"     value="170, 85, 0" />
     <parameter name="type_of_marker"      value="1"  />
     <parameter name="deflection_coeff"    value="0.001"  />
     <parameter name="auto_create_base_objects" value="false"  />
index 856cd6a1ea6d7ef4273abb7f067e44778e4f824e..4a051722cdd3f4bb54b8bf3aec070b96805e9749 100755 (executable)
@@ -89,7 +89,7 @@ GEOM::GEOM_Gen_ptr GEOMBase_Helper::getGeomEngine()
 GEOMBase_Helper::GEOMBase_Helper( SUIT_Desktop* desktop )
   : myDesktop( desktop ), myViewWindow( 0 ), myDisplayer( 0 ), myCommand( 0 ), isPreview( false ),
     myIsApplyAndClose( false ), myIsOptimizedBrowsing( false ), myIsWaitCursorEnabled( true ),
-    myIsDisableBrowsing(false)
+    myIsDisableBrowsing(false), myIsDisplayResult(true)
 {
 }
 
@@ -876,7 +876,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
             }
             anEntryList << addInStudy( obj, aName.toLatin1().constData() );
             // updateView=false
-            display( obj, false );
+            if( isDisplayResult() )
+              display( obj, false );
 #ifdef WITHGENERICOBJ
             // obj has been published in study. Its refcount has been incremented.
             // It is safe to decrement its refcount
@@ -889,7 +890,8 @@ bool GEOMBase_Helper::onAccept( const bool publish, const bool useTransaction, b
             // was modified, and need to be re-cached in GEOM_Client before redisplay
             clearShapeBuffer( obj );
             // withChildren=true, updateView=false
-            redisplay( obj, true, false );
+            if( isDisplayResult() )
+              redisplay( obj, true, false );
           }
         }
 
index 87d96cfd483b1d7f1b6443624bb004c387bcc9bf..0a1ae7b6d2485310b025ca6343a9dcfa2c84bef4 100755 (executable)
@@ -191,6 +191,8 @@ protected:
   virtual bool                isWaitCursorEnabled() const {return myIsWaitCursorEnabled ;}
   virtual void                setIsDisableBrowsing( const bool theFlag ) { myIsDisableBrowsing = theFlag; }
   virtual bool                isDisableBrowsing() const { return myIsDisableBrowsing; }
+  virtual void                setIsDisplayResult( const bool theFlag ) {myIsDisplayResult = theFlag; }
+  virtual bool                isDisplayResult() const { return myIsDisplayResult; }
 
 private:
   QString                     getEntry( GEOM::GEOM_Object_ptr ) const;
@@ -213,6 +215,7 @@ private:
   bool                        myIsWaitCursorEnabled;
   bool                        myIsDisableBrowsing;  //This flag enable/disable selection
                                                     //in the Object Browser newly created objects.
+  bool                        myIsDisplayResult;    //This flag display/hide newly created objects.
 };
 
 #endif // GEOMBASE_HELPER_H
index 00c84861a980b9e887681c921ffbaec32ff972e1..dfe43b5737291c12b3ade4320de77090f49fcf22 100644 (file)
@@ -3206,6 +3206,10 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_PREDEF_MATERIALS</source>
         <translation>Show predefined materials in popup menu</translation>
     </message>
+    <message>
+        <source>PREF_EDITGROUP_COLOR</source>
+        <translation>Subshapes color for editing a group</translation>
+    </message>
     <message>
         <source>PREF_EDGE_WIDTH</source>
         <translation>Edges width</translation>
index 95798fa8ee0796907749b645be4222a99aee9a62..81418e0c8362a0da69003347c3ebf6b54b240b9e 100644 (file)
@@ -3182,6 +3182,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_PREDEF_MATERIALS</source>
         <translation type="unfinished">Show predefined materials in popup menu</translation>
     </message>
+    <message>
+        <source>PREF_EDITGROUP_COLOR</source>
+        <translation type="unfinished">Subshapes color for editing a group</translation>
+    </message>
     <message>
         <source>PREF_EDGE_WIDTH</source>
         <translation>Epaisseur des arêtes</translation>
index fadc0ada74c87c1943d0d742c959295376fe1f9c..1eef55c399881ca54b5c6c195eb17fc955318b85 100644 (file)
@@ -1825,6 +1825,9 @@ void GeometryGUI::createPreferences()
                                       LightApp_Preferences::Selector,
                                       "Geometry", "material" );
 
+  addPreference( tr( "PREF_EDITGROUP_COLOR" ), genGroup,
+                 LightApp_Preferences::Color, "Geometry", "editgroup_color" );
+
   const int nb = 4;
   int wd[nb];
   int iter=0;
index 5d51da8fb4345d98fc1b87cbceb65cc449173aec..13ae02f2d6fe8a329fb0d6affbd2eeb37380fa15 100644 (file)
@@ -33,6 +33,7 @@
 
 #include <SalomeApp_Application.h>
 #include <SalomeApp_Study.h>
+#include <SalomeApp_Tools.h>
 
 #include <LightApp_SelectionMgr.h>
 
@@ -66,6 +67,9 @@
 
 #include <GEOMImpl_Types.hxx>
 
+#define GROUP_IDLST_COLOR Qt::blue // Specific color for the IDs of subShapes in the dialog box
+#define GROUP_NEWIDLST_COLOR Qt::red // Specific color for the new IDs of subShapes in the dialog box
+
 enum { ALL_SUBSHAPES = 0, GET_IN_PLACE, SUBSHAPES_OF_SHAPE2, SUBSHAPES_OF_INVISIBLE_SHAPE2 };
 
 GroupGUI_GroupDlg::GroupGUI_GroupDlg (Mode mode, GeometryGUI* theGeometryGUI, QWidget* parent)
@@ -189,8 +193,10 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
   if (myIsHiddenMain) {
     GEOM_Displayer* aDisplayer = getDisplayer();
     aDisplayer->Display(myMainObj);
+    aDisplayer->Display(myGroup);
     myIsHiddenMain = false;
   }
+  myDmMode = -1;
 }
 
 //=================================================================================
@@ -199,6 +205,7 @@ GroupGUI_GroupDlg::~GroupGUI_GroupDlg()
 //=================================================================================
 void GroupGUI_GroupDlg::Init()
 {
+  myDmMode = -1;
   LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
 
   //unset shape type to avoid preparation of selection before exact user shape type selection
@@ -236,9 +243,12 @@ void GroupGUI_GroupDlg::Init()
         setShapeType((TopAbs_ShapeEnum)anOper->GetType(myGroup));
 
         GEOM::ListOfLong_var aCurrList = anOper->GetObjects(myGroup);
-        for (int i = 0, n = aCurrList->length(); i < n; i++)
-          myIdList->addItem(new QListWidgetItem(QString("%1").arg(aCurrList[i])));
-
+        for (int i = 0, n = aCurrList->length(); i < n; i++) {
+          QListWidgetItem* itm = new QListWidgetItem( QString( "%1" ).arg( aCurrList[ i ] ) );
+          myGroupIdList.append( aCurrList[ i ] );
+          itm->setTextColor( QColor( GROUP_IDLST_COLOR ) );
+          myIdList->addItem( itm );
+        }
         myEditCurrentArgument = 0;
       }
       connect(mySelBtn2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
@@ -306,14 +316,18 @@ void GroupGUI_GroupDlg::ClickOnOk()
 //=================================================================================
 bool GroupGUI_GroupDlg::ClickOnApply()
 {
-  if(!isApplyAndClose())
+  if(!isApplyAndClose()) {
     setIsDisableBrowsing( true );
+    setIsDisplayResult( false );
+  }
     
-  if (!onAccept(myMode == CreateGroup, true,isApplyAndClose()))
+  if (!onAccept(myMode == CreateGroup, true, isApplyAndClose()))
     return false;
 
-  if(!isApplyAndClose())
+  if(!isApplyAndClose()) {
     setIsDisableBrowsing( false );
+    setIsDisplayResult( true );
+  }
 
   if (myMode == CreateGroup)
   {
@@ -322,8 +336,19 @@ bool GroupGUI_GroupDlg::ClickOnApply()
     ConstructorsClicked(getConstructorId());
   }
   else
+  {
+    int n = myIdList->count();
+    myGroupIdList.clear();
+    if (n > 0)
+    {
+      for (int i = 0; i < n; i++) {
+        QListWidgetItem* anItem  = myIdList->item( i );
+        myGroupIdList.append( anItem->text().toInt() );
+        anItem->setTextColor( GROUP_IDLST_COLOR );
+      }
+    }
     activateSelection();
-
+  }
   return true;
 }
 
@@ -576,7 +601,7 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
   if (aSubShapes->length() > 0) {
     if (subSelectionWay() == ALL_SUBSHAPES)
     {
-      myIdList->clear(); // for sorted final list?
+//      myIdList->clear(); // for sorted final list?
 
       if (!aShOp->IsDone())
         return;
@@ -600,12 +625,13 @@ void GroupGUI_GroupDlg::selectAllSubShapes()
 
       QListWidgetItem* anItem = 0;
       QString text = QString("%1").arg(anIndex);
-      if (!myInPlaceObj->_is_nil()) {
+//      if (!myInPlaceObj->_is_nil()) {
         QList<QListWidgetItem*> found = myIdList->findItems(text, Qt::MatchExactly);
         if (found.count()) anItem = found[0];
-      }
+//      }
       if (!anItem) {
         anItem = new QListWidgetItem(text);
+        anItem->setTextColor( myGroupIdList.contains(anIndex) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
         myIdList->addItem(anItem);
       }
       anItem->setSelected(true);
@@ -754,6 +780,7 @@ void GroupGUI_GroupDlg::add()
         continue;
 
       QListWidgetItem* anItem = new QListWidgetItem(QString("%1").arg(aMapIndex(i)));
+      anItem->setTextColor( myGroupIdList.contains( aMapIndex( i ) ) ? QColor( GROUP_IDLST_COLOR ) : QColor( GROUP_NEWIDLST_COLOR ) );
       myIdList->addItem(anItem);
       anItem->setSelected(true);
     }
@@ -835,7 +862,7 @@ void GroupGUI_GroupDlg::setShapeType(const TopAbs_ShapeEnum theType)
 void GroupGUI_GroupDlg::activateSelection()
 {
   bool isApply = ((QPushButton*)sender() == buttonApply());
-  if(!isApply)
+  if(!isApplyAndClose())
     erasePreview(false);
 
   // local selection
@@ -844,27 +871,42 @@ void GroupGUI_GroupDlg::activateSelection()
       myIsShapeType) // check if shape type is already choosen by user
   {
     GEOM_Displayer* aDisplayer = getDisplayer();
-
-    // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
-    if (getShapeType() == TopAbs_VERTEX) {
-      if (myIsHiddenMain)
-        aDisplayer->Display(myMainObj);
-    }
-    else {
-      SALOME_View* view = GEOM_Displayer::GetActiveView();
+  
+    //display mode for main shape
+    if ( myDmMode == -1 ) {
+    SALOME_View* view = GEOM_Displayer::GetActiveView();
       if (view) {
         CORBA::String_var aMainEntry = myMainObj->GetStudyEntry();
         Handle(SALOME_InteractiveObject) io =
           new SALOME_InteractiveObject (aMainEntry.in(), "GEOM", "TEMP_IO");
-        if (view->isVisible(io)) {
-          aDisplayer->Erase(myMainObj, false, false);
-          myIsHiddenMain = true;
+        if ( view->isVisible( io ) ) {
+          Handle(GEOM_AISShape) aSh = GEOMBase::ConvertIOinGEOMAISShape( io, true );
+          if(!aSh.IsNull()) {
+            myDmMode = aSh->isTopLevel() ? aSh->prevDisplayMode() : aSh->DisplayMode();
+          }
+          // Hide main shape, if explode on VERTEX
+          if(getShapeType() != TopAbs_VERTEX) {
+            aDisplayer->Erase(myMainObj, false, false);
+            myIsHiddenMain = true;
+          }
         }
+        else
+          myDmMode = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "display_mode" );
       }
     }
-    if(!isApply) {
-      int prevDisplayMode = aDisplayer->SetDisplayMode(0);
+    aDisplayer->SetDisplayMode(myDmMode);
 
+    // Mantis issue 0021421: do not hide main shape, if explode on VERTEX
+    if (getShapeType() == TopAbs_VERTEX) {
+      if (myIsHiddenMain)
+        aDisplayer->Display(myMainObj);
+    }
+    aDisplayer->Erase(myGroup, false, false);
+
+    QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "Geometry", "editgroup_color" );
+    Quantity_NameOfColor aCol = SalomeApp_Tools::color( aColor ).Name();
+
+    if(!isApplyAndClose()) {
       SUIT_ViewWindow* aViewWindow = 0;
       SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
       if (activeStudy)
@@ -895,8 +937,15 @@ void GroupGUI_GroupDlg::activateSelection()
         for (; anExp.More(); anExp.Next()) {
           TopoDS_Shape aSubShape = anExp.Current();
           int index = aSubShapesMap.FindIndex(aSubShape);
-          QString anEntry = anEntryBase + QString("_%1").arg(index);
-
+          QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
+          Handle(SALOME_InteractiveObject) io =
+            new SALOME_InteractiveObject(anEntry.toAscii(), "GEOM", "TEMP_IO");
+          if ( myGroupIdList.contains( index ) ) {
+            aDisplayer->SetColor( aCol );
+          }
+          else {
+            aDisplayer->UnsetColor();
+          }
           SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
           if (aPrs) {
             displayPreview(aPrs, true, false); // append, do not update
@@ -914,7 +963,14 @@ void GroupGUI_GroupDlg::activateSelection()
         for (; aM2IPit.More(); aM2IPit.Next()) {
           int index = aM2IPit.Key();
           TopoDS_Shape aSubShape = aSubShapesMap.FindKey(index);
-          QString anEntry = anEntryBase + QString("_%1").arg(index);
+          QString anEntry = QString( "TEMP_" ) + anEntryBase + QString("_%1").arg(index);
+
+          if ( myGroupIdList.contains( index ) ) {
+            aDisplayer->SetColor( aCol );
+          }
+          else {
+            aDisplayer->UnsetColor();
+          }
 
           SALOME_Prs* aPrs = aDisplayer->buildSubshapePresentation(aSubShape, anEntry, aView);
           if (aPrs) {
@@ -923,9 +979,9 @@ void GroupGUI_GroupDlg::activateSelection()
         }
       }
       else ;
-
+      aDisplayer->UnsetDisplayMode();
+      aDisplayer->UnsetColor();
       aDisplayer->UpdateViewer();
-      aDisplayer->SetDisplayMode(prevDisplayMode);
     }
   }
 
index 438f52b1055d1dd95847c1e9095399195ab46caa..84618bf4b9f7301c0042c2ac39832cde8a857fe3 100644 (file)
@@ -102,6 +102,8 @@ private:
   GEOM::GEOM_Object_var               myInPlaceObj;
   int                                 myInPlaceObjSelectState;
   TColStd_DataMapOfIntegerInteger     myMain2InPlaceIndices;
+  QList<int>                          myGroupIdList;
+  int                                 myDmMode;
 
   QPushButton*                        mySelBtn;
   QLineEdit*                          myMainName;