+
+ QVector<SUIT_ViewWindow*> aViews = mgr->getViews();
+ for(int i = 0; i < aViews.count() ; i++){
+ SUIT_ViewWindow *sf = aViews[i];
+ connectView( sf );
+ }
+ }
+}
+
+void SMESHGUI::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
+{
+ if( theViewManager && theViewManager->getType() == SVTK_Viewer::Type() )
+ myClippingPlaneInfoMap.erase( theViewManager );
+}
+
+void SMESHGUI::addActorAsObserver( SMESH_Actor* theActor )
+{
+ theActor->AddObserver( SMESH::DeleteActorEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority );
+}
+
+void SMESHGUI::ProcessEvents( vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData )
+{
+ if( SMESHGUI* aSMESHGUI = reinterpret_cast<SMESHGUI*>( theClientData ) ) {
+ if( theObject && theEvent == SMESH::DeleteActorEvent ) {
+ if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( theObject ) ) {
+ SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = aSMESHGUI->getClippingPlaneInfoMap();
+ SMESHGUI_ClippingPlaneInfoMap::iterator anIter1 = aClippingPlaneInfoMap.begin();
+ for( ; anIter1 != aClippingPlaneInfoMap.end(); anIter1++ ) {
+ SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
+ SMESHGUI_ClippingPlaneInfoList::iterator anIter2 = aClippingPlaneInfoList.begin();
+ for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
+ SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
+ std::list<vtkActor*>& anActorList = aClippingPlaneInfo.ActorList;
+ SMESH::TActorList::iterator anIter3 = anActorList.begin();
+ for ( ; anIter3 != anActorList.end(); anIter3++ ) {
+ if( anActor == *anIter3 ) {
+ anActorList.erase( anIter3 );
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+void SMESHGUI::createPreferences()
+{
+ // General tab ------------------------------------------------------------------------
+ int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
+
+ int autoUpdate = addPreference( tr( "PREF_AUTO_UPDATE" ), genTab, LightApp_Preferences::Auto, "SMESH", "auto_update" );
+ int lim = addPreference( tr( "PREF_UPDATE_LIMIT" ), autoUpdate, LightApp_Preferences::IntSpin, "SMESH", "update_limit" );
+ setPreferenceProperty( lim, "min", 0 );
+ setPreferenceProperty( lim, "max", 100000000 );
+ setPreferenceProperty( lim, "step", 1000 );
+ setPreferenceProperty( lim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
+
+ int qaGroup = addPreference( tr( "PREF_GROUP_QUALITY" ), genTab );
+ setPreferenceProperty( qaGroup, "columns", 2 );
+ addPreference( tr( "PREF_DISPLAY_ENTITY" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "display_entity" );
+ addPreference( tr( "PREF_PRECISION_USE" ), qaGroup, LightApp_Preferences::Bool, "SMESH", "use_precision" );
+ int prec = addPreference( tr( "PREF_PRECISION_VALUE" ), qaGroup, LightApp_Preferences::IntSpin, "SMESH", "controls_precision" );
+ setPreferenceProperty( prec, "min", 0 );
+ setPreferenceProperty( prec, "max", 16 );
+ int doubleNodesTol = addPreference( tr( "PREF_EQUAL_NODES_TOL" ), qaGroup, LightApp_Preferences::DblSpin, "SMESH", "equal_nodes_tolerance" );
+ setPreferenceProperty( doubleNodesTol, "precision", 10 );
+ setPreferenceProperty( doubleNodesTol, "min", 0.0000000001 );
+ setPreferenceProperty( doubleNodesTol, "max", 1000000.0 );
+ setPreferenceProperty( doubleNodesTol, "step", 0.0000001 );
+
+ int dispgroup = addPreference( tr( "PREF_DISPLAY_MODE" ), genTab );
+ setPreferenceProperty( dispgroup, "columns", 2 );
+ int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), dispgroup, LightApp_Preferences::Selector, "SMESH", "display_mode" );
+ QStringList modes;
+ modes.append( tr("MEN_WIRE") );
+ modes.append( tr("MEN_SHADE") );
+ modes.append( tr("MEN_NODES") );
+ modes.append( tr("MEN_SHRINK") );
+ QList<QVariant> indices;
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ indices.append( 3 );
+ setPreferenceProperty( dispmode, "strings", modes );
+ setPreferenceProperty( dispmode, "indexes", indices );
+
+ int arcgroup = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), genTab );
+ setPreferenceProperty( arcgroup, "columns", 2 );
+ int quadraticmode = addPreference( tr( "QUADRATIC_REPRESENT_MODE" ), arcgroup, LightApp_Preferences::Selector, "SMESH", "quadratic_mode" );
+ QStringList quadraticModes;
+ quadraticModes.append(tr("MEN_LINE_REPRESENTATION"));
+ quadraticModes.append(tr("MEN_ARC_REPRESENTATION"));
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ setPreferenceProperty( quadraticmode, "strings", quadraticModes );
+ setPreferenceProperty( quadraticmode, "indexes", indices );
+
+ int maxAngle = addPreference( tr( "MAX_ARC_ANGLE" ), arcgroup, LightApp_Preferences::IntSpin,
+ "SMESH", "max_angle" );
+ setPreferenceProperty( maxAngle, "min", 1 );
+ setPreferenceProperty( maxAngle, "max", 90 );
+
+
+
+ int exportgroup = addPreference( tr( "PREF_GROUP_EXPORT" ), genTab );
+ setPreferenceProperty( exportgroup, "columns", 2 );
+ addPreference( tr( "PREF_AUTO_GROUPS" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "auto_groups" );
+ addPreference( tr( "PREF_RENUMBER" ), exportgroup, LightApp_Preferences::Bool, "SMESH", "renumbering" );
+
+ int computeGroup = addPreference( tr( "PREF_GROUP_COMPUTE" ), genTab );
+ setPreferenceProperty( computeGroup, "columns", 2 );
+ int notifyMode = addPreference( tr( "PREF_NOTIFY_MODE" ), computeGroup, LightApp_Preferences::Selector, "SMESH", "show_result_notification" );
+ modes.clear();
+ modes.append( tr( "PREF_NOTIFY_NEVER" ) );
+ modes.append( tr( "PREF_NOTIFY_ERROR" ) );
+ modes.append( tr( "PREF_NOTIFY_ALWAYS" ) );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ indices.append( 2 );
+ setPreferenceProperty( notifyMode, "strings", modes );
+ setPreferenceProperty( notifyMode, "indexes", indices );
+
+ int infoGroup = addPreference( tr( "PREF_GROUP_INFO" ), genTab );
+ setPreferenceProperty( infoGroup, "columns", 2 );
+ int elemInfo = addPreference( tr( "PREF_ELEM_INFO" ), infoGroup, LightApp_Preferences::Selector, "SMESH", "mesh_elem_info" );
+ modes.clear();
+ modes.append( tr( "PREF_ELEM_INFO_SIMPLE" ) );
+ modes.append( tr( "PREF_ELEM_INFO_TREE" ) );
+ indices.clear();
+ indices.append( 0 );
+ indices.append( 1 );
+ setPreferenceProperty( elemInfo, "strings", modes );
+ setPreferenceProperty( elemInfo, "indexes", indices );
+ int nodesLim = addPreference( tr( "PREF_GPP_NODES_LIMIT" ), infoGroup, LightApp_Preferences::IntSpin, "SMESH", "info_groups_nodes_limit" );
+ setPreferenceProperty( nodesLim, "min", 0 );
+ setPreferenceProperty( nodesLim, "max", 10000000 );
+ setPreferenceProperty( nodesLim, "step", 10000 );
+ setPreferenceProperty( nodesLim, "special", tr( "PREF_UPDATE_LIMIT_NOLIMIT" ) );
+ addPreference( tr( "PREF_ELEM_INFO_GRP_DETAILS" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "elem_info_grp_details" );
+ addPreference( tr( "PREF_DUMP_BASE_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_base" );
+ addPreference( tr( "PREF_DUMP_ELEM_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_elem" );
+ addPreference( tr( "PREF_DUMP_ADD_INFO" ), infoGroup, LightApp_Preferences::Bool, "SMESH", "info_dump_add" );
+
+ int segGroup = addPreference( tr( "PREF_GROUP_SEGMENT_LENGTH" ), genTab );
+ setPreferenceProperty( segGroup, "columns", 2 );
+ int segLen = addPreference( tr( "PREF_SEGMENT_LENGTH" ), segGroup, LightApp_Preferences::IntSpin,
+ "SMESH", "segmentation" );
+ setPreferenceProperty( segLen, "min", 1 );
+ setPreferenceProperty( segLen, "max", 10000000 );
+ int nbSeg = addPreference( tr( "PREF_NB_SEGMENTS" ), segGroup, LightApp_Preferences::IntSpin,
+ "SMESH", "nb_segments_per_edge" );
+ setPreferenceProperty( nbSeg, "min", 1 );
+ setPreferenceProperty( nbSeg, "max", 10000000 );
+
+ int loadGroup = addPreference( tr( "SMESH_PREF_MESH_LOADING" ), genTab );
+ addPreference( tr( "PREF_FORGET_MESH_AT_HYP_MODIF" ), loadGroup, LightApp_Preferences::Bool,
+ "SMESH", "forget_mesh_on_hyp_modif" );
+
+
+ // Quantities with individual precision settings
+ int precGroup = addPreference( tr( "SMESH_PREF_GROUP_PRECISION" ), genTab );
+ setPreferenceProperty( precGroup, "columns", 2 );
+
+ const int nbQuantities = 6;
+ int precs[nbQuantities], ii = 0;
+ precs[ii++] = addPreference( tr( "SMESH_PREF_length_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "length_precision" );
+ precs[ii++] = addPreference( tr( "SMESH_PREF_angle_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "angle_precision" );
+ precs[ii++] = addPreference( tr( "SMESH_PREF_len_tol_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "len_tol_precision" );
+ precs[ii++] = addPreference( tr( "SMESH_PREF_parametric_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "parametric_precision" );
+ precs[ii++] = addPreference( tr( "SMESH_PREF_area_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "area_precision" );
+ precs[ii ] = addPreference( tr( "SMESH_PREF_vol_precision" ), precGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "vol_precision" );
+
+ // Set property for precision value for spinboxes
+ for ( ii = 0; ii < nbQuantities; ii++ ){
+ setPreferenceProperty( precs[ii], "min", -14 );
+ setPreferenceProperty( precs[ii], "max", 14 );
+ setPreferenceProperty( precs[ii], "precision", 2 );
+ }
+
+ int previewGroup = addPreference( tr( "SMESH_PREF_GROUP_PREVIEW" ), genTab );
+ setPreferenceProperty( previewGroup, "columns", 2 );
+ int chunkSize = addPreference( tr( "PREF_PREVIEW_CHUNK_SIZE" ), previewGroup, LightApp_Preferences::IntSpin, "SMESH", "preview_actor_chunk_size" );
+ setPreferenceProperty( chunkSize, "min", 1 );
+ setPreferenceProperty( chunkSize, "max", 1000 );
+ setPreferenceProperty( chunkSize, "step", 50 );
+
+ int pyDumpGroup = addPreference( tr( "PREF_PYTHON_DUMP" ), genTab );
+ addPreference( tr( "PREF_HISTORICAL_PYTHON_DUMP" ), pyDumpGroup, LightApp_Preferences::Bool, "SMESH", "historical_python_dump" );
+
+ // Mesh tab ------------------------------------------------------------------------
+ int meshTab = addPreference( tr( "PREF_TAB_MESH" ) );
+ int nodeGroup = addPreference( tr( "PREF_GROUP_NODES" ), meshTab );
+ setPreferenceProperty( nodeGroup, "columns", 3 );
+
+ addPreference( tr( "PREF_COLOR" ), nodeGroup, LightApp_Preferences::Color, "SMESH", "node_color" );
+
+ int typeOfMarker = addPreference( tr( "PREF_TYPE_OF_MARKER" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "type_of_marker" );
+
+ SUIT_ResourceMgr* aResourceMgr = SMESH::GetResourceMgr(this);
+ QList<QVariant> aMarkerTypeIndicesList;
+ QList<QVariant> aMarkerTypeIconsList;
+ for ( int i = VTK::MT_POINT; i < VTK::MT_USER; i++ ) {
+ QString icoFile = QString( "ICON_VERTEX_MARKER_%1" ).arg( i );
+ QPixmap pixmap = aResourceMgr->loadPixmap( "VTKViewer", tr( qPrintable( icoFile ) ) );
+ aMarkerTypeIndicesList << i;
+ aMarkerTypeIconsList << pixmap;
+ }
+ setPreferenceProperty( typeOfMarker, "indexes", aMarkerTypeIndicesList );
+ setPreferenceProperty( typeOfMarker, "icons", aMarkerTypeIconsList );
+
+ int markerScale = addPreference( tr( "PREF_MARKER_SCALE" ), nodeGroup, LightApp_Preferences::Selector, "SMESH", "marker_scale" );
+
+ QList<QVariant> aMarkerScaleIndicesList;
+ QStringList aMarkerScaleValuesList;
+ for ( int i = VTK::MS_10; i <= VTK::MS_70; i++ ) {
+ aMarkerScaleIndicesList << i;
+ aMarkerScaleValuesList << QString::number( (i-(int)VTK::MS_10)*0.5 + 1.0 );
+ }
+ setPreferenceProperty( markerScale, "strings", aMarkerScaleValuesList );
+ setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList );
+
+ int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab );
+ //setPreferenceProperty( elemGroup, "columns", 2 );
+
+ int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" );
+ setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") );
+ ColorId = addPreference( tr( "PREF_VOLUME" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "volume_color" );
+ setPreferenceProperty( ColorId, "text", tr("PREF_REVERSEDVOLUME") );
+ addPreference( tr( "PREF_COLOR_0D" ), elemGroup, LightApp_Preferences::Color, "SMESH", "elem0d_color" );
+ addPreference( tr( "PREF_BALL_COLOR" ), elemGroup, LightApp_Preferences::Color, "SMESH", "ball_elem_color" );
+ addPreference( tr( "PREF_OUTLINE" ), elemGroup, LightApp_Preferences::Color, "SMESH", "outline_color" );
+ addPreference( tr( "PREF_WIREFRAME" ), elemGroup, LightApp_Preferences::Color, "SMESH", "wireframe_color" );
+
+
+ int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab );
+ setPreferenceProperty( grpGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_GRP_NAMES" ), grpGroup, LightApp_Preferences::Color, "SMESH", "group_name_color" );
+ addPreference( tr( "PREF_GRP_DEF_COLOR" ), grpGroup, LightApp_Preferences::Color, "SMESH", "default_grp_color" );
+
+ int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
+ int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
+ int elemW = addPreference(tr("PREF_WIDTH"), elemGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "element_width");
+ int outW = addPreference(tr("PREF_OUTLINE_WIDTH"), elemGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "outline_width");
+ int shrink = addPreference(tr("PREF_SHRINK_COEFF"), elemGroup,
+ LightApp_Preferences::IntSpin, "SMESH", "shrink_coeff");
+
+ setPreferenceProperty( size0d, "min", 1 );
+ setPreferenceProperty( size0d, "max", 10 );
+
+ setPreferenceProperty( ballSize, "min", 1 );
+ setPreferenceProperty( ballSize, "max", 10 );
+
+ setPreferenceProperty( elemW, "min", 1 );
+ setPreferenceProperty( elemW, "max", 5 );
+
+ setPreferenceProperty( outW, "min", 1 );
+ setPreferenceProperty( outW, "max", 5 );
+
+ setPreferenceProperty( shrink, "min", 0 );
+ setPreferenceProperty( shrink, "max", 100 );
+
+ int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
+ setPreferenceProperty( numGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
+ addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_node_font", true );
+
+ addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
+ addVtkFontPref( tr( "PREF_NUMBERING_FONT" ), numGroup, "numbering_elem_font", true );
+
+ int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
+ setPreferenceProperty( orientGroup, "columns", 1 );
+
+ addPreference( tr( "PREF_ORIENTATION_COLOR" ), orientGroup, LightApp_Preferences::Color, "SMESH", "orientation_color" );
+ int orientScale = addPreference( tr( "PREF_ORIENTATION_SCALE" ), orientGroup, LightApp_Preferences::DblSpin, "SMESH", "orientation_scale" );
+
+ setPreferenceProperty( orientScale, "min", 0.05 );
+ setPreferenceProperty( orientScale, "max", 0.5 );
+ setPreferenceProperty( orientScale, "step", 0.05 );
+
+ addPreference( tr( "PREF_ORIENTATION_3D_VECTORS" ), orientGroup, LightApp_Preferences::Bool, "SMESH", "orientation_3d_vectors" );
+
+ // Selection tab ------------------------------------------------------------------------
+ int selTab = addPreference( tr( "PREF_TAB_SELECTION" ) );
+
+ int selGroup = addPreference( tr( "PREF_GROUP_SELECTION" ), selTab );
+ setPreferenceProperty( selGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_OBJECT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_object_color" );
+ addPreference( tr( "PREF_ELEMENT_COLOR" ), selGroup, LightApp_Preferences::Color, "SMESH", "selection_element_color" );
+
+ int preGroup = addPreference( tr( "PREF_GROUP_PRESELECTION" ), selTab );
+ setPreferenceProperty( preGroup, "columns", 2 );
+
+ addPreference( tr( "PREF_HIGHLIGHT_COLOR" ), preGroup, LightApp_Preferences::Color, "SMESH", "highlight_color" );
+
+ int precSelGroup = addPreference( tr( "PREF_GROUP_PRECISION" ), selTab );
+ 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());
+
+ // Check that the entry corresponds to a real object in the Study
+ // as the object may be deleted or modified after the visual state is saved.
+ _PTR(SObject) so = studyDS->FindObjectID(entry.toLatin1().data());
+ if (!so) continue; //Skip the not existent entry
+
+ std::vector<std::string> paramNames = ip->getAllParameterNames( *entIt );
+ std::vector<std::string> paramValues = ip->getAllParameterValues( *entIt );
+
+ std::vector<std::string>::iterator namesIt = paramNames.begin();
+ std::vector<std::string>::iterator valuesIt = paramValues.begin();
+
+ // actors are stored in a map after displaying of them for
+ // quicker access in the future: map < viewID to actor >
+ NCollection_DataMap<int, SMESH_Actor*> vtkActors;
+
+ for (; namesIt != paramNames.end(); ++namesIt, ++valuesIt)
+ {
+ // visual parameters are stored in strings as follows: ViewerType_ViewIndex_ParamName.
+ // '_' is used as separator and should not be used in viewer type or parameter names.
+ QStringList lst = QString((*namesIt).c_str()).split(gSeparator, QString::SkipEmptyParts);
+ if (lst.size() != 3)
+ continue;
+
+ QString viewerTypStr = lst[0];
+ QString viewIndexStr = lst[1];
+ QString paramNameStr = lst[2];
+
+ bool ok;
+ int viewIndex = viewIndexStr.toUInt(&ok);
+ if (!ok) // bad conversion of view index to integer
+ continue;
+
+ // viewers
+ if (viewerTypStr == SVTK_Viewer::Type())
+ {
+ SMESH_Actor* aSmeshActor = 0;
+ if (vtkActors.IsBound(viewIndex))
+ aSmeshActor = vtkActors.Find(viewIndex);
+
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(viewerTypStr, lst);
+
+ // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+ SUIT_ViewManager* vman = NULL;
+ if (viewIndex >= 0 && viewIndex < lst.count())
+ vman = lst.at(viewIndex);
+
+ if (paramNameStr == "Visibility")
+ {
+ if (!aSmeshActor && displayer() && vman)
+ {
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ // SVTK view model can be casted to SALOME_View
+ displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
+
+ // store displayed actor in a temporary map for quicker
+ // access later when restoring other parameters
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+ vtkRenderer* Renderer = vtkView->getRenderer();
+ VTK::ActorCollectionCopy aCopy(Renderer->GetActors());
+ vtkActorCollection* theActors = aCopy.GetActors();
+ theActors->InitTraversal();
+ bool isFound = false;
+ vtkActor *ac = theActors->GetNextActor();
+ for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
+ if (ac->IsA("SMESH_Actor")) {
+ SMESH_Actor* aGeomAc = SMESH_Actor::SafeDownCast(ac);
+ if (aGeomAc->hasIO()) {
+ Handle(SALOME_InteractiveObject) io =
+ Handle(SALOME_InteractiveObject)::DownCast(aGeomAc->getIO());
+ if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
+ isFound = true;
+ vtkActors.Bind(viewIndex, aGeomAc);
+ }
+ }
+ }
+ }
+ }
+ } // if (paramNameStr == "Visibility")
+ else
+ {
+ // the rest properties "work" with SMESH_Actor
+ if (aSmeshActor)
+ {
+ QString val ((*valuesIt).c_str());
+
+ // Representation
+ if (paramNameStr == "Representation") {
+ aSmeshActor->SetRepresentation((SMESH_Actor::EReperesent)val.toInt());
+ }
+ // IsShrunk
+ else if (paramNameStr == "IsShrunk") {
+ if (val.toInt()) {
+ if (!aSmeshActor->IsShrunk())
+ aSmeshActor->SetShrink();
+ }
+ else {
+ if (aSmeshActor->IsShrunk())
+ aSmeshActor->UnShrink();
+ }
+ }
+ // Displayed entities
+ else if (paramNameStr == "Entities") {
+ QStringList mode = val.split(gDigitsSep, QString::SkipEmptyParts);
+ int aEntityMode = SMESH_Actor::eAllEntity;
+ for ( int i = 0; i < mode.count(); i+=2 ) {
+ if ( i < mode.count()-1 ) {
+ QString type = mode[i];
+ bool val = mode[i+1].toInt();
+ if ( type == "e" && !val )
+ aEntityMode = aEntityMode & ~SMESH_Actor::eEdges;
+ else if ( type == "f" && !val )
+ aEntityMode = aEntityMode & ~SMESH_Actor::eFaces;
+ else if ( type == "v" && !val )
+ aEntityMode = aEntityMode & ~SMESH_Actor::eVolumes;
+ else if ( type == "0d" && !val )
+ aEntityMode = aEntityMode & ~SMESH_Actor::e0DElements;
+ else if ( type == "b" && !val )
+ aEntityMode = aEntityMode & ~SMESH_Actor::eBallElem;
+ }
+ }
+ aSmeshActor->SetEntityMode( aEntityMode );
+ }
+ // Colors
+ else if (paramNameStr == "Colors") {
+ QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
+ QColor nodeColor;
+ QColor edgeColor;
+ QColor faceColor;
+ QColor volumeColor;
+ QColor elem0dColor;
+ QColor ballColor;
+ QColor outlineColor;
+ QColor orientationColor;
+ int deltaF;
+ int deltaV;
+ QColor c;
+ double r, g, b;
+ bool bOk;
+ // below lines are required to get default values for delta coefficients
+ // of backface color for faces and color of reversed volumes
+ SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
+ SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
+ for ( int i = 0; i < colors.count(); i++ ) {
+ QString type = colors[i];
+ if ( type == "surface" ) {
+ // face color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ faceColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "backsurface" ) {
+ // backface color can be defined in several ways
+ // - in old versions, it is set as rgb triple r:g:b - this was is unsupported now
+ // - in latest versions, it is set as delta coefficient
+ bool rgbOk = false, deltaOk;
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ int delta = colors[i+1].toInt( &deltaOk );
+ i++; // shift index
+ if ( i+1 < colors.count() ) // index is shifted to 1
+ g = colors[i+1].toDouble( &rgbOk );
+ if ( rgbOk ) i++; // shift index
+ if ( rgbOk && i+1 < colors.count() ) // index is shifted to 2
+ b = colors[i+1].toDouble( &rgbOk );
+ if ( rgbOk ) i++;
+ // - as currently there's no way to set directly backsurface color as it was before,
+ // we ignore old dump where r,g,b triple was set
+ // - also we check that delta parameter is set properly
+ if ( !rgbOk && deltaOk )
+ deltaF = delta;
+ }
+ else if ( type == "volume" ) {
+ // volume color is set by 4 values r:g:b:delta, where
+ // - r,g,b - is a normal volume rgb color components
+ // - delta - is a reversed volume color delta coefficient
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+4 >= colors.count() ) break; // format error
+ int delta = colors[i+4].toInt( &bOk );
+ if ( !bOk ) break; // format error
+ volumeColor.setRgbF( r, g, b );
+ deltaV = delta;
+ i += 4;
+ }
+ else if ( type == "edge" ) {
+ // edge color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ edgeColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "node" ) {
+ // node color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ nodeColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "elem0d" ) {
+ // 0d element color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ elem0dColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "ball" ) {
+ // ball color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ ballColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "outline" ) {
+ // outline color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ outlineColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ else if ( type == "orientation" ) {
+ // orientation color is set by 3 values r:g:b, where
+ // - r,g,b - is rgb color components
+ if ( i+1 >= colors.count() ) break; // format error
+ r = colors[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= colors.count() ) break; // format error
+ g = colors[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+3 >= colors.count() ) break; // format error
+ b = colors[i+3].toDouble( &bOk ); if ( !bOk ) break; // format error
+ orientationColor.setRgbF( r, g, b );
+ i += 3;
+ }
+ }
+ // node color
+ if ( nodeColor.isValid() )
+ aSmeshActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() );
+ // edge color
+ if ( edgeColor.isValid() )
+ aSmeshActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() );
+ // face color
+ if ( faceColor.isValid() )
+ aSmeshActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
+ // volume color
+ if ( volumeColor.isValid() )
+ aSmeshActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV );
+ else if ( faceColor.isValid() ) // backward compatibility (no separate color for volumes)
+ aSmeshActor->SetVolumeColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF );
+ // 0d element color
+ if ( elem0dColor.isValid() )
+ aSmeshActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() );
+ // ball color
+ if ( ballColor.isValid() )
+ aSmeshActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
+ // outline color
+ if ( outlineColor.isValid() )
+ aSmeshActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() );
+ // orientation color
+ if ( orientationColor.isValid() )
+ aSmeshActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
+ }
+ // Sizes
+ else if (paramNameStr == "Sizes") {
+ QStringList sizes = val.split(gDigitsSep, QString::SkipEmptyParts);
+ bool bOk;
+ int lineWidth = -1;
+ int outlineWidth = -1;
+ int elem0dSize = -1;
+ int ballSize = -1;
+ double shrinkSize = -1;
+ double orientationSize = -1;
+ bool orientation3d = false;
+ for ( int i = 0; i < sizes.count(); i++ ) {
+ QString type = sizes[i];
+ if ( type == "line" ) {
+ // line (wireframe) width is given as single integer value
+ if ( i+1 >= sizes.count() ) break; // format error
+ int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
+ lineWidth = v;
+ i++;
+ }
+ if ( type == "outline" ) {
+ // outline width is given as single integer value
+ if ( i+1 >= sizes.count() ) break; // format error
+ int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
+ outlineWidth = v;
+ i++;
+ }
+ else if ( type == "elem0d" ) {
+ // 0d element size is given as single integer value
+ if ( i+1 >= sizes.count() ) break; // format error
+ int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
+ elem0dSize = v;
+ i++;
+ }
+ else if ( type == "ball" ) {
+ // ball size is given as single integer value
+ if ( i+1 >= sizes.count() ) break; // format error
+ int v = sizes[i+1].toInt( &bOk ); if ( !bOk ) break; // format error
+ ballSize = v;
+ i++;
+ }
+ else if ( type == "shrink" ) {
+ // shrink factor is given as single floating point value
+ if ( i+1 >= sizes.count() ) break; // format error
+ double v = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ shrinkSize = v;
+ i++;
+ }
+ else if ( type == "orientation" ) {
+ // orientation vectors are specified by two values size:3d, where
+ // - size - is a floating point value specifying scale factor
+ // - 3d - is a boolean
+ if ( i+1 >= sizes.count() ) break; // format error
+ double v1 = sizes[i+1].toDouble( &bOk ); if ( !bOk ) break; // format error
+ if ( i+2 >= sizes.count() ) break; // format error
+ int v2 = sizes[i+2].toInt( &bOk ); if ( !bOk ) break; // format error
+ orientationSize = v1;
+ orientation3d = (bool)v2;
+ i += 2;
+ }
+ }
+ // line (wireframe) width
+ if ( lineWidth > 0 )
+ aSmeshActor->SetLineWidth( lineWidth );
+ // outline width
+ if ( outlineWidth > 0 )
+ aSmeshActor->SetOutlineWidth( outlineWidth );
+ else if ( lineWidth > 0 ) // backward compatibility (no separate width for outlines)
+ aSmeshActor->SetOutlineWidth( lineWidth );
+ // 0d element size
+ if ( elem0dSize > 0 )
+ aSmeshActor->Set0DSize( elem0dSize );
+ // ball size
+ if ( ballSize > 0 )
+ aSmeshActor->SetBallSize( ballSize );
+ // shrink factor
+ if ( shrinkSize > 0 )
+ aSmeshActor->SetShrinkFactor( shrinkSize );
+ // orientation vectors
+ if ( orientationSize > 0 ) {
+ aSmeshActor->SetFacesOrientationScale( orientationSize );
+ aSmeshActor->SetFacesOrientation3DVectors( orientation3d );
+ }
+ }
+ // Point marker
+ else if (paramNameStr == "PointMarker") {
+ QStringList data = val.split(gDigitsSep, QString::SkipEmptyParts);
+ if( data.count() >= 2 ) {
+ bool ok = false;
+ int aParam1 = data[1].toInt( &ok );
+ if( ok ) {
+ if( data[0] == "std" && data.count() == 3 ) {
+ int aParam2 = data[2].toInt( &ok );
+ aSmeshActor->SetMarkerStd( (VTK::MarkerType)aParam1, (VTK::MarkerScale)aParam2 );
+ }
+ else if( data[0] == "custom" ) {
+ VTK::MarkerMap::const_iterator markerIt = aMarkerMap.find( aParam1 );
+ if( markerIt != aMarkerMap.end() ) {
+ VTK::MarkerData aMarkerData = markerIt->second;
+ aSmeshActor->SetMarkerTexture( aParam1, aMarkerData.second );
+ }
+ }
+ }
+ }
+ }
+ // Opacity
+ else if (paramNameStr == "Opacity") {
+ aSmeshActor->SetOpacity(val.toFloat());
+ }
+ // Clipping
+ else if (paramNameStr.startsWith("ClippingPlane")) {
+ QStringList vals = val.split(gDigitsSep, QString::SkipEmptyParts);
+ // old format - val looks like "Off" or "0:0.5:0:0" (orientation, distance, two angles)
+ // new format - val looks like "Off" or "0" (plane id)
+ // (note: in new format "Off" value is used only for consistency,
+ // so it is processed together with values in old format)
+ bool anIsOldFormat = ( vals.count() == 4 || val == "Off" );
+ if( anIsOldFormat ) {
+ if (paramNameStr == "ClippingPlane1" || val == "Off")
+ aSmeshActor->RemoveAllClippingPlanes();
+ if (val != "Off") {
+ SMESH::Orientation anOrientation = (SMESH::Orientation)vals[0].toInt();
+ double aDistance = vals[1].toFloat();
+ double anAngle[2];
+ anAngle[0] = vals[2].toFloat();
+ anAngle[1] = vals[3].toFloat();
+
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(viewerTypStr, lst);
+ // SVTK ViewManager always has 1 ViewWindow, so view index is index of view manager
+ if (viewIndex >= 0 && viewIndex < lst.count()) {
+ SUIT_ViewManager* vman = lst.at(viewIndex);
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView();
+
+ SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ vman ];
+
+ SMESH::TActorList anActorList;
+ anActorList.push_back( aSmeshActor );
+ SMESH::OrientedPlane* aPlane =
+ SMESHGUI_ClippingDlg::AddPlane(anActorList, vtkView, anOrientation, aDistance, anAngle);
+ if( aPlane ) {
+ SMESH::ClippingPlaneInfo aClippingPlaneInfo;
+ aClippingPlaneInfo.Plane = aPlane;
+ aClippingPlaneInfo.ActorList = anActorList;
+ aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
+ }
+ }
+ }
+ }
+ else {
+ bool ok = false;
+ int aPlaneId = val.toInt( &ok );
+ if( ok && aPlaneId >= 0 ) {
+ bool anIsDefinedPlane = false;
+ TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ viewIndex ];
+ TPlaneInfoList::iterator anIter = aPlaneInfoList.begin();
+ for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
+ TPlaneInfo& aPlaneInfo = *anIter;
+ if( aPlaneInfo.PlaneId == aPlaneId ) {
+ aPlaneInfo.ActorList.push_back( aSmeshActor );
+ anIsDefinedPlane = true;
+ break;
+ }
+ }
+ if( !anIsDefinedPlane ) {
+ TPlaneInfo aPlaneInfo;
+ aPlaneInfo.PlaneId = aPlaneId;
+ aPlaneInfo.ActorList.push_back( aSmeshActor );
+ aPlaneInfo.ViewManager = vman;
+
+ // to make the list sorted by plane id
+ anIter = aPlaneInfoList.begin();
+ for( ; anIter != aPlaneInfoList.end(); anIter++ ) {
+ const TPlaneInfo& aPlaneInfoRef = *anIter;
+ if( aPlaneInfoRef.PlaneId > aPlaneId )
+ break;
+ }
+ aPlaneInfoList.insert( anIter, aPlaneInfo );
+ }
+ }
+ }
+ }
+ } // if (aSmeshActor)
+ } // other parameters than Visibility
+ }
+ } // for names/parameters iterator
+ } // for entries iterator
+
+ // take into account planes with empty list of actors referred to them
+ QList<SUIT_ViewManager*> aVMList;
+ getApp()->viewManagers(SVTK_Viewer::Type(), aVMList);
+
+ TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin();
+ for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) {
+ int aViewId = aPlaneDataIter->first;
+ if( aViewId >= 0 && aViewId < aVMList.count() ) {
+ SUIT_ViewManager* aViewManager = aVMList.at( aViewId );
+
+ const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second;
+
+ TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ];
+ TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin();
+ for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) {
+ const TPlaneData& aPlaneData = *anIter2;
+ int aPlaneId = aPlaneData.Id;
+
+ bool anIsFound = false;
+ TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
+ for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
+ const TPlaneInfo& aPlaneInfo = *anIter3;
+ if( aPlaneInfo.PlaneId == aPlaneId ) {
+ anIsFound = true;
+ break;
+ }
+ }
+
+ if( !anIsFound ) {
+ TPlaneInfo aPlaneInfo; // ActorList field is empty
+ aPlaneInfo.PlaneId = aPlaneId;
+ aPlaneInfo.ViewManager = aViewManager;
+
+ // to make the list sorted by plane id
+ TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin();
+ for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) {
+ const TPlaneInfo& aPlaneInfoRef = *anIter4;
+ if( aPlaneInfoRef.PlaneId > aPlaneId )
+ break;
+ }
+ aPlaneInfoList.insert( anIter4, aPlaneInfo );
+ }
+ }
+ }
+ }
+
+ // add clipping planes to actors according to the restored parameters
+ // and update the clipping plane map
+ TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin();
+ for( ; anIter1 != aPlaneInfoMap.end(); anIter1++ ) {
+ int aViewId = anIter1->first;
+ const TPlaneInfoList& aPlaneInfoList = anIter1->second;
+
+ TPlaneDataMap::const_iterator anIter2 = aPlaneDataMap.find( aViewId );
+ if( anIter2 == aPlaneDataMap.end() )
+ continue;
+ const TPlaneDataList& aPlaneDataList = anIter2->second;
+
+ TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin();
+ for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) {
+ const TPlaneInfo& aPlaneInfo = *anIter3;
+ int aPlaneId = aPlaneInfo.PlaneId;
+ const TActorList& anActorList = aPlaneInfo.ActorList;
+ SUIT_ViewManager* aViewManager = aPlaneInfo.ViewManager;
+ if( !aViewManager )
+ continue;
+
+ SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( aViewManager->getActiveView() );
+ if( !aViewWindow )
+ continue;
+
+ SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = myClippingPlaneInfoMap[ aViewManager ];
+
+ TPlaneDataList::const_iterator anIter4 = aPlaneDataList.begin();
+ for( ; anIter4 != aPlaneDataList.end(); anIter4++ ) {
+ const TPlaneData& aPlaneData = *anIter4;
+ if( aPlaneData.Id == aPlaneId ) {
+ SMESH::OrientedPlane* aPlane =
+ SMESHGUI_ClippingDlg::AddPlane( anActorList,
+ aViewWindow,
+ (SMESH::Orientation)aPlaneData.Orientation,
+ aPlaneData.Distance,
+ aPlaneData.Angle );
+ if( aPlane ) {
+ SMESH::ClippingPlaneInfo aClippingPlaneInfo;
+ aClippingPlaneInfo.Plane = aPlane;
+ aClippingPlaneInfo.ActorList = anActorList;
+ aClippingPlaneInfoList.push_back( aClippingPlaneInfo );
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ // update all VTK views
+ QList<SUIT_ViewManager*> lst;
+ getApp()->viewManagers(lst);
+ for (QList<SUIT_ViewManager*>::Iterator it = lst.begin(); it != lst.end(); it++) {
+ SUIT_ViewModel* vmodel = (*it)->getViewModel();
+ if (vmodel && vmodel->getType() == SVTK_Viewer::Type()) {
+ SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) (*it)->getActiveView();
+ vtkView->getRenderer()->ResetCameraClippingRange();
+ vtkView->Repaint();
+ }
+ }
+}
+
+/*!
+ \brief Adds preferences for dfont of VTK viewer
+ \param label label
+ \param pIf group identifier
+ \param param parameter
+ \return identifier of preferences
+*/
+int SMESHGUI::addVtkFontPref( const QString& label, const int pId, const QString& param, const bool needSize )
+{
+ int tfont = addPreference( label, pId, LightApp_Preferences::Font, "SMESH", param );
+
+ setPreferenceProperty( tfont, "mode", QtxFontEdit::Custom );
+
+ QStringList fam;
+ fam.append( tr( "SMESH_FONT_ARIAL" ) );
+ fam.append( tr( "SMESH_FONT_COURIER" ) );
+ fam.append( tr( "SMESH_FONT_TIMES" ) );
+
+ setPreferenceProperty( tfont, "fonts", fam );
+
+ int f = QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic | QtxFontEdit::Shadow;
+ if ( needSize ) f = f | QtxFontEdit::Size;
+ setPreferenceProperty( tfont, "features", f );
+
+ return tfont;
+}
+
+/*!
+ \brief Actions after hypothesis edition
+ Updates object browser after hypothesis edition
+*/
+void SMESHGUI::onHypothesisEdit( int result )
+{
+ if( result == 1 )
+ SMESHGUI::Modified();
+ updateObjBrowser( true );
+}
+
+
+/*!
+ \brief Signal handler closing(SUIT_ViewWindow*) of a view
+ \param pview view being closed
+*/
+void SMESHGUI::onViewClosed( SUIT_ViewWindow* pview ) {
+#ifndef DISABLE_PLOT2DVIEWER
+ //Crear all Plot2d Viewers if need.
+ SMESH::ClearPlot2Viewers(pview);
+#endif
+}
+
+void SMESHGUI::message( const QString& msg )
+{
+ // dispatch message
+ QStringList data = msg.split("/");
+ if ( data.count() > 0 ) {
+ if ( data.first() == "mesh_loading" ) {
+ // get mesh entry
+ QString entry = data.count() > 1 ? data[1] : QString();
+ if ( entry.isEmpty() )
+ return;
+ // get study
+ _PTR(Study) study = dynamic_cast<SalomeApp_Study*>( application()->activeStudy() )->studyDS();
+ // get mesh name
+ _PTR(SObject) obj = study->FindObjectID( entry.toLatin1().constData() );
+ QString name;
+ if ( obj )
+ name = obj->GetName().c_str();
+ if ( name.isEmpty() )
+ return;
+
+ if ( data.last() == "stop" )
+ application()->putInfo( tr( "MESH_LOADING_MSG_FINISHED" ).arg( name ) );
+ else
+ application()->putInfo( tr( "MESH_LOADING_MSG" ).arg( name ) );
+ QApplication::processEvents();
+ }
+ }
+}
+
+/*!
+ \brief Connects or disconnects signals about activating and cloning view on the module slots
+ \param pview view which is connected/disconnected
+*/
+void SMESHGUI::connectView( const SUIT_ViewWindow* pview ) {
+ if(!pview)
+ return;
+
+ SUIT_ViewManager* viewMgr = pview->getViewManager();
+ if ( viewMgr ) {
+ disconnect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
+ this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
+
+ connect( viewMgr, SIGNAL( deleteView( SUIT_ViewWindow* ) ),
+ this, SLOT( onViewClosed( SUIT_ViewWindow* ) ) );
+ }
+}
+
+/*!
+ \brief Return \c true if object can be renamed
+*/
+bool SMESHGUI::renameAllowed( const QString& entry) const {
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !anApp )
+ return false;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+ if( !appStudy )
+ return false;
+
+ SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>(appStudy->findObjectByEntry(entry));
+
+ if(!obj)
+ return false;
+
+ if(appStudy->isComponent(entry) || obj->isReference())
+ return false;
+
+ // check type to prevent renaming of inappropriate objects
+ int aType = SMESHGUI_Selection::type(qPrintable(entry), SMESH::GetActiveStudyDocument());
+ if (aType == SMESH::MESH || aType == SMESH::GROUP ||
+ aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
+ aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
+ aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
+ aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM)
+ return true;
+
+ return false;
+}
+
+/*!
+ Rename object by entry.
+ \param entry entry of the object
+ \param name new name of the object
+ \brief Return \c true if rename operation finished successfully, \c false otherwise.
+*/
+bool SMESHGUI::renameObject( const QString& entry, const QString& name) {
+
+ SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>( application() );
+ if( !anApp )
+ return false;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( anApp->activeStudy() );
+
+ if(!appStudy)
+ return false;
+
+ _PTR(Study) aStudy = appStudy->studyDS();
+
+ if(!aStudy)
+ return false;
+
+ bool aLocked = (_PTR(AttributeStudyProperties)(appStudy->studyDS()->GetProperties()))->IsLocked();
+ if ( aLocked ) {
+ SUIT_MessageBox::warning ( anApp->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
+ return false;
+ }
+
+
+ _PTR(SObject) obj = aStudy->FindObjectID( qPrintable(entry) );
+ _PTR(GenericAttribute) anAttr;
+ _PTR(AttributeName) aName;
+ if ( obj ) {
+ if ( obj->FindAttribute(anAttr, "AttributeName") ) {
+ aName = anAttr;
+ // check type to prevent renaming of inappropriate objects
+ int aType = SMESHGUI_Selection::type( qPrintable(entry), SMESH::GetActiveStudyDocument() );
+ if (aType == SMESH::MESH || aType == SMESH::GROUP ||
+ aType == SMESH::SUBMESH || aType == SMESH::SUBMESH_COMPOUND ||
+ aType == SMESH::SUBMESH_SOLID || aType == SMESH::SUBMESH_FACE ||
+ aType == SMESH::SUBMESH_EDGE || aType == SMESH::SUBMESH_VERTEX ||
+ aType == SMESH::HYPOTHESIS || aType == SMESH::ALGORITHM) {
+ if ( !name.isEmpty() ) {
+ SMESHGUI::GetSMESHGen()->SetName(obj->GetIOR().c_str(), qPrintable(name) );
+
+ // update name of group object and its actor
+ Handle(SALOME_InteractiveObject) IObject =
+ new SALOME_InteractiveObject ( qPrintable(entry), "SMESH", qPrintable(name) );
+
+ SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
+ if( !aGroupObject->_is_nil() ) {
+ aGroupObject->SetName( qPrintable(name) );
+ if ( SMESH_Actor *anActor = SMESH::FindActorByEntry( qPrintable(entry) ) )
+ anActor->setName( qPrintable(name) );
+ }
+ return true;
+ }
+ }
+ }
+ }
+ return false;