#include "VisuGUI_Prs3dTools.h"
#include "VISU_GaussPoints_i.hh"
+#include "VISU_GaussPtsAct.h"
#include "VisuGUI_GaussPointsDlg.h"
#include "VISU_Gen_i.hh"
#define GAUSS_DISPLAY_PRS 5500
#define GAUSS_DISPLAY_ONLY_PRS 5600
+#define GAUSS_SAVE_CONFIGURATION 5700
+#define GAUSS_OVERWRITE_CONFIGURATION 5701
+#define GAUSS_RESTORE_CONFIGURATION 5702
+
+int VisuGUI_Module::myNbConfigs = 0;
+
void
CreateCurves( SalomeApp_Module* theModule,
VISU::CutLines_i* thePrs,
mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ),
aRule, true );
-
- mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "selcount=1 and $type in {'VISU::TVIEW3D' VISU::TGAUSSVIEW}", true );
- mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VTKViewer' 'SVTK'} and selcount=0", true );
- aRule = "selcount=1 and "
+ /*
+ mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "selcount=1 and $type in {VISU::TGAUSSVIEW}", true );
+ mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VVTK'} and selcount=0", true );
+ //mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "$type in {'VISU::TVIEW3D' VISU::TGAUSSVIEW}", true );
+ //mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VTKViewer' 'SVTK'}", true );
+ aRule = //"selcount=1 and "
"((type='VISU::TVIEW3D' and activeView='VTKViewer') or "
"(type='VISU::TGAUSSVIEW' and activeView='VVTK'))";
mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), aRule, true );
+ */
+ createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIconSet(),
+ tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
+ this, SLOT(OnSaveConfiguration()));
+ mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
+ mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ), "selcount>=0 and client='VVTK' and activeView='VVTK'", true );
+
+ createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIconSet(),
+ tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
+ this, SLOT(OnOverwriteConfiguration()));
+ mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
+ mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
+ "selcount=1 and client='ObjectBrowser' and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
+
+ createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIconSet(),
+ tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
+ this, SLOT(OnRestoreConfiguration()));
+ mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
+ mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
+ "selcount=1 and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
}
//---------------------------------------------------------------
Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[0]",aScaleFactor[0]);
Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[1]",aScaleFactor[1]);
Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[2]",aScaleFactor[2]);
+
+ // Store displayed Gauss Points
+ int index = 0;
+ QString aPrsList;
+ vtkActor* anActor;
+ vtkActorCollection* anActColl = aRenderer->GetActors();
+ for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+ {
+ if( VISU_GaussPtsAct* aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+ {
+ if( aGaussActor->GetVisibility() && aGaussActor->hasIO() )
+ {
+ const char* entry = aGaussActor->getIO()->getEntry();
+ Storable::DataToStream( theStr,
+ std::string("myDisplayedPrs") + theSuffix + "[" + QString::number( index ) + "]",
+ entry );
+ index++;
+ }
+ }
+ }
+ /*
+ TColStd_IndexedMapOfInteger anIndex;
+
+ // Store current selected Gauss Point
+ SVTK_Selector* aSelector = theViewWindow->GetSelector();
+ for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+ {
+ if( VISU_GaussPtsAct* aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+ {
+ if( aGaussActor->hasIO() )
+ {
+ Handle(SALOME_InteractiveObject) anIO = aGaussActor->getIO();
+ if( aSelector->IsSelected( anIO ) )
+ {
+ aSelector->GetIndex( anIO, anIndex );
+ cout << anIO->getEntry() << endl;
+ if( anIndex.Extent() > 0 )
+ cout << anIndex(1) << endl;
+ }
+
+ }
+ }
+ }
+ */
}
//---------------------------------------------------------------
aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
theViewWindow->SetScale(aScaleFactor);
+
+ // Restore displayed Gauss Points
+ vtkActor* anActor;
+ VISU_GaussPtsAct* aGaussActor;
+ vtkActorCollection* anActColl = aRenderer->GetActors();
+ for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+ {
+ if( aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+ anActor->SetVisibility( false );
+ }
+
+ for( int index = 0; ; index++ )
+ {
+ QString aPrs = Storable::FindValue( theMap, std::string("myDisplayedPrs") + theSuffix +
+ "[" + QString::number( index ) + "]" );
+ if( aPrs == "NULL" )
+ break;
+
+ using namespace SVTK;
+ if( aGaussActor = Find<VISU_GaussPtsAct>( anActColl, TIsSameEntry<VISU_GaussPtsAct>( aPrs.latin1() ) ) )
+ aGaussActor->SetVisibility( true );
+ }
+
}
//---------------------------------------------------------------
}
+
+//---------------------------------------------------------------
void
VisuGUI_Module::
-OnSaveViewParams()
+OnSaveConfiguration()
+{
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+ if (CheckLock(aCStudy))
+ return;
+
+ LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+
+ std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
+
+ SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
+ if(aViewManager->getType() == VVTK_Viewer::Type()){
+ SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+ VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+ std::string aValue = GetViewParams(aViewWindow);
+
+ SUIT_Study* aSStudy = aViewManager->study();
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
+ _PTR(Study) aCStudy = aStudy->studyDS();
+ std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(aName,"VISU");
+ _PTR(GenericAttribute) anAttr;
+ int iEnd = aList.size();
+ for(int i = 0; i < iEnd; i++){
+ _PTR(SObject) anObj = aList[i];
+ std::string anEntry = anObj->GetID();
+ if(anObj->FindAttribute(anAttr,"AttributeComment")){
+ _PTR(AttributeComment) aCmnt (anAttr);
+ std::string aComm (aCmnt->Value());
+ if(aComm.compare(View3D_i::myComment) >= 0){
+ aCmnt->SetValue(aValue.c_str());
+ return;
+ }
+ }
+ }
+
+ _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
+ std::string aSComponentEntry = aSComponent->GetID();
+ std::string anEntry = CreateAttributes(aCStudy,
+ aSComponentEntry.c_str(),
+ "",
+ "",
+ aName.c_str(),
+ "",
+ aValue.c_str());
+ }else
+ return;
+
+ UpdateObjBrowser(this);
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module::
+OnOverwriteConfiguration()
{
_PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
if (CheckLock(aCStudy))
SALOME_ListIO aListIO;
aSelectionMgr->selectedObjects(aListIO);
- if(aListIO.Extent() > 1)
+ if(aListIO.Extent() != 1)
return;
- std::string aName;
- if(aListIO.Extent() == 0){
- aName = VISU::View3D_i::GenerateViewParamsName().latin1();
- }else{
- const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
- aName = anIO->getName();
- }
+ std::string aName = aListIO.First()->getName();
SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
- if(aViewManager->getType() == SVTK_Viewer::Type())
- VISU::View3D_i::SaveViewParams(aViewManager,aName.c_str());
- else if(aViewManager->getType() == VVTK_Viewer::Type()){
+ if(aViewManager->getType() == VVTK_Viewer::Type()){
SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
std::string aValue = GetViewParams(aViewWindow);
//---------------------------------------------------------------
void
VisuGUI_Module::
-OnRestoreViewParams()
+OnRestoreConfiguration()
{
LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);