From: enk Date: Fri, 23 Dec 2005 15:22:32 +0000 (+0000) Subject: Improvement Bug PAL10652 X-Git-Tag: T_Before_Join_BR_3_1_0deb~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=173c40201058b2bd57070f6ba5c989d4b76fdf36;p=modules%2Fvisu.git Improvement Bug PAL10652 Superposition of scale bars in VISU --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 4284985d..bb3f6b94 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -698,6 +698,8 @@ OnErasePrs() for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) { anIO = it.Value(); CORBA::Object_var anObject = GetSelectedObj( GetAppStudy(this), anIO->getEntry() ); + if (!CORBA::is_nil(anObject)) + RemoveScalarBarPosition(this,anObject); ErasePrs( this, anObject, false ); } @@ -833,7 +835,9 @@ OnEraseAll() for (anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ) { if (anActor->GetVisibility() > 0) if (VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)) { + RemoveScalarBarPosition(this,anVISUActor->GetPrs3d()); anVISUActor = anVISUActor->GetParent(); + RemoveScalarBarPosition(this,anVISUActor->GetPrs3d()); anVISUActor->VisibilityOff(); } } @@ -2923,6 +2927,9 @@ void VisuGUI::createPreferences() setPreferenceProperty( wh, "max", 1.0 ); setPreferenceProperty( hh, "max", 1.0 ); + int scalarBarGr = addPreference( tr( "Scalar bars default position" ), sbarTab ); + addPreference( tr( "Arrange Scalar Bars" ), scalarBarGr, LightApp_Preferences::Bool, "VISU", "scalar_bars_default_position" ); + int srangeTab = addPreference( tr( "Scalar range, Sweep, MED import" ) ); int rangeGr = addPreference( tr( "VISU_SCALAR_RANGE" ), srangeTab ); @@ -2989,6 +2996,12 @@ VisuGUI return getApp()->getViewManager(theType,theIsCreate); } +TViewToPrs3d +VisuGUI +::getScalarBarsMap() +{ + return myScalarBarsMap; +} LightApp_Displayer* VisuGUI::displayer() { if( !myDisplayer ) diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 87240116..45e3b059 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -31,7 +31,18 @@ #include "SalomeApp_Module.h" +#include +#include + class SUIT_ViewManager; +class SVTK_ViewWindow; +class Prs3d_i; + +namespace VISU{ +typedef std::pair TPrs3dToInd; // prs pointer and default index of scalar bar placement +typedef std::set TSetPrs3d; +typedef std::map TViewToPrs3d; +} class VisuGUI: public SalomeApp_Module { @@ -61,6 +72,9 @@ public: getViewManager(const QString& theType, const bool theIsCreate); + VISU::TViewToPrs3d getScalarBarsMap(); + VISU::TViewToPrs3d myScalarBarsMap; + public slots: virtual bool deactivateModule( SUIT_Study* ); virtual bool activateModule( SUIT_Study* ); diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 10716c36..d6a6959b 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -120,6 +120,13 @@ namespace VISU QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); QString aFieldName = Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); QString aTimeStampId = Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); + // + SUIT_ResourceMgr* aResourceMgr = GetResourceMgr(); + VisuGUI* aMod = dynamic_cast(theModule); + int aPos = 1; + if (aMod) aPos = GetFreePositionOfDefaultScalarBar(aMod); + aResourceMgr->setValue("VISU","scalar_bar_position_num",aPos); + // QApplication::setOverrideCursor(Qt::waitCursor); TPrs3d_i* aPrs3d = @@ -155,6 +162,9 @@ namespace VISU } } PublishInView(theModule,aPrs3d); + Prs3d_i* aPrs_i = dynamic_cast(aPrs3d); + if (aPrs_i != NULL && aMod != NULL) + AddScalarBarPosition(aMod,aPrs_i,aPos); return true; } return false; diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 717c2bff..4bdf982d 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -266,7 +266,6 @@ VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): myBusy = false; } - /** * Initializes dialog box values from resources */ @@ -279,6 +278,12 @@ void VisuGUI_ScalarBarPane::initFromResources() { SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); + int aPlace = 1; + if (anIsArrangeBar){ + aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); + } + int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0); myModeCombo->setCurrentItem(aScalarMode); @@ -299,6 +304,11 @@ void VisuGUI_ScalarBarPane::initFromResources() { sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW); sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH); + if(orient){ + sbY1 += sbH*(aPlace-1); + } else { + sbX1 += sbW*(aPlace-1); + } sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol); sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 83eab744..300112d5 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -58,6 +58,8 @@ #include "SUIT_Session.h" #include "SUIT_MessageBox.h" +#include "VisuGUI.h" + #include #include @@ -354,7 +356,6 @@ namespace VISU return true; } - //************************************************************ // Display/Erase void @@ -403,20 +404,23 @@ namespace VISU _PTR(Study) theStudy, _PTR(SObject) theSObject) { - SalomeApp_Study* study = GetAppStudy( theModule ); + //SalomeApp_Study* study = GetAppStudy( theModule ); _PTR(ChildIterator) aChildIter = theStudy->NewChildIterator(theSObject); for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) { _PTR(SObject) aChildSObject = aChildIter->Value(); CORBA::Object_var aChildObj = VISU::ClientSObjectToObject(aChildSObject); + VisuGUI* aMod = dynamic_cast(theModule); + if(aMod) RemoveScalarBarPosition(aMod,aChildObj); ErasePrs(theModule, aChildObj); } CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject); if (!CORBA::is_nil(anObj)) { + VisuGUI* aMod = dynamic_cast(theModule); + if(aMod) RemoveScalarBarPosition(aMod,anObj); ErasePrs(theModule, anObj); - VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj); if (!CORBA::is_nil(aRemovableObject)) { aRemovableObject->RemoveFromStudy(); @@ -452,6 +456,11 @@ namespace VISU } } thePrs->RemoveFromStudy(); + + VisuGUI* aMod = dynamic_cast(theModule); + Prs3d_i* aPrs_i = dynamic_cast(thePrs); + if (aMod && aPrs_i) + RemoveScalarBarPosition(aMod,aPrs_i); } void @@ -460,13 +469,13 @@ namespace VISU { if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){ VISU_Actor* anVISUActor = FindActor( vw, thePrs ); + if (anVISUActor) { anVISUActor->VisibilityOff(); } } } - //************************************************************ // Presentation management void @@ -542,7 +551,6 @@ namespace VISU } } - //************************************************************ // SObject type bool @@ -606,7 +614,6 @@ namespace VISU return pResult; } - //************************************************************ // Views SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType) @@ -623,7 +630,6 @@ namespace VISU return 0; } - //************************************************************ // VTK View TViewWindows @@ -1373,4 +1379,58 @@ namespace VISU } return aList; } + + int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){ + int minIndx = 1; + std::set aIndexes; + SVTK_ViewWindow* vw = GetViewWindow(theModule); + TViewToPrs3d aMap = theModule->getScalarBarsMap(); + TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(vw); + if (aViewToPrsIter != aMap.end()){ + TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin(); + for(;aPrsIter!=(aViewToPrsIter->second).end();aPrsIter++){ + aIndexes.insert((*aPrsIter).second); + } + } + std::set::const_iterator aIter = aIndexes.begin(); + for (int i=1,length=aIndexes.size(); i <= length; i++){ + std::set::const_iterator aIter = aIndexes.find(i); + if(aIter==aIndexes.end()){minIndx = i;break;} + else minIndx = i + 1; + + } + return minIndx; + } + + void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos){ + SVTK_ViewWindow* vw = GetViewWindow(theModule); + TViewToPrs3d& aMap = theModule->myScalarBarsMap; + TPrs3dToInd aPair; aPair.first=thePrs3d; aPair.second=pos; + aMap[vw].insert(aPair); + } + + void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d){ + TViewToPrs3d& aMap = theModule->myScalarBarsMap; + TSetPrs3d::iterator aIter = aMap[vw].begin(); + for(;aIter!=aMap[vw].end();aIter++) + if((*aIter).first == thePrs3d){ + aMap[vw].erase(*aIter); + return; + } + } + + void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d){ + SVTK_ViewWindow* vw = GetViewWindow(theModule); + RemoveScalarBarPosition(theModule,vw,thePrs3d); + } + + void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject){ + if (!CORBA::is_nil(theObject)) { + Base_var aBase = Base::_narrow(theObject); + if (CORBA::is_nil(aBase)) return; + if (VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aBase).in())){ + RemoveScalarBarPosition(theModule,aPrsObject); + } + } + } } diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 3f36c793..3fcfa37e 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -50,6 +50,7 @@ class Plot2d_ViewFrame; class CAM_Module; class LightApp_SelectionMgr; class SalomeApp_Study; +class VisuGUI; namespace VISU { class Prs3d_i; @@ -194,6 +195,12 @@ namespace VISU { const Handle(SALOME_InteractiveObject)& theIO); std::vector GetPrs3dList (const SalomeApp_Module* theModule, _PTR(SObject) theObject); + + int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule); + void AddScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d, int pos); + void RemoveScalarBarPosition(VisuGUI* theModule,VISU::Prs3d_i* thePrs3d); + void RemoveScalarBarPosition(VisuGUI* theModule,SVTK_ViewWindow* vw,VISU::Prs3d_i* thePrs3d); + void RemoveScalarBarPosition(VisuGUI* theModule,CORBA::Object_ptr theObject); } bool VISU::IsSObjectTable( _PTR(SObject) theSObject ) diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index ebd818ed..e818c1cc 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -194,6 +194,19 @@ VISU::Storable* VISU::ScalarMap_i::Create(const char* theMeshName, VISU::Entity myHeight = (myOrientation == VISU::ScalarMap::VERTICAL)? 0.8:0.12; myHeight = aResourceMgr->doubleValue("VISU", propertyName + "height", myHeight); + // scalar bar default position + bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); + int aPlace = 1; + if (anIsArrangeBar){ + aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); + } + if(myOrientation == VISU::ScalarMap::HORIZONTAL){ + myPosition[1] += myHeight*(aPlace-1); + } else { + myPosition[0] += myWidth*(aPlace-1); + } + + // Nb of Colors int aNumberOfColors = aResourceMgr->integerValue( "VISU", "scalar_bar_num_colors", 64 ); SetNbColors(aNumberOfColors);