#include "SVTK_RenderWindowInteractor.h"
#include "VISU_Event.h"
+#include "Plot2d_ViewWindow.h"
+#include "Plot2d_ViewFrame.h"
+
#include "VisuGUI_Prs3dTools.h"
#include "VISU_GaussPoints_i.hh"
#include "VISU_CutLines_i.hh"
#include "VISU_Actor.h"
+#include "VISU_ScalarMapAct.h"
#include "VisuGUI_Tools.h"
#include "VisuGUI_ActionsDef.h"
#include <vtkRenderer.h>
#include <vtkCamera.h>
#include <vtkTimerLog.h>
+#include <vtkPlane.h>
#include <sstream>
setPreferenceProperty( pyramidHeightPref, "min", 1 );
setPreferenceProperty( pyramidHeightPref, "max", 100 );
- int selectionColorPref = addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
+ /*int selectionColorPref = */addPreference( tr( "VISU_PICKING_PREF_SELECTION_COLOR" ), cursorGr,
LightApp_Preferences::Color, "VISU", "picking_selection_color" );
// Tolerance
}
const char gSeparator = '_'; // character used to separate parameter names
+const char gDigitsSep = ':'; // character used to separate numeric parameter values (color = r:g:b)
/*!
* \brief Virtual public
*
_PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative", moduleName().latin1(), savePoint);
SALOMEDS_IParameters ip(ap);
+ // viewers counters are used for storing view_numbers in IParameters
+ int vtkViewers( 0 ), plotViewers( 0 );
+
+ // componentName is used for encoding of entries when storing them in IParameters
+ _PTR(SComponent) visuEng = ClientFindOrCreateVisuComponent( studyDS );
+ std::string componentName = visuEng->ComponentDataType();
+
+ // iterating view managers and its views
QPtrList<SUIT_ViewManager> lst;
getApp()->viewManagers( lst );
- int vtkViewers( 0 );
for ( QPtrListIterator<SUIT_ViewManager> it( lst ); it.current(); ++it ) {
SUIT_ViewManager* vman = it.current();
SUIT_ViewModel* vmodel = vman->getViewModel();
// inherits SVTK_ViewWindow)
QPtrVector<SUIT_ViewWindow> views = vman->getViews();
for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
- SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>( views[i] );
- if ( vtkView ) {
+ if ( SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>( views[i] ) ) {
vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
allActors->InitTraversal();
while ( vtkActor* actor = allActors->GetNextActor() ) {
if ( actor->GetVisibility() ) { // store only visible actors
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 = 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;
+ std::string param, vtkParam = vmodel->getType().latin1(); vtkParam += gSeparator;
+ vtkParam += QString::number( vtkViewers ).latin1(); vtkParam += gSeparator;
param = vtkParam + "Visibility";
- ip.setParameter( entry, param.latin1(), "true" );
+ ip.setParameter( entry, param, "On" );
param = vtkParam + "Name";
- ip.setParameter( entry, param.latin1(), vActor->getName() );
+ ip.setParameter( entry, param, vActor->getName() );
param = vtkParam + "RepresentationMode";
- ip.setParameter( entry, param.latin1(), QString::number( vActor->GetRepresentation() ).latin1() );
+ ip.setParameter( entry, param, QString::number( vActor->GetRepresentation() ).latin1() );
param = vtkParam + "Opacity";
- ip.setParameter( entry, param.latin1(), QString::number( vActor->GetOpacity() ).latin1() );
+ ip.setParameter( entry, param, 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 += ",";
+ QString colorStr = QString::number( r ); colorStr += gDigitsSep;
+ colorStr += QString::number( g ); colorStr += gDigitsSep;
colorStr += QString::number( b );
param = vtkParam + "Color";
- ip.setParameter( entry, param.latin1(), colorStr.latin1() );
+ ip.setParameter( entry, param, 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() );
+ ip.setParameter( entry, param, QString::number( vActor->GetLineWidth() ).latin1() );
+ if ( vActor->IsShrunkable() && vActor->IsShrunk() ) {
+ param = vtkParam + "ShrinkMode";
+ ip.setParameter( entry, param, "On" );
+ param = vtkParam + "ShrinkFactor";
+ ip.setParameter( entry, param, QString::number( vActor->GetShrinkFactor() ).latin1() );
+ }
+ VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor );
+ if ( scalarMapActor && scalarMapActor->IsShading() ) {
+ param = vtkParam + "Shading";
+ ip.setParameter( entry, param, "On" );
+ }
+ if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) {
+ param = vtkParam + "ClippingPlane_";
+ for ( int p = 0, nPlanes = vPrs->GetNumberOfClippingPlanes(); p < nPlanes; p++ ) {
+ vtkPlane* plane = vPrs->GetClippingPlane( p );
+ float normal[3], origin[3];
+ plane->GetNormal( normal );
+ plane->GetOrigin( origin );
+ std::string planeValue = QString::number( normal[0] ).latin1(); planeValue += gDigitsSep;
+ planeValue += QString::number( normal[1] ).latin1(); planeValue += gDigitsSep;
+ planeValue += QString::number( normal[2] ).latin1(); planeValue += gDigitsSep;
+ planeValue += QString::number( origin[0] ).latin1(); planeValue += gDigitsSep;
+ planeValue += QString::number( origin[1] ).latin1(); planeValue += gDigitsSep;
+ planeValue += QString::number( origin[2] ).latin1();
+ param += QString::number( p+1 ).latin1();
+ ip.setParameter( entry, param, planeValue );
+ }
+ }
} // hasIO
} // salome_actor successfull downcast
} // for ( views )
vtkViewers++;
} // if ( SVTK view model )
+ else if ( vmodel->getType() == SPlot2d_Viewer::Type() ) { // processing Plot2d viewers
+ QPtrVector<SUIT_ViewWindow> views = vman->getViews();
+ for ( int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++ ) {
+ if ( Plot2d_ViewWindow* plotView = dynamic_cast<Plot2d_ViewWindow*>( views[i] ) ) {
+ Plot2d_ViewFrame* plotVF = plotView->getViewFrame();
+ QPtrList<Plot2d_Curve> curves;
+ plotVF->getCurves( curves );
+
+ Plot2d_Curve* curve;
+ for ( curve = curves.first(); curve; curve = curves.next() ) {
+ if ( SPlot2d_Curve* sCurve = dynamic_cast<SPlot2d_Curve*>( curve ) ) {
+ if ( sCurve->hasIO() ) {
+
+ Handle(SALOME_InteractiveObject) io = sCurve->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 );
+
+ std::string param, plotParam = vmodel->getType().latin1(); plotParam += gSeparator;
+ plotParam += QString::number( plotViewers ).latin1(); plotParam += gSeparator;
+
+ param = plotParam + "Visibility";
+ ip.setParameter( entry, param, "On" );
+ }
+ }
+ } // for curves
+ } // if ( plotView )
+ } // for ( views )
+ plotViewers++;
+ } // if ( SPlot2d view model )
}
}
for ( ; namesIt != paramNames.end(); ++namesIt, ++valuesIt ) {
std::string viewerType = ::getParam( *namesIt, ViewerType );
+ std::string paramName = ::getParam( *namesIt, ParamName );
+ bool ok;
+ std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
+ int viewIndex = QString( viewIndexStr.c_str() ).toUInt( &ok );
+ if ( !ok ) // bad conversion of view index to integer
+ continue;
+
if ( viewerType == SVTK_Viewer::Type().latin1() ||
viewerType == VVTK_Viewer::Type().latin1() ) {
- std::string paramName = ::getParam( *namesIt, ParamName );
- bool ok;
- std::string viewIndexStr = ::getParam( *namesIt, ViewIndex );
- int viewIndex = QString( viewIndexStr.c_str() ).toUInt( &ok );
- if ( !ok ) // bad conversion of view index to integer
- continue;
-
- //cout << "--SVTK parameter: entry = " << *entIt << ", paramName = " << paramName << endl;
+ //cout << "--SVTK parameter: entry = " << entry.latin1() << ", paramName = " << paramName << endl;
if ( paramName == "Visibility" && displayer() ) {
QPtrList<SUIT_ViewManager> lst;
vActor->SetOpacity( val.toFloat() );
else if ( paramName == "Color" ) {
- QStringList colors = QStringList::split( ',', val );
+ QStringList colors = QStringList::split( gDigitsSep, val );
if ( colors.count() == 3 )
vActor->SetColor( colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat() );
}
else if ( paramName == "LineWidth" )
vActor->SetLineWidth( val.toFloat() );
- else if ( paramName == "IsShrunk" ) {
+ else if ( paramName == "ShrinkMode" ) {
vActor->SetShrinkable( true );
vActor->SetShrink();
}
else if ( paramName == "ShrunkFactor" )
vActor->SetShrinkFactor( val.toFloat() );
+ else if ( paramName == "Shading" ) {
+ if ( VISU_ScalarMapAct* scalarMapActor = dynamic_cast<VISU_ScalarMapAct*>( vActor ) )
+ scalarMapActor->SetShading();
+ }
+
+ else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) {
+ QStringList vals = QStringList::split( gDigitsSep, val );
+ if ( vals.count() == 6 && vActor->GetPrs3d() ) {
+ float normal[3], origin[3];
+ for (int x = 0; x < 3; x++ ) {
+ normal[x] = vals[x].toFloat();
+ origin[x] = vals[x+3].toFloat();
+ }
+ vtkPlane* plane = vtkPlane::New();
+ plane->SetNormal( normal );
+ plane->SetOrigin( origin );
+ vActor->GetPrs3d()->AddClippingPlane( plane );
+ }
+ }
+
} // else ..
} // if SVTK
+ else if ( viewerType == SPlot2d_Viewer::Type().latin1() ) {
+
+ //cout << "--Plot2d parameter: entry = " << entry.latin1() << ", paramName = " << paramName << endl;
+
+ if ( paramName == "Visibility" && displayer() ) {
+ QPtrList<SUIT_ViewManager> lst;
+ getApp()->viewManagers( viewerType, lst );
+
+ if ( viewIndex >= 0 && viewIndex < lst.count() ) {
+ SUIT_ViewManager* vman = lst.at( viewIndex );
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ // SVTK and VVTK view models can be casted to SALOME_View
+ displayer()->Display( entry, true, dynamic_cast<SALOME_View*>( vmodel ) );
+ }
+ }
+
+ } // if SPlot2d
+
} // for names/parameters iterator
} // for entries iterator
vtkView->getRenderer()->ResetCameraClippingRange();
vtkView->Repaint();
}
+ else if ( vmodel->getType() == SPlot2d_Viewer::Type().latin1() ) {
+ Plot2d_ViewWindow* plotView = (Plot2d_ViewWindow*) vman->getActiveView();
+ plotView->getViewFrame()->Repaint();
+ }
} // ] end of update views
}