void VisuGUI_Module::storeVisualParameters(int savePoint)
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if( !study )
+ if( !study || !study->studyDS() )
return;
- _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
+ _PTR(Study) studyDS = study->studyDS();
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
SALOMEDS_IParameters ip(ap);
QPtrList<SUIT_ViewManager> lst;
allActors->InitTraversal();
while ( vtkActor* actor = allActors->GetNextActor() ) {
if ( actor->GetVisibility() ) { // store only visible actors
- if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) ) {
- if ( salomeActor->hasIO() ) { // actor corresponds to existing obj
+ if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
+ if ( vActor->hasIO() ) { // actor corresponds to existing obj
+
+ _PTR(SComponent) visuEng = ClientFindOrCreateVisuComponent( studyDS );
+ std::string componentName = visuEng->ComponentDataType();
- Handle(SALOME_InteractiveObject) io = salomeActor->getIO();
- const char* entry = io->getEntry();
- const char* aName = salomeActor->getName();
- int repMode = salomeActor->GetRepresentation();
- float opacity = salomeActor->GetOpacity();
- float r, g, b;
- salomeActor->GetColor(r, g, b);
- QString colorStr = QString::number( r ); colorStr += ",";
- colorStr += QString::number( g ); colorStr += ",";
- colorStr += QString::number( b );
+ Handle(SALOME_InteractiveObject) io = vActor->getIO();
+ // entry is "ecoded" = it does NOT contain component adress, since it is a
+ // subject to change on next component loading
+ std::string entry = ip.encodeEntry( io->getEntry(), componentName );
+
QString param, vtkParam = vmodel->getType(); vtkParam += gSeparator;
vtkParam += QString::number( vtkViewers ); vtkParam += gSeparator;
param = vtkParam + "Visibility";
ip.setParameter( entry, param.latin1(), "true" );
param = vtkParam + "Name";
- ip.setParameter( entry, param.latin1(), aName );
+ ip.setParameter( entry, param.latin1(), vActor->getName() );
param = vtkParam + "RepresentationMode";
- ip.setParameter( entry, param.latin1(), QString::number( repMode ).latin1() );
+ ip.setParameter( entry, param.latin1(), QString::number( vActor->GetRepresentation() ).latin1() );
param = vtkParam + "Opacity";
- ip.setParameter( entry, param.latin1(), QString::number( opacity ).latin1() );
+ ip.setParameter( entry, param.latin1(), QString::number( vActor->GetOpacity() ).latin1() );
+ float r, g, b;
+ vActor->GetColor(r, g, b);
+ QString colorStr = QString::number( r ); colorStr += ",";
+ colorStr += QString::number( g ); colorStr += ",";
+ colorStr += QString::number( b );
param = vtkParam + "Color";
ip.setParameter( entry, param.latin1(), colorStr.latin1() );
+ param = vtkParam + "LineWidth";
+ ip.setParameter( entry, param.latin1(), QString::number( vActor->GetLineWidth() ).latin1() );
+ bool shrunk = vActor->IsShrunkable() && vActor->IsShrunk();
+ param = vtkParam + "IsShrunk";
+ ip.setParameter( entry, param.latin1(), QString::number( shrunk ).latin1() );
+ param = vtkParam + "ShrinkFactor";
+ ip.setParameter( entry, param.latin1(), QString::number( vActor->GetShrinkFactor() ).latin1() );
} // hasIO
} // salome_actor successfull downcast
}
}
-// returns SALOME_Actor with IO with given entry
-SALOME_Actor* getActor( std::string entry, SVTK_ViewWindow* vtkView )
+// returns VISU_Actor with IO with given entry
+VISU_Actor* getActor( const QString& entry, SVTK_ViewWindow* vtkView )
{
- if ( vtkView && !entry.empty() ) {
+ if ( vtkView && !entry.isEmpty() ) {
vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
allActors->InitTraversal();
while ( vtkActor* actor = allActors->GetNextActor() ) {
- if ( SALOME_Actor* salomeActor = SALOME_Actor::SafeDownCast( actor ) ) {
- if ( salomeActor->hasIO() ) { // actor corresponds to existing obj
- Handle(SALOME_InteractiveObject) io = salomeActor->getIO();
+ if ( VISU_Actor* vActor = VISU_Actor::SafeDownCast( actor ) ) {
+ if ( vActor->hasIO() ) { // actor corresponds to existing obj
+ Handle(SALOME_InteractiveObject) io = vActor->getIO();
if ( entry == io->getEntry() )
- return salomeActor;
+ return vActor;
}
}
}
void VisuGUI_Module::restoreVisualParameters(int savePoint)
{
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
- if( !study )
+ if( !study || !study->studyDS() )
return;
- _PTR(AttributeParameter) ap = study->studyDS()->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
+ _PTR(Study) studyDS = study->studyDS();
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
SALOMEDS_IParameters ip(ap);
// actors are stored in a map after displaying of them for quicker access in future
- QMap<QString, QMap<int, SALOME_Actor*> > vtkActors; // map: entry to map: view_id to actor
+ QMap<QString, QMap<int, VISU_Actor*> > vtkActors; // map: entry to map: view_id to actor
std::vector<std::string> entries = ip.getEntries();
for ( std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt ) {
- QString entry( (*entIt).c_str() );
+ QString entry( ip.decodeEntry( *entIt ).c_str() );
std::vector<std::string> paramNames = ip.getAllParameterNames( *entIt );
std::vector<std::string> paramValues = ip.getAllParameterValues( *entIt );
std::vector<std::string>::iterator namesIt = paramNames.begin();
// vtkView->Repaint();
// store displayed actor so setting of color, opacity, etc. will be much faster
- QMap<int, SALOME_Actor*> viewActorMap;
+ QMap<int, VISU_Actor*> viewActorMap;
if ( vtkActors.contains( entry ) )
viewActorMap = vtkActors[ entry ];
- viewActorMap[ viewIndex ] = getActor( *entIt, vtkView );
+ viewActorMap[ viewIndex ] = getActor( entry, vtkView );
vtkActors[ entry ] = viewActorMap;
}
}
- else { // the rest properties "work" with SALOME_Actor, so we initialize it at first
- SALOME_Actor* actor = 0;
+ else { // the rest properties "work" with VISU_Actor, so we initialize it at first
+ VISU_Actor* vActor = 0;
if ( vtkActors.contains( entry ) ) {
- QMap<int, SALOME_Actor*> viewActorMap = vtkActors[ entry ];
+ QMap<int, VISU_Actor*> viewActorMap = vtkActors[ entry ];
if ( viewActorMap.contains( viewIndex ) )
- actor = viewActorMap[ viewIndex ];
+ vActor = viewActorMap[ viewIndex ];
}
- if ( !actor )
+ if ( !vActor )
continue;
QString val( (*valuesIt).c_str() );
if ( paramName == "Name" )
- actor->setName( val.latin1() );
+ vActor->setName( val.latin1() );
else if ( paramName == "RepresentationMode" )
- actor->SetRepresentation( val.toInt() );
+ vActor->SetRepresentation( val.toInt() );
else if ( paramName == "Opacity" )
- actor->SetOpacity( val.toFloat() );
+ vActor->SetOpacity( val.toFloat() );
else if ( paramName == "Color" ) {
QStringList colors = QStringList::split( ',', val );
if ( colors.count() == 3 )
- actor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
+ vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
}
+
+ else if ( paramName == "LineWidth" )
+ vActor->SetLineWidth( val.toFloat() );
+
+ else if ( paramName == "IsShrunk" ) {
+ vActor->SetShrinkable( true );
+ vActor->SetShrink();
+ }
+
+ else if ( paramName == "ShrunkFactor" )
+ vActor->SetShrinkFactor( val.toFloat() );
+
} // else ..
} // if SVTK