+ setPreferenceProperty( precSelGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_NODES" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_node" );
+ addPreference( tr( "PREF_ELEMENTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_element" );
+ addPreference( tr( "PREF_OBJECTS" ), precSelGroup, LightApp_Preferences::Double, "SMESH", "selection_precision_object" );
+
+ // Scalar Bar tab ------------------------------------------------------------------------
+ int sbarTab = addPreference( tr( "SMESH_SCALARBAR" ) );
+ int fontGr = addPreference( tr( "SMESH_FONT_SCALARBAR" ), sbarTab );
+ setPreferenceProperty( fontGr, "columns", 2 );
+
+ addVtkFontPref( tr( "SMESH_TITLE" ), fontGr, "scalar_bar_title_font" );
+ addPreference( tr( "PREF_TITLE_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_title_color" );
+
+ addVtkFontPref( tr( "SMESH_LABELS" ), fontGr, "scalar_bar_label_font" );
+ addPreference( tr( "PREF_LABELS_COLOR" ), fontGr, LightApp_Preferences::Color, "SMESH", "scalar_bar_label_color" );
+
+ int colorsLabelsGr = addPreference( tr( "SMESH_LABELS_COLORS_SCALARBAR" ), sbarTab );
+ setPreferenceProperty( colorsLabelsGr, "columns", 2 );
+
+ int numcol = addPreference( tr( "SMESH_NUMBEROFCOLORS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_colors" );
+ setPreferenceProperty( numcol, "min", 2 );
+ setPreferenceProperty( numcol, "max", 256 );
+
+ int numlab = addPreference( tr( "SMESH_NUMBEROFLABELS" ), colorsLabelsGr, LightApp_Preferences::IntSpin, "SMESH", "scalar_bar_num_labels" );
+ setPreferenceProperty( numlab, "min", 2 );
+ setPreferenceProperty( numlab, "max", 65 );
+
+ int orientGr = addPreference( tr( "SMESH_ORIENTATION" ), sbarTab );
+ setPreferenceProperty( orientGr, "columns", 2 );
+ int orient = addPreference( tr( "SMESH_ORIENTATION" ), orientGr, LightApp_Preferences::Selector, "SMESH", "scalar_bar_orientation" );
+ QStringList orients;
+ orients.append( tr( "SMESH_VERTICAL" ) );
+ orients.append( tr( "SMESH_HORIZONTAL" ) );
+ indices.clear(); indices.append( 0 ); indices.append( 1 );
+ setPreferenceProperty( orient, "strings", orients );
+ setPreferenceProperty( orient, "indexes", indices );
+
+ int posVSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_VERTICAL" ), sbarTab );
+ setPreferenceProperty( posVSizeGr, "columns", 2 );
+ int xv = addPreference( tr( "SMESH_X_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_x" );
+ int yv = addPreference( tr( "SMESH_Y_SCALARBAR" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_y" );
+ int wv = addPreference( tr( "SMESH_WIDTH" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_width" );
+ int hv = addPreference( tr( "SMESH_HEIGHT" ), posVSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_vertical_height" );
+ setPreferenceProperty( xv, "step", 0.1 );
+ setPreferenceProperty( xv, "min", 0.0 );
+ setPreferenceProperty( xv, "max", 1.0 );
+ setPreferenceProperty( yv, "step", 0.1 );
+ setPreferenceProperty( yv, "min", 0.0 );
+ setPreferenceProperty( yv, "max", 1.0 );
+ setPreferenceProperty( wv, "step", 0.1 );
+ setPreferenceProperty( wv, "min", 0.0 );
+ setPreferenceProperty( wv, "max", 1.0 );
+ setPreferenceProperty( hv, "min", 0.0 );
+ setPreferenceProperty( hv, "max", 1.0 );
+ setPreferenceProperty( hv, "step", 0.1 );
+
+ int posHSizeGr = addPreference( tr( "SMESH_POSITION_SIZE_SCALARBAR" ) + " " + tr( "SMESH_HORIZONTAL" ), sbarTab );
+ setPreferenceProperty( posHSizeGr, "columns", 2 );
+ int xh = addPreference( tr( "SMESH_X_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_x" );
+ int yh = addPreference( tr( "SMESH_Y_SCALARBAR" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_y" );
+ int wh = addPreference( tr( "SMESH_WIDTH" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_width" );
+ int hh = addPreference( tr( "SMESH_HEIGHT" ), posHSizeGr, LightApp_Preferences::DblSpin, "SMESH", "scalar_bar_horizontal_height" );
+ setPreferenceProperty( xv, "min", 0.0 );
+ setPreferenceProperty( xv, "max", 1.0 );
+ setPreferenceProperty( xv, "step", 0.1 );
+ setPreferenceProperty( xh, "min", 0.0 );
+ setPreferenceProperty( xh, "max", 1.0 );
+ setPreferenceProperty( xh, "step", 0.1 );
+ setPreferenceProperty( yh, "min", 0.0 );
+ setPreferenceProperty( yh, "max", 1.0 );
+ setPreferenceProperty( yh, "step", 0.1 );
+ setPreferenceProperty( wh, "min", 0.0 );
+ setPreferenceProperty( wh, "max", 1.0 );
+ setPreferenceProperty( wh, "step", 0.1 );
+ setPreferenceProperty( hh, "min", 0.0 );
+ setPreferenceProperty( hh, "max", 1.0 );
+ setPreferenceProperty( hh, "step", 0.1 );
+
+ int distributionGr = addPreference( tr( "SMESH_DISTRIBUTION_SCALARBAR" ), sbarTab, LightApp_Preferences::Auto, "SMESH", "distribution_visibility" );
+ int coloringType = addPreference( tr( "SMESH_DISTRIBUTION_COLORING_TYPE" ), distributionGr, LightApp_Preferences::Selector, "SMESH", "distribution_coloring_type" );
+ setPreferenceProperty( distributionGr, "columns", 3 );
+ QStringList types;
+ types.append( tr( "SMESH_MONOCOLOR" ) );
+ types.append( tr( "SMESH_MULTICOLOR" ) );
+ indices.clear(); indices.append( 0 ); indices.append( 1 );
+ setPreferenceProperty( coloringType, "strings", types );
+ setPreferenceProperty( coloringType, "indexes", indices );
+ addPreference( tr( "SMESH_DISTRIBUTION_COLOR" ), distributionGr, LightApp_Preferences::Color, "SMESH", "distribution_color" );
+
+}
+
+void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
+{
+ if( sect=="SMESH" ) {
+ float sbX1,sbY1,sbW,sbH;
+ float aTol = 1.00000009999999;
+ std::string aWarning;
+ SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
+ if( name=="selection_object_color" || name=="selection_element_color" ||
+ name=="highlight_color" ||
+ name=="selection_precision_node" || name=="selection_precision_element" ||
+ name=="selection_precision_object")
+ SMESH::UpdateSelectionProp( this );
+ else if (name == QString("scalar_bar_vertical_x") || name == QString("scalar_bar_vertical_width")){
+ sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_x", sbX1);
+ sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_width", sbW);
+ if(sbX1+sbW > aTol){
+ aWarning = "Origin and Size Vertical: X+Width > 1\n";
+ sbX1=0.01;
+ sbW=0.08;
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_x", sbX1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_width", sbW);
+ }
+ }
+ else if(name == QString("scalar_bar_vertical_y") || name == QString("scalar_bar_vertical_height")){
+ sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_y", sbY1);
+ sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_vertical_height",sbH);
+ if(sbY1+sbH > aTol){
+ aWarning = "Origin and Size Vertical: Y+Height > 1\n";
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_y", sbY1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_vertical_height",sbH);
+ }
+ }
+ else if(name == QString("scalar_bar_horizontal_x") || name == QString("scalar_bar_horizontal_width")){
+ sbX1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+ sbW = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_width", sbW);
+ if(sbX1+sbW > aTol){
+ aWarning = "Origin and Size Horizontal: X+Width > 1\n";
+ sbX1=0.1;
+ sbW=0.08;
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_x", sbX1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_width", sbW);
+ }
+ }
+ else if(name == QString("scalar_bar_horizontal_y") || name == QString("scalar_bar_horizontal_height")){
+ sbY1 = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+ sbH = aResourceMgr->doubleValue("SMESH", "scalar_bar_horizontal_height",sbH);
+ if(sbY1+sbH > aTol){
+ aWarning = "Origin and Size Horizontal: Y+Height > 1\n";
+ sbY1=0.01;
+ sbH=0.08;
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_y", sbY1);
+ aResourceMgr->setValue("SMESH", "scalar_bar_horizontal_height",sbH);
+ }
+ }
+ else if ( name == "segmentation" ) {
+ int nbSeg = aResourceMgr->integerValue( "SMESH", "segmentation", 10 );
+ myComponentSMESH->SetBoundaryBoxSegmentation( nbSeg );
+ }
+ else if ( name == "nb_segments_per_edge" ) {
+ int nbSeg = aResourceMgr->integerValue( "SMESH", "nb_segments_per_edge", 15 );
+ myComponentSMESH->SetDefaultNbSegments( nbSeg );
+ }
+ else if ( name == "historical_python_dump" ||
+ name == "forget_mesh_on_hyp_modif") {
+ QString val = aResourceMgr->stringValue( "SMESH", name );
+ myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
+ }
+ else if ( name == QString( "numbering_node_color" ) || name == QString( "numbering_node_font" ) ) {
+ SMESH::UpdateFontProp( this );
+ }
+ else if ( name == QString( "numbering_elem_color" ) || name == QString( "numbering_elem_font" ) ) {
+ SMESH::UpdateFontProp( this );
+ }
+
+ if(aWarning.size() != 0){
+ aWarning += "The default values are applied instead.";
+ SUIT_MessageBox::warning(SMESHGUI::desktop(),
+ QObject::tr("SMESH_ERR_SCALARBAR_PARAMS"),
+ QObject::tr(aWarning.c_str()));
+ }
+ }
+}
+
+//================================================================================
+/*!
+ * \brief Update something in accordance with update flags
+ * \param theFlags - update flags
+*
+* Update viewer or/and object browser etc. in accordance with update flags ( see
+* LightApp_UpdateFlags enumeration ).
+*/
+//================================================================================
+void SMESHGUI::update( const int flags )
+{
+ if ( (flags & UF_Viewer) | (flags & UF_Forced) )
+ SMESH::UpdateView();
+ else
+ SalomeApp_Module::update( flags );
+}
+
+//================================================================================
+/*!
+ * \brief Set default selection mode
+*
+* SLOT called when operation commited. Sets default selection mode
+*/
+//================================================================================
+void SMESHGUI::onOperationCommited( SUIT_Operation* )
+{
+ SVTK_ViewWindow* vtkWnd =
+ dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
+ if ( vtkWnd )
+ vtkWnd->SetSelectionMode( ActorSelection );
+}
+
+//================================================================================
+/*!
+ * \brief Set default selection mode
+*
+* SLOT called when operation aborted. Sets default selection mode
+*/
+//================================================================================
+void SMESHGUI::onOperationAborted( SUIT_Operation* )
+{
+ SVTK_ViewWindow* vtkWnd =
+ dynamic_cast<SVTK_ViewWindow*>( application()->desktop()->activeWindow() );
+ if ( vtkWnd )
+ vtkWnd->SetSelectionMode( ActorSelection );
+}
+
+//================================================================================
+/*!
+ * \brief Creates operation with given identifier
+ * \param id - identifier of operation to be started
+ * \return Pointer on created operation or NULL if operation is not created
+*
+* Virtual method redefined from the base class creates operation with given id.
+* It is called called automatically from startOperation method of base class.
+*/
+//================================================================================
+LightApp_Operation* SMESHGUI::createOperation( const int id ) const
+{
+ LightApp_Operation* op = 0;
+ // to do : create operation here
+ switch( id )
+ {
+ case 417: //convert to quadratic
+ op = new SMESHGUI_ConvToQuadOp();
+ break;
+ case 418: // create 2D mesh as boundary on 3D
+ op = new SMESHGUI_Make2DFrom3DOp();
+ break;
+ case 420: // Reorient faces
+ op = new SMESHGUI_ReorientFacesOp();
+ break;
+ case 701: // Compute mesh
+ op = new SMESHGUI_ComputeOp();
+ break;
+ case 702: // Create mesh
+ op = new SMESHGUI_MeshOp( true, true );
+ break;
+ case 703: // Create sub-mesh
+ op = new SMESHGUI_MeshOp( true, false );
+ break;
+ case 704: // Edit mesh/sub-mesh
+ op = new SMESHGUI_MeshOp( false );
+ break;
+ case 711: // Precompute mesh
+ op = new SMESHGUI_PrecomputeOp();
+ break;
+ case 712: // Evaluate mesh
+ op = new SMESHGUI_EvaluateOp();
+ break;
+ case 713: // Evaluate mesh
+ op = new SMESHGUI_MeshOrderOp();
+ break;
+ case 806: // Create group on geom
+ op = new SMESHGUI_GroupOnShapeOp();
+ break;
+ case 904: // Find element
+ op = new SMESHGUI_FindElemByPointOp();
+ break;
+ case 4067: // Make mesh pass through point
+ op = new SMESHGUI_MakeNodeAtPointOp();
+ break;
+ case 4070: // Create 0D elements on all nodes
+ op = new SMESHGUI_Add0DElemsOnAllNodesOp();
+ break;
+ default:
+ break;
+ }
+
+ if( !op )
+ op = SalomeApp_Module::createOperation( id );
+ return op;
+}
+
+//================================================================================
+/*!
+ * \brief Stops current operations and starts a given one
+ * \param id - The id of the operation to start
+ */
+//================================================================================
+
+void SMESHGUI::switchToOperation(int id)
+{
+ if ( _PTR(Study) aStudy = SMESH::GetActiveStudyDocument() )
+ activeStudy()->abortAllOperations();
+ startOperation( id );
+}
+
+LightApp_Displayer* SMESHGUI::displayer()
+{
+ if( !myDisplayer )
+ myDisplayer = new SMESHGUI_Displayer( getApp() );
+ return myDisplayer;
+}
+
+SALOMEDS::Color SMESHGUI::getUniqueColor( const QList<SALOMEDS::Color>& theReservedColors )
+{
+ int aHue = -1;
+ int aTolerance = 64;
+ int anIterations = 0;
+ int aPeriod = 5;
+
+ while( 1 )
+ {
+ anIterations++;
+ if( anIterations % aPeriod == 0 )
+ {
+ aTolerance /= 2;
+ if( aTolerance < 1 )
+ break;
+ }
+
+ aHue = (int)( 360.0 * rand() / RAND_MAX );
+
+ bool ok = true;
+ QList<SALOMEDS::Color>::const_iterator it = theReservedColors.constBegin();
+ QList<SALOMEDS::Color>::const_iterator itEnd = theReservedColors.constEnd();
+ for( ; it != itEnd; ++it )
+ {
+ SALOMEDS::Color anAutoColor = *it;
+ QColor aQColor( (int)( anAutoColor.R * 255.0 ), (int)( anAutoColor.G * 255.0 ), (int)( anAutoColor.B * 255.0 ) );
+
+ int h, s, v;
+ aQColor.getHsv( &h, &s, &v );
+ if( abs( h - aHue ) < aTolerance )
+ {
+ ok = false;
+ break;
+ }
+ }
+
+ if( ok )
+ break;
+ }
+
+ QColor aColor;
+ aColor.setHsv( aHue, 255, 255 );
+
+ SALOMEDS::Color aSColor;
+ aSColor.R = aColor.redF();
+ aSColor.G = aColor.greenF();
+ aSColor.B = aColor.blueF();
+
+ return aSColor;
+}
+
+const char* gSeparator = "_"; // character used to separate parameter names
+const char* gDigitsSep = ":"; // character used to separate numeric parameter values (color = r:g:b)
+const char* gPathSep = "|"; // character used to separate paths
+
+/*!
+ * \brief Store visual parameters
+ *
+ * This method is called just before the study document is saved.
+ * Store visual parameters in AttributeParameter attribue(s)
+ */
+void SMESHGUI::storeVisualParameters (int savePoint)
+{
+ // localizing
+ Kernel_Utils::Localizer loc;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+ if (!appStudy || !appStudy->studyDS())
+ return;
+ _PTR(Study) studyDS = appStudy->studyDS();
+
+ // componentName is used for encoding of entries when storing them in IParameters
+ std::string componentName = myComponentSMESH->ComponentDataType();
+ //_PTR(SComponent) aSComponent = studyDS->FindComponent("SMESH");
+ //if (!aSComponent) return;
+
+ // IParameters
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+ componentName.c_str(),
+ savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+ // store map of custom markers
+ const VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
+ if( !aMarkerMap.empty() )
+ {
+ VTK::MarkerMap::const_iterator anIter = aMarkerMap.begin();
+ for( ; anIter != aMarkerMap.end(); anIter++ )
+ {
+ int anId = anIter->first;
+ VTK::MarkerData aMarkerData = anIter->second;
+ std::string aMarkerFileName = aMarkerData.first;
+ VTK::MarkerTexture aMarkerTexture = aMarkerData.second;
+ if( aMarkerTexture.size() < 3 )
+ continue; // should contain at least width, height and the first value
+
+ QString aPropertyName( "texture" );
+ aPropertyName += gSeparator;
+ aPropertyName += QString::number( anId );
+
+ QString aPropertyValue = aMarkerFileName.c_str();
+ aPropertyValue += gPathSep;
+
+ VTK::MarkerTexture::const_iterator aTextureIter = aMarkerTexture.begin();
+ ushort aWidth = *aTextureIter++;
+ ushort aHeight = *aTextureIter++;
+ aPropertyValue += QString::number( aWidth ); aPropertyValue += gDigitsSep;
+ aPropertyValue += QString::number( aHeight ); aPropertyValue += gDigitsSep;
+ for( ; aTextureIter != aMarkerTexture.end(); aTextureIter++ )
+ aPropertyValue += QString::number( *aTextureIter );
+
+ ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
+ }
+ }
+
+ // viewers counters are used for storing view_numbers in IParameters
+ int vtkViewers = 0;
+
+ // main cycle to store parameters of displayed objects
+ QList<SUIT_ViewManager*> lst;
+ QList<SUIT_ViewManager*>::Iterator it;
+ getApp()->viewManagers(lst);
+ for (it = lst.begin(); it != lst.end(); it++)
+ {
+ SUIT_ViewManager* vman = *it;
+ QString vType = vman->getType();
+
+ // saving VTK actors properties
+ if (vType == SVTK_Viewer::Type())
+ {
+ // store the clipping planes attached to the view manager
+ SMESHGUI_ClippingPlaneInfoList aClippingPlaneInfoList;
+ SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter = myClippingPlaneInfoMap.find( vman );
+ if( anIter != myClippingPlaneInfoMap.end() )
+ aClippingPlaneInfoList = anIter->second;
+
+ if( !aClippingPlaneInfoList.empty() ) {
+ SMESHGUI_ClippingPlaneInfoList::const_iterator anIter = aClippingPlaneInfoList.begin();
+ for( int anId = 0; anIter != aClippingPlaneInfoList.end(); anIter++, anId++ )
+ {
+ const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter;
+ SMESH::OrientedPlane* aPlane = aClippingPlaneInfo.Plane;
+
+ QString aPropertyName( "ClippingPlane" );
+ aPropertyName += gSeparator;
+ aPropertyName += QString::number( vtkViewers );
+ aPropertyName += gSeparator;
+ aPropertyName += QString::number( anId );
+
+ QString aPropertyValue = QString::number( (int)aPlane->GetOrientation() ).toLatin1().constData();
+ aPropertyValue += gDigitsSep;
+ aPropertyValue += QString::number( aPlane->GetDistance() ).toLatin1().constData();
+ aPropertyValue += gDigitsSep;
+ aPropertyValue += QString::number( aPlane->myAngle[0] ).toLatin1().constData();
+ aPropertyValue += gDigitsSep;
+ aPropertyValue += QString::number( aPlane->myAngle[1] ).toLatin1().constData();
+
+ ip->setProperty( aPropertyName.toStdString(), aPropertyValue.toStdString() );
+ }
+ }
+
+ QVector<SUIT_ViewWindow*> views = vman->getViews();
+ for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
+ {
+ if (SVTK_ViewWindow* vtkView = dynamic_cast<SVTK_ViewWindow*>(views[i]))
+ {
+ VTK::ActorCollectionCopy aCopy(vtkView->getRenderer()->GetActors());
+ vtkActorCollection* allActors = aCopy.GetActors();
+ allActors->InitTraversal();
+ while (vtkActor* actor = allActors->GetNextActor())
+ {
+ if (actor->GetVisibility()) // store only visible actors
+ {
+ SMESH_Actor* aSmeshActor = 0;
+ if (actor->IsA("SMESH_Actor"))
+ aSmeshActor = SMESH_Actor::SafeDownCast(actor);
+ if (aSmeshActor && aSmeshActor->hasIO())
+ {
+ Handle(SALOME_InteractiveObject) io = aSmeshActor->getIO();
+ if (io->hasEntry())
+ {
+ // entry is "encoded" = 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, vtkParam = vType.toLatin1().data();
+ vtkParam += gSeparator;
+ vtkParam += QString::number(vtkViewers).toLatin1().data();
+ vtkParam += gSeparator;
+
+ // Visibility
+ param = vtkParam + "Visibility";
+ ip->setParameter(entry, param, "On");
+
+ // Representation
+ param = vtkParam + "Representation";
+ ip->setParameter(entry, param, QString::number
+ ((int)aSmeshActor->GetRepresentation()).toLatin1().data());
+
+ // IsShrunk
+ param = vtkParam + "IsShrunk";
+ ip->setParameter(entry, param, QString::number
+ ((int)aSmeshActor->IsShrunk()).toLatin1().data());
+
+ // Displayed entities
+ unsigned int aMode = aSmeshActor->GetEntityMode();
+ bool isE = aMode & SMESH_Actor::eEdges;
+ bool isF = aMode & SMESH_Actor::eFaces;
+ bool isV = aMode & SMESH_Actor::eVolumes;
+ bool is0d = aMode & SMESH_Actor::e0DElements;
+ bool isB = aMode & SMESH_Actor::eBallElem;
+
+ QString modeStr ("e");
+ modeStr += gDigitsSep; modeStr += QString::number(isE);
+ modeStr += gDigitsSep; modeStr += "f";
+ modeStr += gDigitsSep; modeStr += QString::number(isF);
+ modeStr += gDigitsSep; modeStr += "v";
+ modeStr += gDigitsSep; modeStr += QString::number(isV);
+ modeStr += gDigitsSep; modeStr += "0d";
+ modeStr += gDigitsSep; modeStr += QString::number(is0d);
+ modeStr += gDigitsSep; modeStr += "b";
+ modeStr += gDigitsSep; modeStr += QString::number(isB);
+
+ param = vtkParam + "Entities";
+ ip->setParameter(entry, param, modeStr.toLatin1().data());
+
+ // Colors
+ double r, g, b;
+ int delta;
+
+ aSmeshActor->GetSufaceColor(r, g, b, delta);
+ QStringList colorStr;
+ colorStr << "surface";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ colorStr << "backsurface";
+ colorStr << QString::number(delta);
+
+ aSmeshActor->GetVolumeColor(r, g, b, delta);
+ colorStr << "volume";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+ colorStr << QString::number(delta);
+
+ aSmeshActor->GetEdgeColor(r, g, b);
+ colorStr << "edge";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ aSmeshActor->GetNodeColor(r, g, b);
+ colorStr << "node";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ aSmeshActor->GetOutlineColor(r, g, b);
+ colorStr << "outline";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ aSmeshActor->Get0DColor(r, g, b);
+ colorStr << "elem0d";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ aSmeshActor->GetBallColor(r, g, b);
+ colorStr << "ball";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ aSmeshActor->GetFacesOrientationColor(r, g, b);
+ colorStr << "orientation";
+ colorStr << QString::number(r);
+ colorStr << QString::number(g);
+ colorStr << QString::number(b);
+
+ param = vtkParam + "Colors";
+ ip->setParameter(entry, param, qPrintable(colorStr.join(gDigitsSep)));
+
+ // Sizes
+ QStringList sizeStr;
+ sizeStr << "line";
+ sizeStr << QString::number((int)aSmeshActor->GetLineWidth());
+ sizeStr << "outline";
+ sizeStr << QString::number((int)aSmeshActor->GetOutlineWidth());
+ sizeStr << "elem0d";
+ sizeStr << QString::number((int)aSmeshActor->Get0DSize());
+ sizeStr << "ball";
+ sizeStr << QString::number((int)aSmeshActor->GetBallSize());
+ sizeStr << "shrink";
+ sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
+ sizeStr << "orientation";
+ sizeStr << QString::number(aSmeshActor->GetFacesOrientationScale());
+ sizeStr << QString::number(aSmeshActor->GetFacesOrientation3DVectors());
+
+ param = vtkParam + "Sizes";
+ ip->setParameter(entry, param, qPrintable(sizeStr.join(gDigitsSep)));
+
+ // Point marker
+ QString markerStr;
+
+ VTK::MarkerType aMarkerType = aSmeshActor->GetMarkerType();
+ if( aMarkerType == VTK::MT_USER ) {
+ markerStr += "custom";
+ markerStr += gDigitsSep;
+ markerStr += QString::number( aSmeshActor->GetMarkerTexture() );
+ }
+ else {
+ markerStr += "std";
+ markerStr += gDigitsSep;
+ markerStr += QString::number( (int)aMarkerType );
+ markerStr += gDigitsSep;
+ markerStr += QString::number( (int)aSmeshActor->GetMarkerScale() );
+ }
+
+ param = vtkParam + "PointMarker";
+ ip->setParameter(entry, param, markerStr.toLatin1().data());
+
+ // Opacity
+ param = vtkParam + "Opacity";
+ ip->setParameter(entry, param,
+ QString::number(aSmeshActor->GetOpacity()).toLatin1().data());
+
+ // Clipping
+ param = vtkParam + "ClippingPlane";
+ int aPlaneId = 0;
+ if( !aClippingPlaneInfoList.empty() ) {
+ SMESHGUI_ClippingPlaneInfoList::const_iterator anIter1 = aClippingPlaneInfoList.begin();
+ for( int anId = 0; anIter1 != aClippingPlaneInfoList.end(); anIter1++, anId++ )
+ {
+ const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter1;
+ std::list<vtkActor*> anActorList = aClippingPlaneInfo.ActorList;
+ SMESH::TActorList::iterator anIter2 = anActorList.begin();
+ for ( ; anIter2 != anActorList.end(); anIter2++ ) {
+ if( aSmeshActor == *anIter2 ) {
+ ip->setParameter( entry, param + QString::number( ++aPlaneId ).toLatin1().constData(),
+ QString::number( anId ).toLatin1().constData() );
+ break;
+ }
+ }
+ }
+ }
+ if( aPlaneId == 0 )
+ ip->setParameter( entry, param, "Off" );
+ } // if (io->hasEntry())
+ } // SMESH_Actor && hasIO
+ } // isVisible
+ } // while.. actors traversal
+ } // if (vtkView)
+ } // for (views)
+ vtkViewers++;
+ } // if (SVTK view model)
+ } // for (viewManagers)
+}
+
+// data structures for clipping planes processing
+typedef struct {
+ int Id;
+ vtkIdType Orientation;
+ double Distance;
+ double Angle[2];
+} TPlaneData;
+typedef std::list<TPlaneData> TPlaneDataList;
+typedef std::map<int, TPlaneDataList> TPlaneDataMap;
+
+typedef std::list<vtkActor*> TActorList;
+typedef struct {
+ int PlaneId;
+ TActorList ActorList;
+ SUIT_ViewManager* ViewManager;
+} TPlaneInfo;
+typedef std::list<TPlaneInfo> TPlaneInfoList;
+typedef std::map<int, TPlaneInfoList> TPlaneInfoMap;
+
+/*!
+ * \brief Restore visual parameters
+ *
+ * This method is called after the study document is opened.
+ * Restore visual parameters from AttributeParameter attribue(s)
+ */
+void SMESHGUI::restoreVisualParameters (int savePoint)
+{
+ // localizing
+ Kernel_Utils::Localizer loc;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>(application()->activeStudy());
+ if (!appStudy || !appStudy->studyDS())
+ return;
+ _PTR(Study) studyDS = appStudy->studyDS();
+
+ // componentName is used for encoding of entries when storing them in IParameters
+ std::string componentName = myComponentSMESH->ComponentDataType();
+ //_PTR(SComponent) aSComponent = studyDS->FindComponent("GEOM");
+ //if (!aSComponent) return;
+
+ // IParameters
+ _PTR(AttributeParameter) ap = studyDS->GetModuleParameters("Interface Applicative",
+ componentName.c_str(),
+ savePoint);
+ _PTR(IParameters) ip = ClientFactory::getIParameters(ap);
+
+ // restore map of custom markers and map of clipping planes
+ VTK::MarkerMap& aMarkerMap = myMarkerMap[ studyDS->StudyId() ];
+ TPlaneDataMap aPlaneDataMap;
+
+ std::vector<std::string> properties = ip->getProperties();
+ for (std::vector<std::string>::iterator propIt = properties.begin(); propIt != properties.end(); ++propIt)
+ {
+ std::string property = *propIt;
+ QString aPropertyName( property.c_str() );
+ QString aPropertyValue( ip->getProperty( property ).c_str() );
+
+ QStringList aPropertyNameList = aPropertyName.split( gSeparator, QString::SkipEmptyParts );
+ if( aPropertyNameList.isEmpty() )
+ continue;
+
+ QString aPropertyType = aPropertyNameList[0];
+ if( aPropertyType == "texture" )
+ {
+ if( aPropertyNameList.size() != 2 )
+ continue;
+
+ bool ok = false;
+ int anId = aPropertyNameList[1].toInt( &ok );
+ if( !ok || anId < 1 )
+ continue;
+
+ QStringList aPropertyValueList = aPropertyValue.split( gPathSep, QString::SkipEmptyParts );
+ if( aPropertyValueList.size() != 2 )
+ continue;
+
+ std::string aMarkerFileName = aPropertyValueList[0].toStdString();
+ QString aMarkerTextureString = aPropertyValueList[1];
+ QStringList aMarkerTextureStringList = aMarkerTextureString.split( gDigitsSep, QString::SkipEmptyParts );
+ if( aMarkerTextureStringList.size() != 3 )
+ continue;
+
+ ok = false;
+ ushort aWidth = aMarkerTextureStringList[0].toUShort( &ok );
+ if( !ok )
+ continue;
+
+ ok = false;
+ ushort aHeight = aMarkerTextureStringList[1].toUShort( &ok );
+ if( !ok )
+ continue;
+
+ VTK::MarkerTexture aMarkerTexture;
+ aMarkerTexture.push_back( aWidth );
+ aMarkerTexture.push_back( aHeight );
+
+ QString aMarkerTextureData = aMarkerTextureStringList[2];
+ for( int i = 0, n = aMarkerTextureData.length(); i < n; i++ )
+ {
+ QChar aChar = aMarkerTextureData.at( i );
+ if( aChar.isDigit() )
+ aMarkerTexture.push_back( aChar.digitValue() );
+ }
+
+ aMarkerMap[ anId ] = VTK::MarkerData( aMarkerFileName, aMarkerTexture );
+ }
+ else if( aPropertyType == "ClippingPlane" )
+ {
+ if( aPropertyNameList.size() != 3 )
+ continue;
+
+ bool ok = false;
+ int aViewId = aPropertyNameList[1].toInt( &ok );
+ if( !ok || aViewId < 0 )
+ continue;
+
+ ok = false;
+ int aClippingPlaneId = aPropertyNameList[2].toInt( &ok );
+ if( !ok || aClippingPlaneId < 0 )
+ continue;
+
+ QStringList aPropertyValueList = aPropertyValue.split( gDigitsSep, QString::SkipEmptyParts );
+ if( aPropertyValueList.size() != 4 )
+ continue;
+
+ TPlaneData aPlaneData;
+ aPlaneData.Id = aClippingPlaneId;
+
+ ok = false;
+ aPlaneData.Orientation = aPropertyValueList[0].toInt( &ok );
+ if( !ok )
+ continue;
+
+ ok = false;
+ aPlaneData.Distance = aPropertyValueList[1].toDouble( &ok );
+ if( !ok )
+ continue;
+
+ ok = false;
+ aPlaneData.Angle[0] = aPropertyValueList[2].toDouble( &ok );
+ if( !ok )
+ continue;
+
+ ok = false;
+ aPlaneData.Angle[1] = aPropertyValueList[3].toDouble( &ok );
+ if( !ok )
+ continue;
+
+ TPlaneDataList& aPlaneDataList = aPlaneDataMap[ aViewId ];
+ aPlaneDataList.push_back( aPlaneData );
+ }
+ }
+
+ TPlaneInfoMap aPlaneInfoMap;
+
+ std::vector<std::string> entries = ip->getEntries();
+
+ for (std::vector<std::string>::iterator entIt = entries.begin(); entIt != entries.end(); ++entIt)
+ {
+ // entry is a normal entry - it should be "decoded" (setting base adress of component)
+ QString entry (ip->decodeEntry(*entIt).c_str());