From 03a4ab784b7486b5d125242f187c5ef51cbfa168 Mon Sep 17 00:00:00 2001 From: ana Date: Tue, 29 Jan 2013 14:16:52 +0000 Subject: [PATCH] Implementation of "EDF 1702 GEOM: Displaying of GEOM object in 3D viewer while editing a group" and "EDF 1630 GEOM: Specific color when editing a group" issues. --- resources/SalomeApp.xml.in | 1 + src/GEOMBase/GEOMBase_Helper.cxx | 8 +- src/GEOMBase/GEOMBase_Helper.h | 3 + src/GEOMGUI/GEOM_msg_en.ts | 4 + src/GEOMGUI/GEOM_msg_fr.ts | 4 + src/GEOMGUI/GeometryGUI.cxx | 3 + src/GroupGUI/GroupGUI_GroupDlg.cxx | 114 +++++++++++++++++++++-------- src/GroupGUI/GroupGUI_GroupDlg.h | 2 + 8 files changed, 107 insertions(+), 32 deletions(-) diff --git a/resources/SalomeApp.xml.in b/resources/SalomeApp.xml.in index 2d32d28fe..2925e464d 100644 --- a/resources/SalomeApp.xml.in +++ b/resources/SalomeApp.xml.in @@ -51,6 +51,7 @@ + diff --git a/src/GEOMBase/GEOMBase_Helper.cxx b/src/GEOMBase/GEOMBase_Helper.cxx index 856cd6a1e..4a051722c 100755 --- a/src/GEOMBase/GEOMBase_Helper.cxx +++ b/src/GEOMBase/GEOMBase_Helper.cxx @@ -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 ); } } diff --git a/src/GEOMBase/GEOMBase_Helper.h b/src/GEOMBase/GEOMBase_Helper.h index 87d96cfd4..0a1ae7b6d 100755 --- a/src/GEOMBase/GEOMBase_Helper.h +++ b/src/GEOMBase/GEOMBase_Helper.h @@ -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 diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 00c84861a..dfe43b573 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -3206,6 +3206,10 @@ Please, select face, shell or solid and try again PREF_PREDEF_MATERIALS Show predefined materials in popup menu + + PREF_EDITGROUP_COLOR + Subshapes color for editing a group + PREF_EDGE_WIDTH Edges width diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 95798fa8e..81418e0c8 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -3182,6 +3182,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau PREF_PREDEF_MATERIALS Show predefined materials in popup menu + + PREF_EDITGROUP_COLOR + Subshapes color for editing a group + PREF_EDGE_WIDTH Epaisseur des arêtes diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index fadc0ada7..1eef55c39 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -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; diff --git a/src/GroupGUI/GroupGUI_GroupDlg.cxx b/src/GroupGUI/GroupGUI_GroupDlg.cxx index 5d51da8fb..13ae02f2d 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.cxx +++ b/src/GroupGUI/GroupGUI_GroupDlg.cxx @@ -33,6 +33,7 @@ #include #include +#include #include @@ -66,6 +67,9 @@ #include +#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 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); } } diff --git a/src/GroupGUI/GroupGUI_GroupDlg.h b/src/GroupGUI/GroupGUI_GroupDlg.h index 438f52b10..84618bf4b 100644 --- a/src/GroupGUI/GroupGUI_GroupDlg.h +++ b/src/GroupGUI/GroupGUI_GroupDlg.h @@ -102,6 +102,8 @@ private: GEOM::GEOM_Object_var myInPlaceObj; int myInPlaceObjSelectState; TColStd_DataMapOfIntegerInteger myMain2InPlaceIndices; + QList myGroupIdList; + int myDmMode; QPushButton* mySelBtn; QLineEdit* myMainName; -- 2.39.2