if (CheckLock(aStudy,GetDesktop(this)))
return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
// Get selected SObject
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
if (anIO.IsNull() || !anIO->hasEntry())
return;
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
Handle(SALOME_InteractiveObject) anIO = it.Value();
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- if(CORBA::is_nil(anObject))
+ TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(!aBase)
continue;
- VISU::Base_var aBase = VISU::Base::_narrow(anObject);
- if(!CORBA::is_nil(aBase)){
- VISU::VISUType aType = aBase->GetType();
- switch (aType) {
- case VISU::TCURVE:
- case VISU::TCONTAINER:
- case VISU::TTABLE:
- displayer()->Display(anIO->getEntry());
- break;
- default: {
- VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aBase);
- if(!CORBA::is_nil(aPrs3d) || aType == VISU::TCOLOREDPRS3DHOLDER){
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
- displayer()->Display(anIO->getEntry());
- aViewWindow->highlight(anIO, 1);
- aViewWindow->getRenderer()->ResetCameraClippingRange();
- aViewWindow->Repaint();
- }
+ VISU::VISUType aType = aBase->GetType();
+ switch (aType) {
+ case VISU::TCURVE:
+ case VISU::TCONTAINER:
+ case VISU::TTABLE:
+ displayer()->Display(anIO->getEntry());
+ break;
+ default: {
+ VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase);
+ if(aPrs3d){
+ if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this)){
+ displayer()->Display(anIO->getEntry());
+ aViewWindow->highlight(anIO, 1);
+ aViewWindow->getRenderer()->ResetCameraClippingRange();
+ aViewWindow->Repaint();
}
}}
}
::OnErasePrs()
{
if(MYDEBUG) MESSAGE("OnErasePrs");
-
QApplication::setOverrideCursor(Qt::waitCursor);
- //SVTK_ViewWindow* vw = GetActiveViewWindow<SVTK_ViewWindow>(this);
- //if (vw)
- // vw->unHighlightAll();
-
SALOME_ListIO aList, aSel;
- LightApp_SelectionMgr* mgr = GetSelectionMgr(this);
- mgr->selectedObjects(aSel);
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+ aSelectionMgr->selectedObjects(aSel);
extractContainers(aSel, aList);
for (SALOME_ListIteratorOfListIO it (aList); it.More(); it.Next()) {
Handle(SALOME_InteractiveObject) anIO = it.Value();
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- //ErasePrs(this, anObject, /*repaint_view_window = */false);
- ErasePrs(this, anObject, /*repaint_view_window = */true);
+ TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ ErasePrs(this, aBase, /*repaint_view_window = */true);
}
- //if (vw)
- // vw->Repaint();
-
QApplication::restoreOverrideCursor();
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEraseAll()
}
+namespace
+{
+ //----------------------------------------------------------------------------
+ VISU::Prs3d_i*
+ GetPrsToModify(const SalomeApp_Module* theModule,
+ Handle(SALOME_InteractiveObject)& theIO)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return NULL;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ theIO = aSelectionItem.myIO;
+ return VISU::GetPrs3dToModify(theModule, aSelectionItem.myObjectInfo.myBase);
+ }
+}
+
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditScalarMap()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::ScalarMap_i, VisuGUI_ScalarBarDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditDeformedShape()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::DeformedShape_i, VisuGUI_DeformedShapeDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditScalarMapOnDeformedShape()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::ScalarMapOnDeformedShape_i, VisuGUI_ScalarMapOnDeformedShapeDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditCutPlanes()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::CutPlanes_i, VisuGUI_CutPlanesDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditCutLines()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::CutLines_i, VisuGUI_CutLinesDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditIsoSurfaces()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditVectors()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::Vectors_i, VisuGUI_VectorsDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditStreamLines()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::StreamLines_i, VisuGUI_StreamLinesDlg, 1>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditPlot3D()
{
Handle(SALOME_InteractiveObject) anIO;
- if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, &anIO))
+ if (VISU::Prs3d_i* aPrs3d = GetPrsToModify(this, anIO))
EditPrs3d<VISU::Plot3D_i, VisuGUI_Plot3DDlg, 0>(this, anIO, aPrs3d);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakeSurfaceframe()
ChangeRepresentation(this, VISU::SURFACEFRAME);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakeInsideframe()
ChangeRepresentation(this, VISU::INSIDEFRAME);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakeWireframe()
ChangeRepresentation(this, VISU::WIREFRAME);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakeSurface()
ChangeRepresentation(this, VISU::SHADED);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakePoints()
ChangeRepresentation(this, VISU::POINT);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMakeShrink()
ChangeRepresentation(this, VISU::SHRINK);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnSetShadingOn()
SetShading(this, true);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnSetShadingOff()
SetShading(this, false);
}
+
+namespace
+{
+ //----------------------------------------------------------------------------
+ bool
+ GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return false;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
+ }
+}
+
+//----------------------------------------------------------------------------
void
VisuGUI
::OnChangeColor()
{
- SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if(!aViewWindow)
- return;
- VISU::Prs3d_i* aPrs3d = GetPrsToModify(this);
- if(!aPrs3d)
- return;
- VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d);
- if(!anActor)
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
return;
+
VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
VISU::DeformedShape_i* aDeformedShape = dynamic_cast<VISU::DeformedShape_i*>(aPrs3d);
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnChangeWireframeColor()
{
- SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if(!aViewWindow)
- return;
- VISU::Prs3d_i* aPrs3d = GetPrsToModify(this);
- if(!aPrs3d)
- return;
- VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d);
- if(!anActor)
- return;
- if(aPrs3d->GetType() != VISU::TMESH)
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
return;
+
VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
if(!aMesh)
return;
+
SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
QColor aColor (int(255*anOldColor.R),
int(255*anOldColor.G),
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnChangeOpacity()
{
- SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if(!aViewWindow)
- return;
- VISU::Prs3d_i* aPrs3d = GetPrsToModify(this);
- if(!aPrs3d)
- return;
- VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d);
- if(!anActor)
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
return;
+
VisuGUI_TransparencyDlg* aDialog = new VisuGUI_TransparencyDlg( this );
aDialog->show();
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnChangeLines()
{
- SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if(!aViewWindow)
- return;
- VISU::Prs3d_i* aPrs3d = GetPrsToModify(this);
- if(!aPrs3d)
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
return;
- VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d);
- if(!anActor)
- return;
-
+
VisuGUI_CursorDlg* CursorDlg =
new VisuGUI_CursorDlg (GetDesktop(this), tr("DLG_LINEWIDTH_TITLE"), TRUE);
delete CursorDlg;
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnShowTable()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(SObject) SO;
- if ( !CORBA::is_nil( anObject ) ) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
- if ( !CORBA::is_nil( aVisuObj ) && aVisuObj->GetType() == VISU::TTABLE ) {
- CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject );
- if( !CORBA::is_nil( aTable ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>( VISU::GetServant(aTable).in() );
- if ( table ) {
- SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( table->GetObjectEntry() );
- }
- }
- }
- } else {
- // possibly this is Table SObject
- SO = GetCStudy( GetAppStudy( this ) )->FindObjectID( anIO->getEntry() );
- }
-
- if( !IsSObjectTable( SO ) )
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aSObject = GetCStudy( GetAppStudy( this ) )->FindObjectID( aTable->GetObjectEntry() );
+
+ if( !IsSObjectTable( aSObject ) )
return;
VisuGUI_TableDlg* dlg = new VisuGUI_TableDlg( GetDesktop( this ),
- SO,
+ aSObject,
false,
//SAL2670 Orientation of show tables
VisuGUI_TableDlg::ttAuto,
dlg->show();
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnCreateTable()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
- _PTR(SObject) aSObject = aStudy->FindObjectID(anIO->getEntry());
- VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject );
- if(!aCutLines->_is_nil() || IsSObjectTable(aSObject)) {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+
+ if((aBase && aBase->GetType() == VISU::TCUTLINES) || IsSObjectTable(aSObject)) {
GetVisuGen( this )->CreateTable( aSObject->GetID().c_str() );
UpdateObjBrowser(this);
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnDeleteObjects()
aStudyBuilder->NewCommand();
for (i = 0; i < nbSelected; i++) {
- _PTR(SObject) aSObject = aCStudy->FindObjectID(entries[i]);
- if (aSObject) {
- _PTR(SObject) aRefObj;
- if (aSObject->ReferencedObject(aRefObj)) {
- // It can be a reference on curve, published under a container.
- // In this case the curve should be removed from the container.
- // See bug 10441.
- CORBA::Object_var aCorbaObj = VISU::GetSelectedObj(anAppStudy, aRefObj->GetID().c_str());
- if (!CORBA::is_nil(aCorbaObj)) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(aCorbaObj);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TMESH)
- {
- DeleteSObject(this, aCStudy, aRefObj);
- UpdateObjBrowser(this, true, aRefObj);
+ VISU::TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(this), entries[i]);
+ if(_PTR(SObject) aSObject = anObjectInfo.mySObject){
+ _PTR(SObject) aRefSObject;
+ if (aSObject->ReferencedObject(aRefSObject)) {
+ // It can be a reference on curve, published under a container.
+ // In this case the curve should be removed from the container.
+ // See bug 10441.
+ VISU::TObjectInfo aRefObjectInfo = GetObjectByEntry(GetAppStudy(this), aRefSObject->GetID());
+ VISU::Base_i* aRefBase = aRefObjectInfo.myBase;
+ if(aRefBase && aRefBase->GetType() == VISU::TMESH){
+ DeleteSObject(this, aCStudy, aRefSObject);
+ UpdateObjBrowser(this, true, aRefSObject);
+ }else if(aRefBase && aRefBase->GetType() == VISU::TCURVE){
+ CORBA::Object_var anObject = ClientSObjectToObject(aRefSObject);
+ VISU::Curve_var aCurve = VISU::Curve::_narrow(anObject);
+ _PTR(SObject) aParentSO = aSObject->GetFather();
+ VISU::TObjectInfo aParentObjectInfo = GetObjectByEntry(GetAppStudy(this), aParentSO->GetID());
+ if(VISU::Base_i* aParentBase = aParentObjectInfo.myBase){
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aParentBase)){
+ if(aContainer->GetNbCurves() > 0){
+ aContainer->RemoveCurve(aCurve);
+ UpdateObjBrowser(this, true, aParentSO);
+ }
+ }
}
- else if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
- VISU::Curve_ptr aCurve = VISU::Curve::_narrow(aVisuObj);
- _PTR(SObject) aParentSO = aSObject->GetFather();
- aCorbaObj = VISU::GetSelectedObj(anAppStudy, aParentSO->GetID().c_str());
- if (!CORBA::is_nil(aCorbaObj) && !CORBA::is_nil(aCurve)) {
- aVisuObj = VISU::Base::_narrow(aCorbaObj);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
- // Container object
- CORBA::Object_ptr aCnt = VISU::Container::_narrow(aVisuObj);
- if (!CORBA::is_nil(aCnt)) {
- VISU::Container_i* aContainer =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
- if (aContainer && aContainer->GetNbCurves() > 0) {
- aContainer->RemoveCurve(aCurve);
- UpdateObjBrowser(this, true, aParentSO);
- }
- }
- }
- }
- }
- }
- } else {
- DeleteSObject(this, aCStudy, aSObject);
- UpdateObjBrowser(this, true, aSObject);
+ }
+ }else{
+ DeleteSObject(this, aCStudy, aSObject);
+ UpdateObjBrowser(this, true, aSObject);
}
}
}
mgr->clearSelected();
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnPlotData()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO );
- _PTR(SObject) SO;
- _PTR(GenericAttribute) anAttr;
- _PTR(AttributeName) aName;
- QString SOName;
- _PTR(Study) aStudy = GetCStudy( GetAppStudy( this ) );
-
- if ( !CORBA::is_nil( anObject ) ) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) {
- // Table (VISU object) is selected
- CORBA::Object_ptr aTbl = VISU::Table::_narrow( anObject );
- if( !CORBA::is_nil( aTbl ) ) {
- VISU::Table_i* table = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTbl).in());
- if ( table ) {
- _PTR(SObject) SO = aStudy->FindObjectID( table->GetObjectEntry() );
- if ( IsSObjectTable(SO) ) {
- // get name of SObject
- if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = anAttr;
- SOName = QString( aName->Value().c_str() );
- }
- VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
- if ( dlg->exec() == QDialog::Accepted ) {
- if ( !IsStudyLocked( aStudy ) ) {
- // if study is not locked - create new container, create curves and insert them
- // into container, then plot container if current viewer is of VIEW_PLOT2D type
- int horIndex;
- QValueList<int> verIndices, zIndices;
- dlg->getCurvesSource( horIndex, verIndices, zIndices );
- if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
- if( !CORBA::is_nil( aContainer ) ) {
- VISU::Container_i* pContainer =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
- if ( pContainer ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve =
- GetVisuGen(this)->CreateCurveWithZ( table->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv =
- dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
- line, lineWidth, color) && !isAuto ) {
- SALOMEDS::Color c;
- c.R = color.red() /255.;
- c.G = color.green()/255.;
- c.B = color.blue() /255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- UpdateObjBrowser(this);
- PlotContainer( this, pContainer, VISU::eDisplay );
- }
- }
- }
- }
- else {
- // if study is locked just get curves info and plot them
- // if current viewer is of VIEW_PLOT2D type
- QPtrList<Plot2d_Curve> container;
- dlg->getCurves( container );
- if ( !container.isEmpty() ) {
- GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
- GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
- }
- }
- }
- delete dlg;
- }
- }
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ if(aBase->GetType() == VISU::TTABLE) {
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase)){
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ _PTR(SObject) aSObject = aStudy->FindObjectID( aTable->GetObjectEntry() );
+ if(IsSObjectTable(aSObject)){
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ if(aDlg->exec() == QDialog::Accepted){
+ if(!IsStudyLocked(aStudy)){
+ // if study is not locked - create new container, create curves and insert them
+ // into container, then plot container if current viewer is of VIEW_PLOT2D type
+ int horIndex;
+ QValueList<int> verIndices, zIndices;
+ aDlg->getCurvesSource( horIndex, verIndices, zIndices );
+ if( horIndex >= 0 && verIndices.count() > 0 ){
+ CORBA::Object_var aContainerObj = GetVisuGen(this)->CreateContainer();
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObj).in())){
+ for( int i = 0; i < verIndices.count(); i++ ){
+ VISU::Curve_var aCurveObject =
+ GetVisuGen(this)->CreateCurveWithZ(aTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto )
+ {
+ SALOMEDS::Color c;
+ c.R = color.red() /255.;
+ c.G = color.green()/255.;
+ c.B = color.blue() /255.;
+ aCurve->SetColor( c );
+ aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
+ aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ aContainer->AddCurve(aCurveObject);
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ }
+ }
+ } else {
+ // get name of SObject
+ QString aSObjectName;
+ _PTR(GenericAttribute) anAttr;
+ if(aSObject->FindAttribute( anAttr, "AttributeName" )){
+ _PTR(AttributeName) aName = anAttr;
+ aSObjectName = QString( aName->Value().c_str() );
+ }
+ // if study is locked just get curves info and plot them
+ // if current viewer is of VIEW_PLOT2D type
+ QPtrList<Plot2d_Curve> container;
+ aDlg->getCurves( container );
+ if ( !container.isEmpty() ) {
+ GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
+ }
+ }
+ }
+ delete aDlg;
+ }
}
}
- }
- else if ( !anIO.IsNull() ) {
+ }else if(!aSelectionItem.myIO.IsNull()){
// check if Table SObject is selected
- SO = aStudy->FindObjectID( anIO->getEntry() );
- if ( IsSObjectTable(SO) ) {
- // get name of SObject
- if ( SO->FindAttribute( anAttr, "AttributeName" ) ) {
- aName = anAttr;
- SOName = QString( aName->Value().c_str() );
- }
- VisuGUI_SetupPlot2dDlg* dlg = new VisuGUI_SetupPlot2dDlg( SO, GetDesktop( this ) );
- if ( dlg->exec() == QDialog::Accepted ) {
- if ( !IsStudyLocked( aStudy ) ) {
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(IsSObjectTable(aSObject)){
+ VisuGUI_SetupPlot2dDlg* aDlg = new VisuGUI_SetupPlot2dDlg(aSObject, GetDesktop(this));
+ if(aDlg->exec() == QDialog::Accepted){
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(this));
+ if(!IsStudyLocked(aStudy)){
// if study is not locked - create new table and container objects, create curves
// and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type
int horIndex;
QValueList<int> verIndices, zIndices;
- dlg->getCurvesSource( horIndex, verIndices, zIndices );
+ aDlg->getCurvesSource( horIndex, verIndices, zIndices );
if ( horIndex >= 0 && verIndices.count() > 0 ) {
- CORBA::Object_var aTable = GetVisuGen(this)->CreateTable( SO->GetID().c_str() );
- CORBA::Object_var aContainer = GetVisuGen(this)->CreateContainer();
- if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
- VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
- VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
-
- if ( pContainer && pTable ) {
- for ( int i = 0; i < verIndices.count(); i++ ) {
- CORBA::Object_var aNewCurve = GetVisuGen(this)->CreateCurveWithZ
- ( pTable->_this(), horIndex+1, verIndices[i]+1, zIndices[i]+1 );
- if( !CORBA::is_nil( aNewCurve ) ) {
- VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aNewCurve).in());
- if ( pCrv ) {
- bool isAuto;
- int marker, line, lineWidth;
- QColor color;
- if ( dlg->getCurveAttributes(verIndices[i], isAuto, marker,
- line, lineWidth, color) && !isAuto ) {
- SALOMEDS::Color c;
- c.R = color.red()/255.;
- c.G = color.green()/255.;
- c.B = color.blue()/255.;
- pCrv->SetColor( c );
- pCrv->SetMarker( ( VISU::Curve::MarkerType )marker );
- pCrv->SetLine( ( VISU::Curve::LineType )line, lineWidth );
- }
- pContainer->AddCurve( pCrv->_this() );
- }
- }
- }
- UpdateObjBrowser(this);
- PlotContainer( this, pContainer, VISU::eDisplay );
- }
- }
- }
+ VISU::Table_var aTableObject = GetVisuGen(this)->CreateTable(aSObject->GetID().c_str());
+ if(!CORBA::is_nil(aTableObject)){
+ VISU::Container_var aContainerObject = GetVisuGen(this)->CreateContainer();
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainerObject).in());
+ for ( int i = 0; i < verIndices.count(); i++ ) {
+ VISU::Curve_var aCurveObject = GetVisuGen(this)->CreateCurveWithZ
+ ( aTableObject, horIndex+1, verIndices[i]+1, zIndices[i]+1 );
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurveObject).in())){
+ bool isAuto;
+ int marker, line, lineWidth;
+ QColor color;
+ if ( aDlg->getCurveAttributes(verIndices[i], isAuto, marker,
+ line, lineWidth, color) && !isAuto )
+ {
+ SALOMEDS::Color c;
+ c.R = color.red()/255.;
+ c.G = color.green()/255.;
+ c.B = color.blue()/255.;
+ aCurve->SetColor( c );
+ aCurve->SetMarker( ( VISU::Curve::MarkerType )marker );
+ aCurve->SetLine( ( VISU::Curve::LineType )line, lineWidth );
+ }
+ aContainerObject->AddCurve(aCurveObject);
+ }
+ }
+ UpdateObjBrowser(this);
+ PlotContainer( this, aContainer, VISU::eDisplay );
+ }
+ }
} else {
+ // get name of SObject
+ QString aSObjectName;
+ _PTR(GenericAttribute) anAttr;
+ if(aSObject->FindAttribute(anAttr, "AttributeName")){
+ _PTR(AttributeName) aName = anAttr;
+ aSObjectName = QString( aName->Value().c_str() );
+ }
// if study is locked just get curves info and plot them
QPtrList<Plot2d_Curve> container;
- dlg->getCurves( container );
+ aDlg->getCurves( container );
if ( !container.isEmpty() ) {
GetPlot2dViewer( this )->getActiveViewFrame()->displayCurves( container, true );
- GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( SOName );
+ GetPlot2dViewer( this )->getActiveViewFrame()->setTitle( aSObjectName );
}
}
}
- delete dlg;
+ delete aDlg;
}
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnCurveProperties()
{
- LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
- SALOME_ListIO aListIO;
- aSelectionMgr->selectedObjects(aListIO);
- if (aListIO.Extent() != 1) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.size() != 1)
+ return;
- SalomeApp_Study* aAppStudy = GetAppStudy(this);
- const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
- CORBA::Object_var anObject = GetSelectedObj( aAppStudy, anIO->getEntry() );
- if (CORBA::is_nil( anObject )) return;
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) {
+ if(aBase->GetType() == VISU::TCURVE) {
// Curve object
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject );
- if( !CORBA::is_nil( aCurve ) ) {
- VISU::Curve_i* aDSCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
- if ( aDSCurve && (!IsStudyLocked( GetCStudy(aAppStudy) )) ) {
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase)){
+ if(!IsStudyLocked(GetCStudy(GetAppStudy(this)))){
Plot2d_SetupCurveDlg aDlg(GetDesktop( this ));
- aDlg.setLine( (int)aDSCurve->GetLine(), aDSCurve->GetLineWidth() );
- aDlg.setMarker( (int)aDSCurve->GetMarker() );
- SALOMEDS::Color aColor = aDSCurve->GetColor();
+ aDlg.setLine( (int)aCurve->GetLine(), aCurve->GetLineWidth() );
+ aDlg.setMarker( (int)aCurve->GetMarker() );
+ SALOMEDS::Color aColor = aCurve->GetColor();
aDlg.setColor( QColor( (int)(aColor.R*255.), (int)(aColor.G*255.), (int)(aColor.B*255.) ) );
if( aDlg.exec() == QDialog::Accepted ) {
- aDSCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
- aDSCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
+ aCurve->SetLine( (VISU::Curve::LineType)aDlg.getLine(), aDlg.getLineWidth() );
+ aCurve->SetMarker( (VISU::Curve::MarkerType)aDlg.getMarker());
SALOMEDS::Color newColor;
newColor.R = aDlg.getColor().red()/255.;
newColor.G = aDlg.getColor().green()/255.;
newColor.B = aDlg.getColor().blue()/255.;
- aDSCurve->SetColor( newColor );
- PlotCurve(this, aDSCurve, VISU::eDisplay);
+ aCurve->SetColor( newColor );
+ PlotCurve(this, aCurve, VISU::eDisplay);
}
}
}
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnClearContainer()
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (anIO.IsNull() || CORBA::is_nil(anObject))
+
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
return;
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) {
+ if(aBase->GetType() == VISU::TCONTAINER){
// Container object
- CORBA::Object_ptr aCnt = VISU::Container::_narrow(anObject);
- if (!CORBA::is_nil(aCnt)) {
- VISU::Container_i* container = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCnt).in());
- if (container && container->GetNbCurves() > 0) {
- container->Clear();
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase)){
+ if(aContainer && aContainer->GetNbCurves() > 0){
+ aContainer->Clear();
UpdateObjBrowser(this);
}
}
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnEditContainer()
{
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aServant.in());
- if (!aContainer) return;
+ VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase);
+ if(!aContainer)
+ return;
VisuGUI_EditContainerDlg* aDlg = new VisuGUI_EditContainerDlg (this);
aDlg->initFromPrsObject(aContainer);
delete aDlg;
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnSaveViewParams()
UpdateObjBrowser(this);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnRestoreViewParams()
VISU::View3D_i::RestoreViewParams(aViewMgr, aSObj->GetName().c_str());//jfa tmp
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnRename()
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
-
- _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
- if (!aSObj) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ if(!aSObject)
+ return;
//TEST DU PARENT == VISU
_PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder();
- _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObj, "AttributeName");
+ _PTR(GenericAttribute) anAttr = aBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
if (anAttr) {
_PTR(AttributeName) aName (anAttr);
QString Name = VisuGUI_NameDlg::getName( GetDesktop( this ), aName->Value().c_str() );
QApplication::setOverrideCursor(Qt::waitCursor);
// rename specific objects
- if (!CORBA::is_nil(anObject)) {
- VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject);
- if (!CORBA::is_nil(aVisuObj)) {
- switch (aVisuObj->GetType()) {
- case VISU::TCURVE: // Curve object
- {
- CORBA::Object_ptr aCurve = VISU::Curve::_narrow(anObject);
- if (!CORBA::is_nil(aCurve)) {
- VISU::Curve_i* curve =
- dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCurve).in());
- if (curve)
- curve->SetName(Name.latin1(), true);
- }
- break;
- }
- case VISU::TTABLE: // Table object
- {
- CORBA::Object_ptr aTable = VISU::Table::_narrow(anObject);
- if (!CORBA::is_nil(aTable)) {
- VISU::Table_i* table =
- dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
- if (table)
- table->SetName(Name.latin1(), true);
- }
- break;
- }
- case VISU::TCONTAINER: // Container object
- {
- CORBA::Object_ptr aContainer = VISU::Container::_narrow(anObject);
- if (!CORBA::is_nil(aContainer)) {
- VISU::Container_i* container =
- dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
- if (container)
- container->SetName(Name.latin1(), true);
- }
- break;
- }
- default:
- {
- }
- }
- }
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ switch(aBase->GetType()){
+ case VISU::TCURVE: { // Curve object
+ if(VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(aBase))
+ aCurve->SetName(Name.latin1(), true);
+ break;
+ }
+ case VISU::TTABLE: { // Table object
+ if(VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(aBase))
+ aTable->SetName(Name.latin1(), true);
+ break;
+ }
+ case VISU::TCONTAINER: { // Container object
+ if(VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(aBase))
+ aContainer->SetName(Name.latin1(), true);
+ break;
+ }
+ default: {
+ }}
}
+ }
- // rename the study object
- aName->SetValue(Name.latin1()); // rename the SObject
- anIO->setName(Name.latin1()); // rename the InteractiveObject
+ // rename the study object
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ aName->SetValue(Name.latin1()); // rename the SObject
+ anIO->setName(Name.latin1()); // rename the InteractiveObject
- ViewManagerList pvm_list;
- getApp()->viewManagers( SPlot2d_Viewer::Type(), pvm_list );
- for( SUIT_ViewManager* mgr = pvm_list.first(); mgr; mgr = pvm_list.next() )
- {
- Plot2d_ViewManager* pvm = dynamic_cast<Plot2d_ViewManager*>( mgr );
- if( pvm )
- {
- SPlot2d_Viewer* pv = dynamic_cast<SPlot2d_Viewer*>( pvm->getViewModel() );
- if( pv )
- pv->renameAll( anIO, Name.latin1() );
- }
+ ViewManagerList aViewManagerList;
+ getApp()->viewManagers(SPlot2d_Viewer::Type(), aViewManagerList);
+ SUIT_ViewManager* aViewManager = aViewManagerList.first();
+ for(; aViewManager; aViewManager = aViewManagerList.next()){
+ if(Plot2d_ViewManager* aManager = dynamic_cast<Plot2d_ViewManager*>(aViewManager)){
+ if(SPlot2d_Viewer* aViewer = dynamic_cast<SPlot2d_Viewer*>(aManager->getViewModel()))
+ aViewer->renameAll( anIO, Name.latin1() );
}
+ }
- UpdateObjBrowser(this, false);
+ UpdateObjBrowser(this, false);
- QApplication::restoreOverrideCursor();
- }
+ QApplication::restoreOverrideCursor();
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnClippingPlanes()
new VisuGUI_ClippingDlg (this, "", false);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnSweep()
{
- SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(this);
- if(!aViewWindow)
- return;
- VISU::Prs3d_i* aPrs3d = GetPrsToModify(this);
- if(!aPrs3d)
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo(this, aPrs3d, aViewWindow, anActor))
return;
+
VISU::ScalarMap_i* aScalarMap = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
if(!aScalarMap)
return;
- VISU_Actor* anActor = VISU::FindActor(aViewWindow, aPrs3d);
- if(!anActor)
- return;
+
if(!anActor->GetVisibility())
anActor->VisibilityOn();
QApplication::restoreOverrideCursor();
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnTimeAnimation()
else delete aAnimationDlg;
}
-//************************************************************************
+//----------------------------------------------------------------------------
void
VisuGUI
::OnShowAnimation()
aAnimationDlg->show();
}
-//----------------------------------------------------------------------------
-template<unsigned int colored_prs3d_type_enum>
-void
-DoSameAs(VISU::Prs3d_i* thePrs3d)
-{
- typedef typename TL::TColoredEnum2Type<colored_prs3d_type_enum>::TResult TColoredPrs3d;
- TColoredPrs3d* aColoredPrs3d = dynamic_cast<TColoredPrs3d*>(thePrs3d);
- TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(VISU::ColoredPrs3d_i::EPublishUnderTimeStamp);
- aSameColoredPrs3d->SetCResult(aColoredPrs3d->GetCResult());
- aSameColoredPrs3d->SetMeshName(aColoredPrs3d->GetCMeshName().c_str());
- aSameColoredPrs3d->SetEntity(aColoredPrs3d->GetEntity());
- aSameColoredPrs3d->SetFieldName(aColoredPrs3d->GetCFieldName().c_str());
- aSameColoredPrs3d->SetTimeStampNumber(aColoredPrs3d->GetTimeStampNumber());
- aSameColoredPrs3d->SameAs(aColoredPrs3d);
-}
-
//----------------------------------------------------------------------------
void
VisuGUI
if (CheckLock(aCStudy,GetDesktop(this)))
return;
- Handle(SALOME_InteractiveObject) anIO;
- CORBA::Object_var anObject = GetSelectedObj(this, &anIO);
- if (CORBA::is_nil(anObject)) return;
- PortableServer::ServantBase_var aServant = VISU::GetServant(anObject);
- if (!aServant.in()) return;
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase;
+ if(!aBase)
+ return;
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
- if (!aPrsObject) return;
+ VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dToModify(this, aBase);
+ if(!aPrs3d)
+ return;
- switch (aPrsObject->GetType()) {
- case VISU::TMESH:
- {
- VISU::Mesh_i* aPrs = dynamic_cast<VISU::Mesh_i*>(aPrsObject);
- VISU::Mesh_i* aSamePrs = new VISU::Mesh_i(aPrs->GetCResult());
- aSamePrs->SameAs(aPrs);
+ if(aBase->GetType() != VISU::TMESH){
+ VISU::ColoredPrs3d_i* aColoredPrs3d = dynamic_cast<VISU::ColoredPrs3d_i*>(aBase);
+ switch (aBase->GetType()) {
+ case VISU::TSCALARMAP:
+ TSameAsFactory<VISU::TSCALARMAP>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TDEFORMEDSHAPE:
+ TSameAsFactory<VISU::TDEFORMEDSHAPE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TSCALARMAPONDEFORMEDSHAPE:
+ TSameAsFactory<VISU::TSCALARMAPONDEFORMEDSHAPE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TCUTPLANES:
+ TSameAsFactory<VISU::TCUTPLANES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TCUTLINES:
+ TSameAsFactory<VISU::TCUTLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TISOSURFACE:
+ TSameAsFactory<VISU::TISOSURFACE>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TSTREAMLINES:
+ TSameAsFactory<VISU::TSTREAMLINES>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TVECTORS:
+ TSameAsFactory<VISU::TVECTORS>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
+ case VISU::TPLOT3D:
+ TSameAsFactory<VISU::TPLOT3D>().Create(aColoredPrs3d, ColoredPrs3d_i::EPublishUnderTimeStamp);
+ break;
}
- break;
- case VISU::TSCALARMAP:
- DoSameAs<VISU::TSCALARMAP>(aPrsObject);
- break;
- case VISU::TDEFORMEDSHAPE:
- DoSameAs<VISU::TDEFORMEDSHAPE>(aPrsObject);
- break;
- case VISU::TSCALARMAPONDEFORMEDSHAPE:
- DoSameAs<VISU::TSCALARMAPONDEFORMEDSHAPE>(aPrsObject);
- break;
- case VISU::TCUTPLANES:
- DoSameAs<VISU::TCUTPLANES>(aPrsObject);
- break;
- case VISU::TCUTLINES:
- DoSameAs<VISU::TCUTLINES>(aPrsObject);
- break;
- case VISU::TISOSURFACE:
- DoSameAs<VISU::TISOSURFACE>(aPrsObject);
- break;
- case VISU::TSTREAMLINES:
- DoSameAs<VISU::TSTREAMLINES>(aPrsObject);
- break;
- case VISU::TVECTORS:
- DoSameAs<VISU::TVECTORS>(aPrsObject);
- break;
- case VISU::TPLOT3D:
- DoSameAs<VISU::TPLOT3D>(aPrsObject);
- break;
+ UpdateObjBrowser(this);
}
- UpdateObjBrowser(this);
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnSelectionInfo()
tr("BUT_OK") );
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnMergeScalarBars()
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnFreeScalarBars()
}
}
+//----------------------------------------------------------------------------
void
VisuGUI
::OnTranslatePrs()
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if (anIO->hasEntry()) {
QString anEntry(anIO->getEntry());
- CORBA::Object_var anObject = VISU::GetSelectedObj(aStudy, anEntry);
- if(VISU::Prs3d_i* aPrsObject = VISU::GetPrsToModify(anObject))
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, anEntry);
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase))
aDlg->addPresentation(aPrsObject);
}
}
if (isExist && aType == VISU::TCURVE) {
isCurves = true;
} else {
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- if (!CORBA::is_nil(anObject)) {
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if (aPrsObject) {
- if (aPrsObject->GetType() == VISU::TCUTPLANES) {
- VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- if (aCutPrs) {
- isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
- }
- }
- }
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
+ if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+ VISU::CutPlanes_i* aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+ if (aCutPrs) {
+ isOneCutPlane = aCutPrs->GetNbPlanes() == 1;
+ }
+ }
}
}
}
if (isOneCutPlane)
action( VISU_PLOT3D_FROM_CUTPLANE )->addTo(theMenu);
- Handle(SALOME_InteractiveObject) anIO;
- VISU::Storable::TRestoringMap aMap;
- CORBA::Object_var anObject = GetSelectedObj( this, &anIO, &aMap);
-
- if (!CORBA::is_nil(anObject)) {
- VISU::Base_i* aBase = dynamic_cast<VISU::Base_i*>(VISU::GetServant(anObject).in());
- if (aBase && aBase->GetType() == VISU::TCOLOREDPRS3DCACHE)
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ Handle(SALOME_InteractiveObject) anIO = aSelectionItem.myIO;
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(aSObject);
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+
+ if(VISU::Base_i* aBase = aSelectionItem.myObjectInfo.myBase){
+ if(aBase->GetType() == VISU::TCOLOREDPRS3DCACHE)
action( VISU_CACHE_PROPERTIES )->addTo(theMenu);
}
}
// Check single selection
- if (aListIO.Extent() != 1) return;
-
- _PTR(SObject) SO = aCStudy->FindObjectID(anIO->getEntry());
- if ( !SO )
+ if (aListIO.Extent() != 1)
return;
+
bool isExist;
VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt();
action( VISU_SHOW_ANIMATION )->addTo(theMenu);
} else if (isOBClient) {
- if (IsSObjectTable(SO)) {
+ if (IsSObjectTable(aSObject)) {
action( VISU_SHOW_TABLE )->addTo(theMenu);
action( VISU_CREATE_CURVES )->addTo(theMenu);
action( VISU_EXPORT_TABLE )->addTo(theMenu);
action( VISU_IMPORT_MED_TIMESTAMP )->addTo(theMenu); // "Import TimeStamp"
}
} else {
- _PTR(SObject) aSFather = SO->GetFather();
+ _PTR(SObject) aSFather = aSObject->GetFather();
if (aSFather) {
_PTR(GenericAttribute) anAttr;
aSFather->FindAttribute(anAttr, "AttributeName");
aSObject = aCStudy->FindObjectID(anIO->getEntry());
if ( !aSObject )
continue;
- CORBA::Object_var anObject = GetSelectedObj(GetAppStudy(this), anIO->getEntry());
- if (!CORBA::is_nil(anObject)) {
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if (aPrsObject->GetType() == VISU::TCUTPLANES) {
- aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
- if (aCutPrs)
- break;
- }
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(this), anIO->getEntry());
+ if(VISU::Prs3d_i* aPrsObject = VISU::GetPrs3dFromBase(anObjectInfo.myBase)){
+ if (aPrsObject->GetType() == VISU::TCUTPLANES) {
+ aCutPrs = dynamic_cast<VISU::CutPlanes_i*>(aPrsObject);
+ if (aCutPrs)
+ break;
+ }
}
}
}
void VisuGUI::OnCacheProperties()
{
- CORBA::Object_var anObject = GetSelectedObj(this);
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(this);
+ if(aSelectionInfo.empty())
+ return;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ _PTR(SObject) aSObject = aSelectionItem.myObjectInfo.mySObject;
+
+ CORBA::Object_var anObject = VISU::ClientSObjectToObject(aSObject);
+ if( CORBA::is_nil( anObject ) )
+ return;
+
VISU::ColoredPrs3dCache_var aCache = VISU::GetInterface<VISU::ColoredPrs3dCache>(anObject);
if( CORBA::is_nil( aCache ) )
return;
QString VisuGUI_Selection::type( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- CORBA::Object_var anObject = GetSelectedObj( aStudy, entry( ind ), &aMap );
- VISU::Base_var aVisuObj = VISU::Base::_narrow( anObject );
- if ( !CORBA::is_nil( aVisuObj ) ){
- VISU::VISUType aType = aVisuObj->GetType();
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
+ VISU::Base_i* aBase = anObjectInfo.myBase;
+ if(aBase){
+ VISU::VISUType aType = aBase->GetType();
if(aType == VISU::TCOLOREDPRS3DHOLDER){
- VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(aVisuObj);
+ CORBA::Object_var anObject = ClientSObjectToObject(anObjectInfo.mySObject);
+ VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(anObject);
aType = aHolder->GetPrsType();
}
switch (aType) {
QString VisuGUI_Selection::nbComponents( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- GetSelectedObj( aStudy, entry( ind ), &aMap );
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
- const QString& aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
+ QString aVal = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist);
if ( isExist )
aResStr = aVal;
return aResStr;
QString VisuGUI_Selection::medEntity( const int ind ) const
{
+ SalomeApp_Study* aStudy = GetStudy();
+ if ( !aStudy )
+ return QString();
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
- VISU::Storable::TRestoringMap aMap;
- GetSelectedObj( GetStudy(), entry( ind ), &aMap );
- const QString& aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist);
+ QString aVal = VISU::Storable::FindValue(aMap,"myEntityId",&isExist);
if ( isExist ) {
using namespace VISU;
TEntity anEntityId = TEntity(aVal.toInt());
QString VisuGUI_Selection::nbTimeStamps( const int ind ) const
{
QString aResStr;
- VISU::Storable::TRestoringMap aMap;
SalomeApp_Study* aStudy = GetStudy();
if ( !aStudy )
return aResStr;
- GetSelectedObj( aStudy, entry( ind ), &aMap );
+
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(aStudy, entry( ind ));
+ VISU::Storable::TRestoringMap aMap = VISU::GetStorableMap(anObjectInfo.mySObject);
+
bool isExist;
const QString& aVal = VISU::Storable::FindValue(aMap,"myNbTimeStamps",&isExist);
if ( isExist )
return aResStr;
}
-QString VisuGUI_Selection::representation( const int ind ) const
-{
- QString aResStr;
- if (SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule)) {
- if (VISU_Actor* anVISUActor = FindActor(aView, entry(ind).latin1())) {
- int aRepresent = anVISUActor->GetRepresentation();
- switch (aRepresent) {
- ENUM2STRING( aResStr, VISU::POINT );
- ENUM2STRING( aResStr, VISU::WIREFRAME );
- ENUM2STRING( aResStr, VISU::SHADED );
- ENUM2STRING( aResStr, VISU::INSIDEFRAME );
- ENUM2STRING( aResStr, VISU::SURFACEFRAME );
- }
+//----------------------------------------------------------------------------
+template<class TPopupFunctor>
+struct TPopupDispatcher
+{
+ QString
+ operator()(const SalomeApp_Module* theModule,
+ const QString& theEntry)
+ {
+ if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
+ QString aType = aViewManager->getType();
+ TPopupFunctor aFunctor;
+ if(aType == SVTK_Viewer::Type())
+ return aFunctor.template Get<SVTK_Viewer>(theModule, theEntry);
+ else if(aType == VVTK_Viewer::Type())
+ return aFunctor.template Get<VVTK_Viewer>(theModule, theEntry);
}
+ return QString();
+ }
+};
+
+
+//----------------------------------------------------------------------------
+template<class TViewer>
+bool
+GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ const QString& theEntry,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+{
+ VISU::TObjectInfo anObjectInfo = VISU::GetObjectByEntry(GetAppStudy(theModule), theEntry);
+ thePrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ typedef typename TViewer::TViewWindow TViewWindow;
+ theViewWindow = GetActiveViewWindow<TViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
+}
+
+
+//----------------------------------------------------------------------------
+struct TViewFunctor
+{
+ template<class TViewer>
+ QString
+ Get(const SalomeApp_Module* theModule,
+ const QString& theEntry)
+ {
+ VISU_Actor* anActor = NULL;
+ VISU::Prs3d_i* aPrs3d = NULL;
+ SVTK_ViewWindow* aViewWindow = NULL;
+ if(!GetPrs3dSelectionInfo<TViewer>(theModule, theEntry, aPrs3d, aViewWindow, anActor))
+ return QString();
+
+ return get(aPrs3d, aViewWindow, anActor);
+ }
+
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return QString();
}
+};
- return aResStr;
+
+//----------------------------------------------------------------------------
+struct TGetRepesentationFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ QString aResStr;
+ switch (theActor->GetRepresentation()) {
+ ENUM2STRING( aResStr, VISU::POINT );
+ ENUM2STRING( aResStr, VISU::WIREFRAME );
+ ENUM2STRING( aResStr, VISU::SHADED );
+ ENUM2STRING( aResStr, VISU::INSIDEFRAME );
+ ENUM2STRING( aResStr, VISU::SURFACEFRAME );
+ }
+ return aResStr;
+ }
+};
+
+QString VisuGUI_Selection::representation( const int ind ) const
+{
+ return TPopupDispatcher<TGetRepesentationFunctor>()(myModule, entry(ind));
}
+//----------------------------------------------------------------------------
SalomeApp_Study* VisuGUI_Selection::GetStudy() const
{
return dynamic_cast<SalomeApp_Study*>( aLightStudy );
}
+//----------------------------------------------------------------------------
int VisuGUI_Selection::nbChild( const int ind, const bool named ) const
{
int cnt = 0;
return cnt;
}
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::nbChildren( const int ind ) const
{
QString aResStr;
return aResStr;
}
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::nbNamedChildren( const int ind ) const
{
QString aResStr;
return aResStr;
}
-namespace
-{
- struct TIsVisibleFunctor
- {
- template<class TViewer>
- QString
- Get(VisuGUI* theModule,
- const QString& theEntry)
- {
- typedef typename TViewer::TViewWindow TViewWindow;
- if (TViewWindow* aViewWindow = GetActiveViewWindow<TViewWindow>(theModule))
- if (VISU_Actor* anActor = FindActor(aViewWindow,theEntry.latin1()))
- return anActor->GetVisibility() ? "true" : "false";
-
- return QString();
- }
- };
- template<class TPopupFunctor>
- struct TPopupDispatcher
+//----------------------------------------------------------------------------
+struct TIsVisibleFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
{
- QString
- operator()(VisuGUI* theModule,
- const QString& theEntry)
- {
- if(SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager()){
- QString aType = aViewManager->getType();
- TPopupFunctor aFunctor;
- if(aType == SVTK_Viewer::Type())
- return aFunctor.template Get<SVTK_Viewer>(theModule,theEntry);
- else if(aType == VVTK_Viewer::Type())
- return aFunctor.template Get<VVTK_Viewer>(theModule,theEntry);
- }
- return QString();
- }
- };
-}
+ return theActor->GetVisibility() ? "true" : "false";
+ }
+};
QString VisuGUI_Selection::isVisible( const int ind ) const
{
- return TPopupDispatcher<TIsVisibleFunctor>()((VisuGUI*)myModule,entry(ind));
+ return TPopupDispatcher<TIsVisibleFunctor>()(myModule, entry(ind));
}
-QString VisuGUI_Selection::isShrunk( const int ind ) const
-{
- QString aResStr;
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- if ( anVISUActor->IsShrunkable() )
- aResStr = anVISUActor->IsShrunk() ? "1" : "0";
+//----------------------------------------------------------------------------
+struct TIsShrunkFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return theActor->IsShrunk() ? "1" : "0";
+ }
+};
- return aResStr;
+QString VisuGUI_Selection::isShrunk( const int ind ) const
+{
+ return TPopupDispatcher<TIsShrunkFunctor>()(myModule, entry(ind));
}
+
+//----------------------------------------------------------------------------
QString VisuGUI_Selection::hasActor( const int ind ) const
{
return representation( ind ).isEmpty() ? "0" : "1";
}
+
+//----------------------------------------------------------------------------
+struct TIsShadingFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ if(VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(theActor))
+ return anActor->IsShading() ? "1" : "0";
+ return QString();
+ }
+};
+
QString VisuGUI_Selection::isShading( const int ind ) const
{
- QString aResStr;
-
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- if ( VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor) )
- aResStr = anActor->IsShading() ? "1" : "0";
-
- return aResStr;
+ return TPopupDispatcher<TIsShadingFunctor>()(myModule, entry(ind));
}
-QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
-{
- QString aResStr;
- if ( SVTK_ViewWindow* aView = GetActiveViewWindow<SVTK_ViewWindow>(myModule) )
- if ( VISU_Actor* anVISUActor = FindActor( aView, entry( ind ).latin1() ) )
- {
- VISU_ScalarMapAct* anActor = dynamic_cast<VISU_ScalarMapAct*>(anVISUActor);
- aResStr = anActor ? "1" : "0";
- }
+//----------------------------------------------------------------------------
+struct TIsScalarMapActFunctor: TViewFunctor
+{
+ QString
+ virtual
+ get(VISU::Prs3d_i* thePrs3d,
+ SVTK_ViewWindow* theViewWindow,
+ VISU_Actor* theActor)
+ {
+ return dynamic_cast<VISU_ScalarMapAct*>(theActor)? "1" : "0";
+ }
+};
- return aResStr;
+QString VisuGUI_Selection::isScalarMapAct( const int ind ) const
+{
+ return TPopupDispatcher<TIsScalarMapActFunctor>()(myModule, entry(ind));
}
+
+//----------------------------------------------------------------------------
bool VisuGUI_Selection::isVisuComponent( const int ind ) const
{
SalomeApp_Study* study = GetStudy();
#include "VISU_Table_i.hh"
#include "VISU_Mesh_i.hh"
#include "VISU_ViewManager_i.hh"
+#include "VISU_ColoredPrs3dHolder_i.hh"
#include "VISU_Actor.h"
#include "VISU_ScalarMapAct.h"
return aStr;
}
- //------------------------------------------------------------
- // Selection
- CORBA::Object_var
- GetSelectedObj(const SalomeApp_Study* theStudy,
- const QString& theEntry,
- VISU::Storable::TRestoringMap* theMap)
- {
- if (!theStudy || theEntry.isEmpty())
- return CORBA::Object::_nil();
-
- _PTR(Study) aStudy = GetCStudy(theStudy);
- _PTR(SObject) aSObject = aStudy->FindObjectID(theEntry.latin1());
- if (aSObject) {
- _PTR(GenericAttribute) anAttr;
- if (theMap && aSObject->FindAttribute(anAttr,"AttributeComment")) {
- _PTR(AttributeComment) aComment (anAttr);
- std::string aValue = aComment->Value();
- QString aString (aValue.c_str());
- VISU::Storable::StrToMap(aString, *theMap);
- }
- return VISU::ClientSObjectToObject(aSObject);
- }
- return CORBA::Object::_nil();
- }
- //------------------------------------------------------------
- CORBA::Object_var
- GetSelectedObj(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO,
- VISU::Storable::TRestoringMap* theMap)
+ //----------------------------------------------------------------------------
+ // Selection
+ TSelectionInfo
+ GetSelectedObjects(const SalomeApp_Module* theModule)
{
+ TSelectionInfo aSelectionInfo;
+ const SalomeApp_Study* aStudy = GetAppStudy(theModule);
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects(aListIO);
SALOME_ListIteratorOfListIO anIter(aListIO);
if(anIter.More()){
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
- if(theIO)
- *theIO = anIO;
- if(anIO->hasEntry())
- return GetSelectedObj( GetAppStudy(theModule), anIO->getEntry(), theMap );
+ if(anIO->hasEntry()){
+ TObjectInfo anObjectInfo = GetObjectByEntry(aStudy, anIO->getEntry());
+ TSelectionItem aSelectionItem;
+ aSelectionItem.myObjectInfo = anObjectInfo;
+ aSelectionItem.myIO = anIO;
+ aSelectionInfo.push_back(aSelectionItem);
+ }
}
- return CORBA::Object::_nil();
+ return aSelectionInfo;
}
- //------------------------------------------------------------
+
+ //----------------------------------------------------------------------------
+ TObjectInfo
+ GetObjectByEntry(const SalomeApp_Study* theStudy,
+ const std::string& theEntry)
+ {
+ TObjectInfo anObjectInfo;
+ if(!theStudy || theEntry == "")
+ return anObjectInfo;
+
+ _PTR(Study) aStudy = GetCStudy(theStudy);
+ if(_PTR(SObject) aSObject = aStudy->FindObjectID(theEntry)){
+ anObjectInfo.mySObject = aSObject;
+ CORBA::Object_var anObject = ClientSObjectToObject(aSObject);
+ if(VISU::Base_i* aBase = GetServantInterface<VISU::Base_i>(anObject))
+ anObjectInfo.myBase = aBase;
+ }
+
+ return anObjectInfo;
+ }
+
+
+ //----------------------------------------------------------------------------
VISU::Prs3d_i*
- GetPrsToModify(const SalomeApp_Module* theModule,
- Handle(SALOME_InteractiveObject)* theIO,
- VISU::Storable::TRestoringMap* theMap)
+ GetPrs3dToModify(const SalomeApp_Module* theModule,
+ Base_i* theBase)
{
- if (CheckLock(GetCStudy(GetAppStudy(theModule)),GetDesktop(theModule)))
+ if (CheckLock(GetCStudy(GetAppStudy(theModule)), GetDesktop(theModule)))
return NULL;
- return GetPrsToModify(GetSelectedObj(theModule, theIO));
+ return GetPrs3dFromBase(theBase);
}
- //------------------------------------------------------------
+ //----------------------------------------------------------------------------
VISU::Prs3d_i*
- GetPrsToModify(CORBA::Object_var theObject)
+ GetPrs3dFromBase(Base_i* theBase)
{
- if(VISU::Base_i* aBase = GetServantInterface<VISU::Base_i>(theObject)){
- if(aBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
- VISU::ColoredPrs3dHolder_var aHolder = VISU::ColoredPrs3dHolder::_narrow(theObject);
- VISU::ColoredPrs3d_var aColoredPrs3d = aHolder->GetDevice();
- aBase = dynamic_cast<VISU::Base_i*>(GetServant(aColoredPrs3d).in());
- }
- return dynamic_cast<VISU::Prs3d_i*>(aBase);
+ if(theBase && theBase->GetType() == VISU::TCOLOREDPRS3DHOLDER){
+ VISU::ColoredPrs3dHolder_i* aHolder = dynamic_cast<VISU::ColoredPrs3dHolder_i*>(theBase);
+ return aHolder->GetPrs3dDevice();
}
- return NULL;
+ return dynamic_cast<VISU::Prs3d_i*>(theBase);
}
- //------------------------------------------------------------
+ //----------------------------------------------------------------------------
+ Storable::TRestoringMap
+ GetStorableMap(_PTR(SObject) theSObject)
+ {
+ Storable::TRestoringMap aMap;
+ _PTR(GenericAttribute) anAttr;
+ if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+ _PTR(AttributeComment) aComment (anAttr);
+ std::string aValue = aComment->Value();
+ VISU::Storable::StrToMap(aValue.c_str(), aMap);
+ }
+ return aMap;
+ }
+
+ //----------------------------------------------------------------------------
+ bool
+ GetPrs3dSelectionInfo(const SalomeApp_Module* theModule,
+ VISU::Prs3d_i*& thePrs3d,
+ SVTK_ViewWindow*& theViewWindow,
+ VISU_Actor*& thenActor)
+ {
+ VISU::TSelectionInfo aSelectionInfo = VISU::GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return false;
+
+ VISU::TSelectionItem aSelectionItem = aSelectionInfo.front();
+ thePrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!thePrs3d)
+ return false;
+
+ theViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!theViewWindow)
+ return false;
+
+ thenActor = FindActor(theViewWindow, thePrs3d);
+ if(!thenActor)
+ return false;
+
+ return true;
+ }
+
+ //----------------------------------------------------------------------------
void
Add(LightApp_SelectionMgr* theSelectionMgr,
const Handle(SALOME_InteractiveObject)& theIO)
{
_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);
- ErasePrs(theModule, aChildObj, /*repaint_view_window = */false);
+ _PTR(SObject) aSObject = aChildIter->Value();
+ TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), aSObject->GetID());
+ ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */false);
}
- CORBA::Object_var anObj = VISU::ClientSObjectToObject(theSObject);
- if (!CORBA::is_nil(anObj)) {
- ErasePrs(theModule, anObj, /*repaint_view_window = */true);
+ TObjectInfo anObjectInfo = GetObjectByEntry(GetAppStudy(theModule), theSObject->GetID());
+ if(anObjectInfo.myBase){
+ ErasePrs(theModule, anObjectInfo.myBase, /*repaint_view_window = */true);
- VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
+ CORBA::Object_var anObject = ClientSObjectToObject(theSObject);
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObject);
if (!CORBA::is_nil(aRemovableObject)) {
aRemovableObject->RemoveFromStudy();
}
ChangeRepresentation (const SalomeApp_Module* theModule,
VISU::PresentationType theType)
{
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule)){
- if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(theModule)){
- if (VISU_Actor* anActor = GetActor(aPrs3d, aViewWindow)) {
- switch (theType) {
- case VISU::SHRINK:
- if (anActor->IsShrunk())
- anActor->UnShrink();
- else
- anActor->SetShrink();
- break;
- default:
- if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
- aMesh->SetPresentationType(theType);
- RecreateActor(theModule, aMesh);
- } else {
- anActor->SetRepresentation(theType);
- }
- }
- aViewWindow->Repaint();
- }
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return;
+
+ TSelectionItem aSelectionItem = aSelectionInfo.front();
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!aPrs3d)
+ return;
+
+ SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!aViewWindow)
+ return;
+
+ VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
+ if(!anActor)
+ return;
+
+ switch (theType) {
+ case VISU::SHRINK:
+ if (anActor->IsShrunk())
+ anActor->UnShrink();
+ else
+ anActor->SetShrink();
+ break;
+ default:
+ if (VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d)) {
+ aMesh->SetPresentationType(theType);
+ RecreateActor(theModule, aMesh);
+ } else {
+ anActor->SetRepresentation(theType);
}
}
+ aViewWindow->Repaint();
}
//------------------------------------------------------------
SetShading ( const SalomeApp_Module* theModule,
bool theOn )
{
- if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule)){
- if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(theModule)){
- if (VISU_Actor* anActor = GetActor(aPrs3d, aViewWindow)) {
- if ( VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor) )
- aScalarMapActor->SetShading( theOn );
- }
- aViewWindow->Repaint();
- }
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(aSelectionInfo.empty())
+ return;
+
+ TSelectionItem aSelectionItem = GetSelectedObjects(theModule).front();
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(aSelectionItem.myObjectInfo.myBase);
+ if(!aPrs3d)
+ return;
+
+ SVTK_ViewWindow* aViewWindow = GetActiveViewWindow<SVTK_ViewWindow>(theModule);
+ if(!aViewWindow)
+ return;
+
+ VISU_Actor* anActor = FindActor(aViewWindow, aPrs3d);
+ if(!anActor)
+ return;
+
+ if(VISU_ScalarMapAct* aScalarMapActor = dynamic_cast<VISU_ScalarMapAct*>(anActor)){
+ aScalarMapActor->SetShading(theOn);
+ aViewWindow->Repaint();
}
}
Handle(SALOME_InteractiveObject)& theIO,
ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
{
- CORBA::Object_var anObject = GetSelectedObj(theModule, &theIO);
- if (!theIO.IsNull() && theIO->hasEntry()){
- _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
- theSObject = aStudy->FindObjectID(theIO->getEntry());
+ TSelectionInfo aSelectionInfo = GetSelectedObjects(theModule);
+ if(!aSelectionInfo.empty()){
+ TSelectionItem aSelectionItem = aSelectionInfo.front();
+ theIO = aSelectionItem.myIO;
+ theSObject = aSelectionItem.myObjectInfo.mySObject;
QString aValue = getValue(theSObject,"myType");
if (aValue.toInt() == int(VISU::TTIMESTAMP)){
thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
//------------------------------------------------------------
VISU_Actor*
- FindActor(SVTK_ViewWindow* theViewWindow,
- const char* theEntry)
+ FindActor(const SalomeApp_Study* theStudy,
+ SVTK_ViewWindow* theViewWindow,
+ const QString& theEntry)
{
- using namespace SVTK;
- if(vtkRenderer* aRenderer = theViewWindow->getRenderer()){
- if(vtkActorCollection* aCollection = aRenderer->GetActors()){
- if(VISU_Actor* anActor = Find<VISU_Actor>(aCollection,TIsSameEntry<VISU_Actor>(theEntry))){
- return anActor;
- }
- }
- }
- return NULL;
- }
-
- //------------------------------------------------------------
- VISU_Actor*
- FindActor(SVTK_ViewWindow* theViewWindow,
- VISU::Prs3d_i* thePrs)
- {
- Handle(SALOME_InteractiveObject) anIO = thePrs->GetIO();
- if(anIO->hasEntry()){
- std::string anEntry = anIO->getEntry();
- return FindActor(theViewWindow, anEntry.c_str());
- }
- return NULL;
+ TObjectInfo anObjectInfo = GetObjectByEntry(theStudy, theEntry);
+ VISU::Prs3d_i* aPrs3d = GetPrs3dFromBase(anObjectInfo.myBase);
+ return FindActor(theViewWindow, aPrs3d);
}
//------------------------------------------------------------