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 );
}
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();
}
}
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 );
return getApp()->getViewManager(theType,theIsCreate);
}
+TViewToPrs3d
+VisuGUI
+::getScalarBarsMap()
+{
+ return myScalarBarsMap;
+}
LightApp_Displayer* VisuGUI::displayer()
{
if( !myDisplayer )
#include "SalomeApp_Module.h"
+#include <map>
+#include <set>
+
class SUIT_ViewManager;
+class SVTK_ViewWindow;
+class Prs3d_i;
+
+namespace VISU{
+typedef std::pair<Prs3d_i*,int> TPrs3dToInd; // prs pointer and default index of scalar bar placement
+typedef std::set<TPrs3dToInd> TSetPrs3d;
+typedef std::map<SVTK_ViewWindow*,TSetPrs3d> TViewToPrs3d;
+}
class VisuGUI: public SalomeApp_Module
{
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* );
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<VisuGUI*>(theModule);
+ int aPos = 1;
+ if (aMod) aPos = GetFreePositionOfDefaultScalarBar(aMod);
+ aResourceMgr->setValue("VISU","scalar_bar_position_num",aPos);
+ //
QApplication::setOverrideCursor(Qt::waitCursor);
TPrs3d_i* aPrs3d =
}
}
PublishInView(theModule,aPrs3d);
+ Prs3d_i* aPrs_i = dynamic_cast<Prs3d_i*>(aPrs3d);
+ if (aPrs_i != NULL && aMod != NULL)
+ AddScalarBarPosition(aMod,aPrs_i,aPos);
return true;
}
return false;
myBusy = false;
}
-
/**
* Initializes dialog box values from resources
*/
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);
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);
#include "SUIT_Session.h"
#include "SUIT_MessageBox.h"
+#include "VisuGUI.h"
+
#include <vtkRenderer.h>
#include <vtkActorCollection.h>
return true;
}
- //************************************************************
// Display/Erase
void
_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<VisuGUI*>(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<VisuGUI*>(theModule);
+ if(aMod) RemoveScalarBarPosition(aMod,anObj);
ErasePrs(theModule, anObj);
-
VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
if (!CORBA::is_nil(aRemovableObject)) {
aRemovableObject->RemoveFromStudy();
}
}
thePrs->RemoveFromStudy();
+
+ VisuGUI* aMod = dynamic_cast<VisuGUI*>(theModule);
+ Prs3d_i* aPrs_i = dynamic_cast<Prs3d_i*>(thePrs);
+ if (aMod && aPrs_i)
+ RemoveScalarBarPosition(aMod,aPrs_i);
}
void
{
if ( SVTK_ViewWindow* vw = GetViewWindow( theModule ) ){
VISU_Actor* anVISUActor = FindActor( vw, thePrs );
+
if (anVISUActor) {
anVISUActor->VisibilityOff();
}
}
}
- //************************************************************
// Presentation management
void
}
}
- //************************************************************
// SObject type
bool
return pResult;
}
- //************************************************************
// Views
SUIT_ViewWindow* GetActiveView(const SalomeApp_Module* theModule, QString theType)
return 0;
}
- //************************************************************
// VTK View
TViewWindows
}
return aList;
}
+
+ int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule){
+ int minIndx = 1;
+ std::set<int> 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<int>::const_iterator aIter = aIndexes.begin();
+ for (int i=1,length=aIndexes.size(); i <= length; i++){
+ std::set<int>::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::Prs3d_i*>(VISU::GetServant(aBase).in())){
+ RemoveScalarBarPosition(theModule,aPrsObject);
+ }
+ }
+ }
}
class CAM_Module;
class LightApp_SelectionMgr;
class SalomeApp_Study;
+class VisuGUI;
namespace VISU {
class Prs3d_i;
const Handle(SALOME_InteractiveObject)& theIO);
std::vector<VISU::Prs3d_i*> 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 )
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);