From: vsr Date: Wed, 3 Oct 2012 13:45:18 +0000 (+0000) Subject: 0021711: [CEA 579] Simplify Properties dialog accordingly to dimension of mesh X-Git-Tag: V6_6_0a1~65 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=878662e498171172caa47a41ac9ba45a73ad5da1;p=modules%2Fsmesh.git 0021711: [CEA 579] Simplify Properties dialog accordingly to dimension of mesh --- diff --git a/src/SMESHGUI/Makefile.am b/src/SMESHGUI/Makefile.am index 15925385f..9bfd599b3 100644 --- a/src/SMESHGUI/Makefile.am +++ b/src/SMESHGUI/Makefile.am @@ -49,7 +49,6 @@ salomeinclude_HEADERS = \ SMESHGUI_RemoveElementsDlg.h \ SMESHGUI_MeshInfo.h \ SMESHGUI_Measurements.h \ - SMESHGUI_Preferences_ColorDlg.h \ SMESHGUI_Preferences_ScalarBarDlg.h \ SMESHGUI_AddMeshElementDlg.h \ SMESHGUI_XmlHandler.h \ @@ -97,6 +96,7 @@ salomeinclude_HEADERS = \ SMESHGUI_CopyMeshDlg.h \ SMESHGUI_PreviewDlg.h \ SMESHGUI_ReorientFacesDlg.h \ + SMESHGUI_PropertiesDlg.h \ SMESH_SMESHGUI.hxx # Libraries targets @@ -115,7 +115,6 @@ dist_libSMESH_la_SOURCES = \ SMESHGUI_RemoveElementsDlg.cxx \ SMESHGUI_MeshInfo.cxx \ SMESHGUI_Measurements.cxx \ - SMESHGUI_Preferences_ColorDlg.cxx \ SMESHGUI_Preferences_ScalarBarDlg.cxx \ SMESHGUI_AddMeshElementDlg.cxx \ SMESHGUI_XmlHandler.cxx \ @@ -173,7 +172,8 @@ dist_libSMESH_la_SOURCES = \ SMESHGUI_CopyMeshDlg.cxx \ SMESHGUI_FileValidator.cxx \ SMESHGUI_PreviewDlg.cxx \ - SMESHGUI_ReorientFacesDlg.cxx + SMESHGUI_ReorientFacesDlg.cxx \ + SMESHGUI_PropertiesDlg.cxx MOC_FILES = \ SMESHGUI_moc.cxx \ @@ -189,7 +189,6 @@ MOC_FILES = \ SMESHGUI_RemoveElementsDlg_moc.cxx \ SMESHGUI_MeshInfo_moc.cxx \ SMESHGUI_Measurements_moc.cxx \ - SMESHGUI_Preferences_ColorDlg_moc.cxx \ SMESHGUI_Preferences_ScalarBarDlg_moc.cxx \ SMESHGUI_AddMeshElementDlg_moc.cxx \ SMESHGUI_FilterDlg_moc.cxx \ @@ -233,7 +232,8 @@ MOC_FILES = \ SMESHGUI_CopyMeshDlg_moc.cxx \ SMESHGUI_MeshOrderOp_moc.cxx \ SMESHGUI_PreviewDlg_moc.cxx \ - SMESHGUI_ReorientFacesDlg_moc.cxx + SMESHGUI_ReorientFacesDlg_moc.cxx \ + SMESHGUI_PropertiesDlg_moc.cxx nodist_libSMESH_la_SOURCES= \ $(MOC_FILES) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index bbb3276a4..75678728f 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -59,8 +59,8 @@ #include "SMESHGUI_MeshPatternDlg.h" #include "SMESHGUI_MultiEditDlg.h" #include "SMESHGUI_NodesDlg.h" -#include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI_Preferences_ScalarBarDlg.h" +#include "SMESHGUI_PropertiesDlg.h" #include "SMESHGUI_RemoveElementsDlg.h" #include "SMESHGUI_RemoveNodesDlg.h" #include "SMESHGUI_RenumberingDlg.h" @@ -939,6 +939,8 @@ SALOMEDS::Color aColor = aGroupObject->GetColor(); _PTR(SObject) aGroupSObject = SMESH::FindSObject(aGroupObject); if (aGroupSObject) { + QColor c; + int delta; if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aGroupSObject->GetID().c_str())) { switch ( aGroupObject->GetType ()) { case SMESH::NODE: @@ -949,9 +951,11 @@ anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); break; case SMESH::BALL: anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break; + case SMESH::VOLUME: + SMESH::GetColor("SMESH", "volume_color", c, delta, "255,0,170|-100"); + anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break; + case SMESH::FACE: default: - QColor c; - int delta; SMESH::GetColor("SMESH", "fill_color", c, delta, "0,170,255|-100"); anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); } @@ -1202,250 +1206,224 @@ (new SMESHGUI_TransparencyDlg( SMESHGUI::GetSMESHGUI() ))->show(); return; } - case 1132:{ - QColor c, e, b, n, c0D, cBall, o, outl, selection, preselection; - int delta; - int size0D = 0, ballSize = 0; - int Edgewidth = 0; - vtkFloatingPointType Shrink = 0.0; - vtkFloatingPointType faces_orientation_scale = 0.0; - bool faces_orientation_3dvectors = false; - - VTK::MarkerType aMarkerTypeCurrent = VTK::MT_NONE; - VTK::MarkerScale aMarkerScaleCurrent = VTK::MS_NONE; - int aMarkerTextureCurrent = 0; + case 1132: { + vtkFloatingPointType color[3]; + QColor faceColor, edgeColor, nodeColor, elem0dColor, ballColor; + QColor orientationColor, outlineColor, volumeColor; + int deltaF = 0, deltaV = 0; + int elem0dSize = 1; + int ballSize = 1; + int edgeWidth = 1; + int outlineWidth = 1; + vtkFloatingPointType shrinkCoef = 0.0; + vtkFloatingPointType orientationScale = 0.0; + bool orientation3d = false; + VTK::MarkerType markerType = VTK::MT_NONE; + VTK::MarkerScale markerScale = VTK::MS_NONE; + int markerId = 0; + bool hasNodes = false; + int presentEntities = 0; + bool firstTime = true; SALOME_ListIteratorOfListIO It( selected ); - for( ; It.More(); It.Next()){ + for ( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){ - vtkFloatingPointType color[3]; - anActor->GetSufaceColor(color[0], color[1], color[2],delta); - int c0 = int (color[0] * 255); - int c1 = int (color[1] * 255); - int c2 = int (color[2] * 255); - c.setRgb(c0, c1, c2); - - vtkFloatingPointType edgecolor[3]; - anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]); - c0 = int (edgecolor[0] * 255); - c1 = int (edgecolor[1] * 255); - c2 = int (edgecolor[2] * 255); - e.setRgb(c0, c1, c2); - - vtkFloatingPointType nodecolor[3]; - anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]); - c0 = int (nodecolor[0] * 255); - c1 = int (nodecolor[1] * 255); - c2 = int (nodecolor[2] * 255); - n.setRgb(c0, c1, c2); - - vtkFloatingPointType color0D[3]; - anActor->Get0DColor(color0D[0], color0D[1], color0D[2]); - c0 = int (color0D[0] * 255); - c1 = int (color0D[1] * 255); - c2 = int (color0D[2] * 255); - c0D.setRgb(c0, c1, c2); - - vtkFloatingPointType ballcolor[3]; - anActor->GetBallColor(ballcolor[0], ballcolor[1], ballcolor[2]); - c0 = int (ballcolor[0] * 255); - c1 = int (ballcolor[1] * 255); - c2 = int (ballcolor[2] * 255); - cBall.setRgb(c0, c1, c2); - - vtkFloatingPointType outlineColor[3]; - anActor->GetOutlineColor(outlineColor[0], outlineColor[1], outlineColor[2]); - c0 = int (outlineColor[0] * 255); - c1 = int (outlineColor[1] * 255); - c2 = int (outlineColor[2] * 255); - outl.setRgb(c0, c1, c2); - - vtkFloatingPointType hColor[3]; - anActor->GetHighlightColor(hColor[0], hColor[1], hColor[2]); - c0 = int (hColor[0] * 255); - c1 = int (hColor[1] * 255); - c2 = int (hColor[2] * 255); - selection.setRgb(c0, c1, c2); - - vtkFloatingPointType phColor[3]; - anActor->GetPreHighlightColor(phColor[0], phColor[1], phColor[2]); - c0 = int (phColor[0] * 255); - c1 = int (phColor[1] * 255); - c2 = int (phColor[2] * 255); - preselection.setRgb(c0, c1, c2); - - size0D = (int)anActor->Get0DSize(); - if(size0D == 0) - size0D = 1; - ballSize = (int)anActor->GetBallSize(); - if(ballSize == 0) - ballSize = 1; - Edgewidth = (int)anActor->GetLineWidth(); - if(Edgewidth == 0) - Edgewidth = 1; - Shrink = anActor->GetShrinkFactor(); - - vtkFloatingPointType faces_orientation_color[3]; - anActor->GetFacesOrientationColor(faces_orientation_color); - c0 = int (faces_orientation_color[0] * 255); - c1 = int (faces_orientation_color[1] * 255); - c2 = int (faces_orientation_color[2] * 255); - o.setRgb(c0, c1, c2); - - faces_orientation_scale = anActor->GetFacesOrientationScale(); - faces_orientation_3dvectors = anActor->GetFacesOrientation3DVectors(); - - aMarkerTypeCurrent = anActor->GetMarkerType(); - aMarkerScaleCurrent = anActor->GetMarkerScale(); - aMarkerTextureCurrent = anActor->GetMarkerTexture(); - - // even if there are multiple objects in the selection, - // we need only the first one to get values for the dialog - break; - } - } - } - - SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg( SMESHGUI::GetSMESHGUI() ); - aDlg->SetBooleanValue(1, faces_orientation_3dvectors); - aDlg->SetColor(1, c); - aDlg->SetColor(2, e); - aDlg->SetColor(3, n); - aDlg->SetColor(4, outl); - aDlg->SetColor(5, c0D); - aDlg->SetColor(6, cBall); - aDlg->SetColor(7, o); - aDlg->SetColor(8, selection); - aDlg->SetColor(9, preselection); - aDlg->SetDeltaBrightness(delta); - aDlg->SetDoubleValue(1, faces_orientation_scale); - aDlg->SetIntValue(1, Edgewidth); - aDlg->SetIntValue(2, int(Shrink*100.)); - aDlg->SetIntValue(3, size0D); - aDlg->SetIntValue(4, ballSize); - - aDlg->setCustomMarkerMap( theMarkerMap[ aStudy->StudyId() ] ); - - if( aMarkerTypeCurrent != VTK::MT_USER ) - aDlg->setStandardMarker( aMarkerTypeCurrent, aMarkerScaleCurrent ); + if ( !IObject->hasEntry() ) continue; + SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() ); + if ( !anActor || !anActor->GetObject() ) continue; + + if ( firstTime ) { + // nodes: color, marker + anActor->GetNodeColor( color[0], color[1], color[2] ); + nodeColor.setRgbF( color[0], color[1], color[2] ); + markerType = anActor->GetMarkerType(); + markerScale = anActor->GetMarkerScale(); + markerId = anActor->GetMarkerTexture(); + // edges: color, width + anActor->GetEdgeColor( color[0], color[1], color[2] ); + edgeColor.setRgbF( color[0], color[1], color[2] ); + edgeWidth = qMax( (int)anActor->GetLineWidth(), 1 ); // minimum allowed width is 1 + // faces: front color, back color (delta) + anActor->GetSufaceColor( color[0], color[1], color[2], deltaF ); + faceColor.setRgbF( color[0], color[1], color[2] ); + // faces: front color, back color (delta) + anActor->GetVolumeColor( color[0], color[1], color[2], deltaV ); + volumeColor.setRgbF( color[0], color[1], color[2] ); + // 0d elements: color, size + anActor->Get0DColor( color[0], color[1], color[2] ); + elem0dColor.setRgbF( color[0], color[1], color[2] ); + elem0dSize = qMax( (int)anActor->Get0DSize(), 1 ); // minimum allowed size is 1 + // balls: color, size + anActor->GetBallColor( color[0], color[1], color[2] ); + ballColor.setRgbF( color[0], color[1], color[2] ); + ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1 + // outlines: color + anActor->GetOutlineColor( color[0], color[1], color[2] ); + outlineColor.setRgbF( color[0], color[1], color[2] ); + outlineWidth = qMax( (int)anActor->GetOutlineWidth(), 1 ); // minimum allowed width is 1 + // orientation vectors: color, scale, 3d flag + anActor->GetFacesOrientationColor( color[0], color[1], color[2] ); + orientationColor.setRgbF( color[0], color[1], color[2] ); + orientationScale = anActor->GetFacesOrientationScale(); + orientation3d = anActor->GetFacesOrientation3DVectors(); + // shrink factor + shrinkCoef = anActor->GetShrinkFactor(); + } + + firstTime = false; // we only take properties from first object (for performance reasons) + + if ( !hasNodes ) + hasNodes = anActor->GetObject()->GetNbEntities( SMDSAbs_Node ); + if ( !(presentEntities & SMESH_Actor::eEdges) && anActor->GetObject()->GetNbEntities( SMDSAbs_Edge ) ) + presentEntities = presentEntities | SMESH_Actor::eEdges; + if ( !(presentEntities & SMESH_Actor::eFaces) && anActor->GetObject()->GetNbEntities( SMDSAbs_Face ) ) + presentEntities = presentEntities | SMESH_Actor::eFaces; + if ( !(presentEntities & SMESH_Actor::eVolumes) && anActor->GetObject()->GetNbEntities( SMDSAbs_Volume ) ) + presentEntities = presentEntities | SMESH_Actor::eVolumes; + if ( !(presentEntities & SMESH_Actor::e0DElements) && anActor->GetObject()->GetNbEntities( SMDSAbs_0DElement ) ) + presentEntities = presentEntities | SMESH_Actor::e0DElements; + if ( !(presentEntities & SMESH_Actor::eBallElem) && anActor->GetObject()->GetNbEntities( SMDSAbs_Ball ) ) + presentEntities = presentEntities | SMESH_Actor::eBallElem; + + // as we know that all types of elements are present, we can exit the loop + if ( presentEntities == SMESH_Actor::eAllEntity ) + break; + } + + SMESHGUI_PropertiesDlg dlg( theMarkerMap[ aStudy->StudyId() ], SMESHGUI::desktop() ); + // nodes: color, marker + dlg.setNodeColor( nodeColor ); + if( markerType != VTK::MT_USER ) + dlg.setNodeMarker( markerType, markerScale ); else - aDlg->setCustomMarker( aMarkerTextureCurrent ); - - if(aDlg->exec()){ - QColor color = aDlg->GetColor(1); - QColor edgecolor = aDlg->GetColor(2); - QColor nodecolor = aDlg->GetColor(3); - QColor outlinecolor = aDlg->GetColor(4); - QColor color0D = aDlg->GetColor(5); - QColor ballcolor = aDlg->GetColor(6); - QColor faces_orientation_color = aDlg->GetColor(7); - QColor selectioncolor = aDlg->GetColor(8); - QColor preSelectioncolor = aDlg->GetColor(9); - int delta = aDlg->GetDeltaBrightness(); - - /* Point marker */ - theMarkerMap[ aStudy->StudyId() ] = aDlg->getCustomMarkerMap(); - + dlg.setNodeCustomMarker( markerId ); + // edges: color, line width + dlg.setEdgeColor( edgeColor ); + dlg.setEdgeWidth( edgeWidth ); + // faces: front color, back color + dlg.setFaceColor( faceColor, deltaF ); + // volumes: normal color, reversed color + dlg.setVolumeColor( volumeColor, deltaV ); + // outlines: color, line width + dlg.setOutlineColor( outlineColor ); + dlg.setOutlineWidth( outlineWidth ); + // 0d elements: color, size + dlg.setElem0dColor( elem0dColor ); + dlg.setElem0dSize( elem0dSize ); + // balls: color, size + dlg.setBallColor( ballColor ); + dlg.setBallSize( ballSize ); + // orientation: color, scale, 3d flag + dlg.setOrientationColor( orientationColor ); + dlg.setOrientationSize( int( orientationScale * 100. ) ); + dlg.setOrientation3d( orientation3d ); + // shrink: scale factor + dlg.setShrinkCoef( int( shrinkCoef * 100. ) ); + // hide unused controls + dlg.showControls( presentEntities, hasNodes ); + + if ( dlg.exec() ) { + nodeColor = dlg.nodeColor(); + markerType = dlg.nodeMarkerType(); + markerScale = dlg.nodeMarkerScale(); + markerId = dlg.nodeMarkerId(); + edgeColor = dlg.edgeColor(); + edgeWidth = dlg.edgeWidth(); + faceColor = dlg.faceColor(); + deltaF = dlg.faceColorDelta(); + volumeColor = dlg.volumeColor(); + deltaV = dlg.volumeColorDelta(); + outlineColor = dlg.outlineColor(); + outlineWidth = dlg.outlineWidth(); + elem0dColor = dlg.elem0dColor(); + elem0dSize = dlg.elem0dSize(); + ballColor = dlg.ballColor(); + ballSize = dlg.ballSize(); + orientationColor = dlg.orientationColor(); + orientationScale = dlg.orientationSize() / 100.; + orientation3d = dlg.orientation3d(); + shrinkCoef = dlg.shrinkCoef() / 100.; + + // store point markers map that might be changed by the user + theMarkerMap[ aStudy->StudyId() ] = dlg.customMarkers(); + + // set properties from dialog box to the presentations SALOME_ListIteratorOfListIO It( selected ); - for( ; It.More(); It.Next()){ + for ( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){ - /* actor color and backface color */ - anActor->SetSufaceColor(vtkFloatingPointType (color.red()) / 255., - vtkFloatingPointType (color.green()) / 255., - vtkFloatingPointType (color.blue()) / 255., - delta); - /* edge color */ - anActor->SetEdgeColor(vtkFloatingPointType (edgecolor.red()) / 255., - vtkFloatingPointType (edgecolor.green()) / 255., - vtkFloatingPointType (edgecolor.blue()) / 255.); - /* edge outline */ - anActor->SetOutlineColor(vtkFloatingPointType (outlinecolor.red()) / 255., - vtkFloatingPointType (outlinecolor.green()) / 255., - vtkFloatingPointType (outlinecolor.blue()) / 255.); - - /* selection */ - anActor->SetHighlightColor(vtkFloatingPointType (selectioncolor.red()) / 255., - vtkFloatingPointType (selectioncolor.green()) / 255., - vtkFloatingPointType (selectioncolor.blue()) / 255.); - /* pre-selection */ - anActor->SetPreHighlightColor(vtkFloatingPointType (preSelectioncolor.red()) / 255., - vtkFloatingPointType (preSelectioncolor.green()) / 255., - vtkFloatingPointType (preSelectioncolor.blue()) / 255.); - - - /* Shrink factor and size edges */ - anActor->SetShrinkFactor(aDlg->GetIntValue(2) / 100.); - anActor->SetLineWidth(aDlg->GetIntValue(1)); - - /* Nodes color and size */ - anActor->SetNodeColor(vtkFloatingPointType (nodecolor.red()) / 255., - vtkFloatingPointType (nodecolor.green()) / 255., - vtkFloatingPointType (nodecolor.blue()) / 255.); - - /* 0D elements */ - anActor->Set0DColor(vtkFloatingPointType (color0D.red()) / 255., - vtkFloatingPointType (color0D.green()) / 255., - vtkFloatingPointType (color0D.blue()) / 255.); - anActor->Set0DSize(aDlg->GetIntValue(3)); - - /* Ball elements */ - anActor->SetBallColor(vtkFloatingPointType (ballcolor.red()) / 255., - vtkFloatingPointType (ballcolor.green()) / 255., - vtkFloatingPointType (ballcolor.blue()) / 255.); - anActor->SetBallSize(aDlg->GetIntValue(4)); - - /* Faces orientation */ - vtkFloatingPointType c[3] = {vtkFloatingPointType(faces_orientation_color.redF()), - vtkFloatingPointType(faces_orientation_color.greenF()), - vtkFloatingPointType(faces_orientation_color.blueF())}; - anActor->SetFacesOrientationColor(c); - anActor->SetFacesOrientationScale(aDlg->GetDoubleValue(1)); - anActor->SetFacesOrientation3DVectors(aDlg->GetBooleanValue(1)); - - VTK::MarkerType aMarkerTypeNew = aDlg->getMarkerType(); - VTK::MarkerScale aMarkerScaleNew = aDlg->getStandardMarkerScale(); - int aMarkerTextureNew = aDlg->getCustomMarkerID(); - if( aMarkerTypeNew != VTK::MT_USER ) - anActor->SetMarkerStd( aMarkerTypeNew, aMarkerScaleNew ); - else { - const VTK::MarkerMap& aMarkerMap = theMarkerMap[ aStudy->StudyId() ]; - VTK::MarkerMap::const_iterator anIter = aMarkerMap.find( aMarkerTextureNew ); - if( anIter != aMarkerMap.end() ) - anActor->SetMarkerTexture( aMarkerTextureNew, anIter->second.second ); - } - - SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface(IObject); - if( !aGroupObject->_is_nil() ) - { - SMESH::ElementType anElementType = aGroupObject->GetType(); - QColor aColor; - switch( anElementType ) - { - case SMESH::NODE: aColor = nodecolor; break; - case SMESH::EDGE: aColor = edgecolor; break; - default: aColor = color; break; - } - - SALOMEDS::Color aGroupColor; - aGroupColor.R = (float)aColor.red() / 255.0; - aGroupColor.G = (float)aColor.green() / 255.0; - aGroupColor.B = (float)aColor.blue() / 255.0; - aGroupObject->SetColor( aGroupColor ); - } - } - } - } - SMESH::RepaintCurrentView(); - } - delete aDlg; + if ( !IObject->hasEntry() ) continue; + SMESH_Actor* anActor = SMESH::FindActorByEntry( IObject->getEntry() ); + if ( !anActor ) continue; + + // nodes: color, marker + anActor->SetNodeColor( nodeColor.redF(), nodeColor.greenF(), nodeColor.blueF() ); + if ( markerType != VTK::MT_USER ) { + anActor->SetMarkerStd( markerType, markerScale ); + } + else { + const VTK::MarkerMap& markerMap = theMarkerMap[ aStudy->StudyId() ]; + VTK::MarkerMap::const_iterator iter = markerMap.find( markerId ); + if ( iter != markerMap.end() ) + anActor->SetMarkerTexture( markerId, iter->second.second ); + } + // volumes: normal color, reversed color (delta) + anActor->SetVolumeColor( volumeColor.redF(), volumeColor.greenF(), volumeColor.blueF(), deltaV ); + // faces: front color, back color (delta) + anActor->SetSufaceColor( faceColor.redF(), faceColor.greenF(), faceColor.blueF(), deltaF ); + // edges: color, width + anActor->SetEdgeColor( edgeColor.redF(), edgeColor.greenF(), edgeColor.blueF() ); + anActor->SetLineWidth( edgeWidth ); + // outlines: color + anActor->SetOutlineColor( outlineColor.redF(), outlineColor.greenF(), outlineColor.blueF() ); + anActor->SetOutlineWidth( outlineWidth ); + // 0D elements: color, size + anActor->Set0DColor( elem0dColor.redF(), elem0dColor.greenF(), elem0dColor.blueF() ); + anActor->Set0DSize( elem0dSize ); + // balls: color, size + anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() ); + anActor->SetBallSize( ballSize ); + // orientation: color, scale, 3d flag + anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() ); + anActor->SetFacesOrientationScale( orientationScale ); + anActor->SetFacesOrientation3DVectors( orientation3d ); + // shrink factor + anActor->SetShrinkFactor( shrinkCoef ); + + // for groups, set also proper color + SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface(IObject); + if ( !aGroupObject->_is_nil() ) { + SMESH::ElementType anElementType = aGroupObject->GetType(); + QColor aColor; + switch( anElementType ) { + case SMESH::NODE: + aColor = nodeColor; break; + case SMESH::EDGE: + aColor = edgeColor; break; + case SMESH::FACE: + aColor = faceColor; break; + case SMESH::VOLUME: + aColor = volumeColor; break; + case SMESH::ELEM0D: + aColor = elem0dColor; break; + case SMESH::BALL: + aColor = ballColor; break; + default: break; + } + + if ( aColor.isValid() ) { + SALOMEDS::Color aGroupColor; + aGroupColor.R = aColor.redF(); + aGroupColor.G = aColor.greenF(); + aGroupColor.B = aColor.blueF(); + aGroupObject->SetColor( aGroupColor ); + } + } // if ( !aGroupObject->_is_nil() ) + } // for ( ; It.More(); It.Next() ) + SMESH::RepaintCurrentView(); + } // if ( dlg.exec() ) return; - } - } + } // case 1132: + } // switch(theCommandID) SALOME_ListIteratorOfListIO It( selected ); for( ; It.More(); It.Next()){ Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -4813,15 +4791,17 @@ void SMESHGUI::createPreferences() setPreferenceProperty( markerScale, "indexes", aMarkerScaleIndicesList ); int elemGroup = addPreference( tr( "PREF_GROUP_ELEMENTS" ), meshTab ); - setPreferenceProperty( elemGroup, "columns", 2 ); + //setPreferenceProperty( elemGroup, "columns", 2 ); - int ColorId = addPreference( tr( "PREF_FILL" ), elemGroup, LightApp_Preferences::BiColor, "SMESH", "fill_color" ); + 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" ); - setPreferenceProperty( ColorId, "text", tr("PREF_BACKFACE") ); int grpGroup = addPreference( tr( "PREF_GROUP_GROUPS" ), meshTab ); setPreferenceProperty( grpGroup, "columns", 2 ); @@ -4835,6 +4815,8 @@ void SMESHGUI::createPreferences() 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"); @@ -4847,6 +4829,9 @@ void SMESHGUI::createPreferences() setPreferenceProperty( elemW, "min", 1 ); setPreferenceProperty( elemW, "max", 5 ); + setPreferenceProperty( outW, "min", 1 ); + setPreferenceProperty( outW, "max", 5 ); + setPreferenceProperty( shrink, "min", 0 ); setPreferenceProperty( shrink, "max", 100 ); @@ -5222,9 +5207,9 @@ SALOMEDS::Color SMESHGUI::getUniqueColor( const QList& theReser aColor.setHsv( aHue, 255, 255 ); SALOMEDS::Color aSColor; - aSColor.R = (double)aColor.red() / 255.0; - aSColor.G = (double)aColor.green() / 255.0; - aSColor.B = (double)aColor.blue() / 255.0; + aSColor.R = aColor.redF(); + aSColor.G = aColor.greenF(); + aSColor.B = aColor.blueF(); return aSColor; } diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index 129f67073..668681496 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1126,17 +1126,21 @@ bool SMESHGUI_GroupDlg::onApply() if ( aMeshGroupSO ) if(SMESH_Actor *anActor = SMESH::FindActorByEntry(aMeshGroupSO->GetID().c_str())) { anActor->setName(myName->text().toLatin1().data()); + QColor c; + int delta; switch ( myTypeId ) { case grpNodeSelection: anActor->SetNodeColor( aColor.R, aColor.G, aColor.B ); break; case grpBallSelection: anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); break; case grpEdgeSelection: anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B ); break; - case grpFaceSelection: case grpVolumeSelection: + SMESH::GetColor("SMESH", "volume_color", c , delta, "255,0,170|-100"); + anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, delta ); break; + break; + case grpFaceSelection: default: - QColor c; - int delta; SMESH::GetColor("SMESH", "fill_color", c , delta, "0,170,255|-100"); anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); break; + break; } } } diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx deleted file mode 100644 index efd681fef..000000000 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.cxx +++ /dev/null @@ -1,574 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// SMESH SMESHGUI : GUI for SMESH component -// File : SMESHGUI_Preferences_ColorDlg.cxx -// Author : Nicolas REJNERI, Open CASCADE S.A.S. -// SMESH includes -// -#include "SMESHGUI_Preferences_ColorDlg.h" - -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" -#include "SMESHGUI_Utils.h" - -// SALOME GUI includes -#include -#include -#include -#include -#include -#include -#include -#include - -// Qt includes -#include -#include -#include -#include -#include -#include -#include -#include - -#define SPACING 6 -#define MARGIN 11 - -//================================================================================= -// function : SMESHGUI_Preferences_ColorDlg() -// purpose : Constructs a SMESHGUI_Preferences_ColorDlg which is a child -// of 'parent', with the name 'name' and widget flags set to 'f' -// The dialog will by default be modeless, unless you -// set'modal' to true to construct a modal dialog. -//================================================================================= -SMESHGUI_Preferences_ColorDlg::SMESHGUI_Preferences_ColorDlg( SMESHGUI* theModule ) - : QDialog( SMESH::GetDesktop( theModule ) ), - mySMESHGUI( theModule ) -{ - setModal( true ); - setWindowTitle( tr( "DIALOG_TITLE" ) ); - setSizeGripEnabled( true ); - - // ------------------------------- - QVBoxLayout* topLayout = new QVBoxLayout( this ); - topLayout->setSpacing( SPACING ); - topLayout->setMargin( MARGIN ); - - // ------------------------------- - QGroupBox* ButtonGroup1 = new QGroupBox( tr( "GRP_ELEMENTS" ), this ); - QGridLayout* ButtonGroup1Layout = new QGridLayout( ButtonGroup1 ); - ButtonGroup1Layout->setSpacing( SPACING ); - ButtonGroup1Layout->setMargin( MARGIN ); - - QLabel* TextLabel_Fill = new QLabel( tr( "SURFACE_COLOR_LBL" ), ButtonGroup1 ); - - toolSurfColor = new QtxBiColorTool(ButtonGroup1); - toolSurfColor->setText( tr( "BACKSURFACE_COLOR_LBL" )); - - QLabel* TextLabel_Outline = new QLabel( tr( "OUTLINE_COLOR_LBL" ), ButtonGroup1 ); - btnOutlineColor = new QtxColorButton( ButtonGroup1 ); - - QLabel* TextLabel_Wireframe = new QLabel( tr( "WIREFRAME_COLOR_LBL" ), ButtonGroup1 ); - btnWireframeColor = new QtxColorButton( ButtonGroup1 ); - - QLabel* TextLabel_0DElements_Color = new QLabel( tr( "0D_ELEMENTS_COLOR_LBL" ), ButtonGroup1 ); - btn0DElementsColor = new QtxColorButton( ButtonGroup1 ); - - QLabel* TextLabel_0DElements_Size = new QLabel( tr( "0D_ELEMENTS_SIZE_LBL" ), ButtonGroup1 ); - SpinBox_0DElements_Size = new SalomeApp_IntSpinBox( ButtonGroup1 ); - SpinBox_0DElements_Size->setAcceptNames( false ); // No Notebook variables allowed - SpinBox_0DElements_Size->setRange( 1, 10 ); - SpinBox_0DElements_Size->setSingleStep( 1 ); - SpinBox_0DElements_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_0DElements_Size->setButtonSymbols( QSpinBox::PlusMinus ); - - QLabel* TextLabel_BallElem_Color = new QLabel( tr( "BALL_ELEMENTS_COLOR_LBL" ), ButtonGroup1 ); - btnBallElemColor = new QtxColorButton( ButtonGroup1 ); - - QLabel* TextLabel_BallElem_Size = new QLabel( tr( "BALL_ELEMENTS_SIZE_LBL" ), ButtonGroup1 ); - SpinBox_BallElem_Size = new SalomeApp_IntSpinBox( ButtonGroup1 ); - SpinBox_BallElem_Size->setAcceptNames( false ); // No Notebook variables allowed - SpinBox_BallElem_Size->setRange( 1, 10 ); - SpinBox_BallElem_Size->setSingleStep( 1 ); - SpinBox_BallElem_Size->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_BallElem_Size->setButtonSymbols( QSpinBox::PlusMinus ); - - QLabel* TextLabel_Width = new QLabel( tr( "LINE_WIDTH_LBL" ), ButtonGroup1 ); - SpinBox_Width = new SalomeApp_IntSpinBox( ButtonGroup1 ); - SpinBox_Width->setAcceptNames( false ); // No Notebook variables allowed - SpinBox_Width->setRange( 1, 5 ); - SpinBox_Width->setSingleStep( 1 ); - SpinBox_Width->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Width->setButtonSymbols( QSpinBox::PlusMinus ); - - QLabel* TextLabel_ShrinkCoeff = new QLabel( tr( "SHRINK_COEF_LBL" ), ButtonGroup1 ); - SpinBox_Shrink = new SalomeApp_IntSpinBox( ButtonGroup1 ); - SpinBox_Shrink->setAcceptNames( false ); // No Notebook variables allowed - SpinBox_Shrink->setRange( 20, 100 ); - SpinBox_Shrink->setSingleStep( 1 ); - SpinBox_Shrink->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Shrink->setButtonSymbols( QSpinBox::PlusMinus ); - - int row = 0; - ButtonGroup1Layout->addWidget( TextLabel_Fill, row, 0 ); - ButtonGroup1Layout->addWidget( toolSurfColor, row++, 1, 1, 3 ); - - ButtonGroup1Layout->addWidget( TextLabel_Outline, row, 0 ); - ButtonGroup1Layout->addWidget( btnOutlineColor, row, 1 ); - ButtonGroup1Layout->addWidget( TextLabel_Wireframe, row, 2 ); - ButtonGroup1Layout->addWidget( btnWireframeColor, row++, 3 ); - - ButtonGroup1Layout->addWidget( TextLabel_0DElements_Color, row, 0 ); - ButtonGroup1Layout->addWidget( btn0DElementsColor, row, 1 ); - - ButtonGroup1Layout->addWidget( TextLabel_0DElements_Size, row, 2 ); - ButtonGroup1Layout->addWidget( SpinBox_0DElements_Size, row++, 3 ); - - ButtonGroup1Layout->addWidget( TextLabel_BallElem_Color, row, 0 ); - ButtonGroup1Layout->addWidget( btnBallElemColor, row, 1 ); - - ButtonGroup1Layout->addWidget( TextLabel_BallElem_Size, row, 2 ); - ButtonGroup1Layout->addWidget( SpinBox_BallElem_Size, row++, 3 ); - - ButtonGroup1Layout->addWidget( TextLabel_Width, row, 0 ); - ButtonGroup1Layout->addWidget( SpinBox_Width, row, 1 ); - ButtonGroup1Layout->addWidget( TextLabel_ShrinkCoeff, row, 2 ); - ButtonGroup1Layout->addWidget( SpinBox_Shrink, row, 3 ); - - // ------------------------------- - QGroupBox* ButtonGroup2 = new QGroupBox( tr( "GRP_NODES" ), this ); - QGridLayout* ButtonGroup2Layout = new QGridLayout( ButtonGroup2 ); - ButtonGroup2Layout->setSpacing( SPACING ); - ButtonGroup2Layout->setMargin( MARGIN ); - - QLabel* TextLabel_Nodes_Color = new QLabel( tr( "NODES_COLOR_LBL" ), ButtonGroup2 ); - btnNodeColor = new QtxColorButton( ButtonGroup2 ); - - QGroupBox* MarkerGroup = new QGroupBox( tr( "NODES_MARKER_LBL" ), ButtonGroup2 ); - QVBoxLayout* MarkerGroupLayout = new QVBoxLayout( MarkerGroup ); - MarkerGroupLayout->setSpacing( 0 ); - MarkerGroupLayout->setMargin( 0 ); - - MarkerWidget = new VTKViewer_MarkerWidget( MarkerGroup ); - - MarkerGroupLayout->addWidget( MarkerWidget ); - - row = 0; - ButtonGroup2Layout->addWidget( TextLabel_Nodes_Color, row, 0 ); - ButtonGroup2Layout->addWidget( btnNodeColor, row++, 1 ); - ButtonGroup2Layout->addWidget( MarkerGroup, row++, 0, 1, 3 ); - ButtonGroup2Layout->setColumnStretch( row, 1 ); - - // ------------------------------- - QGroupBox* ButtonGroup3 = new QGroupBox( tr( "GRP_ORIENTATION" ), this ); - QGridLayout* ButtonGroup3Layout = new QGridLayout( ButtonGroup3 ); - ButtonGroup3Layout->setSpacing( SPACING ); - ButtonGroup3Layout->setMargin( MARGIN ); - - QLabel* TextLabel_Orientation_Color = new QLabel( tr( "ORIENTATION_COLOR_LBL" ), ButtonGroup3 ); - btnOrientationColor = new QtxColorButton( ButtonGroup3 ); - - QLabel* TextLabel_Orientation_Scale = new QLabel( tr( "ORIENTATION_SCALE_LBL" ), ButtonGroup3 ); - SpinBox_Orientation_Scale = new SMESHGUI_SpinBox( ButtonGroup3 ); - SpinBox_Orientation_Scale->setAcceptNames( false ); // No Notebook variables allowed - SpinBox_Orientation_Scale->RangeStepAndValidator( .05, .5, .05, "parametric_precision" ); - SpinBox_Orientation_Scale->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - SpinBox_Orientation_Scale->setButtonSymbols( QSpinBox::PlusMinus ); - - CheckBox_Orientation_3DVectors = new QCheckBox( tr( "3D_VECTORS_LBL" ), ButtonGroup3 ); - - row = 0; - ButtonGroup3Layout->addWidget( TextLabel_Orientation_Color, row, 0 ); - ButtonGroup3Layout->addWidget( btnOrientationColor, row, 1 ); - ButtonGroup3Layout->addWidget( TextLabel_Orientation_Scale, row, 2 ); - ButtonGroup3Layout->addWidget( SpinBox_Orientation_Scale, row++, 3 ); - ButtonGroup3Layout->addWidget( CheckBox_Orientation_3DVectors, row, 0, 1, 4 ); - - // ------------------------------- - QGroupBox* ButtonGroup4 = new QGroupBox( tr( "GRP_SELECTION" ), this ); - QGridLayout* ButtonGroup4Layout = new QGridLayout( ButtonGroup4 ); - ButtonGroup3Layout->setSpacing( SPACING ); - ButtonGroup3Layout->setMargin( MARGIN ); - - QLabel* TextLabel_Selection_Color = new QLabel( tr( "SELECTION_COLOR_LBL" ), ButtonGroup4 ); - btnSelectionColor = new QtxColorButton( ButtonGroup4 ); - - QLabel* TextLabel_Preselection_Color = new QLabel( tr( "PRESELECTION_COLOR_LBL" ), ButtonGroup4 ); - btnPreselectionColor = new QtxColorButton( ButtonGroup4 ); - - row = 0; - ButtonGroup4Layout->addWidget( TextLabel_Selection_Color, row, 0 ); - ButtonGroup4Layout->addWidget( btnSelectionColor, row, 1 ); - ButtonGroup4Layout->addWidget( TextLabel_Preselection_Color, row, 2 ); - ButtonGroup4Layout->addWidget( btnPreselectionColor, row, 3 ); - - // ------------------------------- - QGroupBox* GroupButtons = new QGroupBox( this ); - QHBoxLayout* GroupButtonsLayout = new QHBoxLayout( GroupButtons ); - GroupButtonsLayout->setSpacing( SPACING ); - GroupButtonsLayout->setMargin( MARGIN ); - - QPushButton* buttonOk = new QPushButton( tr( "SMESH_BUT_OK" ), GroupButtons ); - buttonOk->setAutoDefault( true ); - buttonOk->setDefault( true ); - - QPushButton* buttonCancel = new QPushButton( tr( "SMESH_BUT_CANCEL" ), GroupButtons ); - buttonCancel->setAutoDefault( true ); - - QPushButton* buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons ); - buttonHelp->setAutoDefault( true ); - - GroupButtonsLayout->addWidget( buttonOk ); - GroupButtonsLayout->addSpacing( 10 ); - GroupButtonsLayout->addStretch(); - GroupButtonsLayout->addWidget( buttonCancel ); - GroupButtonsLayout->addWidget( buttonHelp ); - - // ------------------------------- - topLayout->addWidget( ButtonGroup1 ); - topLayout->addWidget( ButtonGroup2 ); - topLayout->addWidget( ButtonGroup3 ); - // rnv: Selection and preselection colors are defined only in the Preferences - // topLayout->addWidget( ButtonGroup4 ); - ButtonGroup4->hide(); - topLayout->addWidget( GroupButtons ); - - // ------------------------------- - mySMESHGUI->SetActiveDialogBox( this ); - - myHelpFileName = "colors_size_page.html"; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); - connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), - this, SLOT( DeactivateActiveDialog() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), - this, SLOT( ClickOnCancel() ) ); -} - -//================================================================================= -// function : ~SMESHGUI_Preferences_ColorDlg() -// purpose : Destructor -//================================================================================= -SMESHGUI_Preferences_ColorDlg::~SMESHGUI_Preferences_ColorDlg() -{ -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::ClickOnOk() -{ - mySMESHGUI->ResetState(); - accept(); -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::ClickOnCancel() -{ - mySMESHGUI->ResetState(); - reject(); -} - -//================================================================================= -// function : ClickOnHelp() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::ClickOnHelp() -{ - LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) - app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); - else { - QString platform; -#ifdef WIN32 - platform = "winapplication"; -#else - platform = "application"; -#endif - SUIT_MessageBox::warning(this, tr("WRN_WARNING"), - tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", - platform)). - arg(myHelpFileName)); - } -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::DeactivateActiveDialog() -{ -} - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::closeEvent( QCloseEvent* ) -{ - ClickOnCancel(); /* same than click on cancel button */ -} - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate any active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog(); -} - -//================================================================================= -// function : SetColor() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetColor( int type, const QColor& color ) -{ - switch ( type ) { - case 1 : toolSurfColor->setMainColor( color ); break; // fill - case 2 : btnWireframeColor->setColor( color ); break; // wireframe - case 3 : btnNodeColor->setColor( color ); break; // node - case 4 : btnOutlineColor->setColor( color ); break; // outline - case 5 : btn0DElementsColor->setColor( color ); break; // 0d elements - case 6 : btnBallElemColor->setColor( color ); break; // ball elements - case 7 : btnOrientationColor->setColor( color ); break; // orientation of faces - case 8 : btnSelectionColor->setColor( color ); break; // selection color - case 9 : btnPreselectionColor->setColor( color ); break; // pre-selection color - default: break; - } -} - -//================================================================================= -// function : GetColor() -// purpose : -//================================================================================= -QColor SMESHGUI_Preferences_ColorDlg::GetColor( int type ) -{ - QColor color; - switch ( type ) { - case 1 : color = toolSurfColor->mainColor(); break; // fill - case 2 : color = btnWireframeColor->color(); break; // outline - case 3 : color = btnNodeColor->color(); break; // node - case 4 : color = btnOutlineColor->color(); break; // node - case 5 : color = btn0DElementsColor->color(); break; // 0d elements - case 6 : color = btnBallElemColor->color(); break; // 0d elements - case 7 : color = btnOrientationColor->color(); break; // orientation of faces - case 8 : color = btnSelectionColor->color(); break; // selection color - case 9 : color = btnPreselectionColor->color(); break; // pre-selection color - - default: break; - } - return color; -} - -//================================================================================= -// function : SetIntValue() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetIntValue( int type, int value ) -{ - switch ( type ) { - case 1 : SpinBox_Width->setValue( value ); break; // width - case 2 : SpinBox_Shrink->setValue( value ); break; // shrink coeff - case 3 : SpinBox_0DElements_Size->setValue( value ); break; // 0d elements - case 4 : SpinBox_BallElem_Size->setValue( value ); break; // 0d elements - default: break; - } -} - -//================================================================================= -// function : GetIntValue() -// purpose : -//================================================================================= -int SMESHGUI_Preferences_ColorDlg::GetIntValue( int type ) -{ - int res = 0; - switch ( type ) { - case 1 : res = SpinBox_Width->value(); break; // width - case 2 : res = SpinBox_Shrink->value(); break; // shrink coeff - case 3 : res = SpinBox_0DElements_Size->value(); break; // 0d elements - case 4 : res = SpinBox_BallElem_Size->value(); break; // 0d elements - default: break; - } - return res; -} - -//================================================================================= -// function : SetDoubleValue() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetDoubleValue( int type, double value ) -{ - switch ( type ) { - case 1 : SpinBox_Orientation_Scale->setValue( value ); break; // orientation scale - default: break; - } -} - -//================================================================================= -// function : GetDoubleValue() -// purpose : -//================================================================================= -double SMESHGUI_Preferences_ColorDlg::GetDoubleValue( int type ) -{ - double res = 0; - switch ( type ) { - case 1 : res = SpinBox_Orientation_Scale->value(); break; // orientation scale - default: break; - } - return res; -} - -//================================================================================= -// function : SetBooleanValue() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetBooleanValue( int type, bool value ) -{ - switch ( type ) { - case 1 : CheckBox_Orientation_3DVectors->setChecked( value ); break; // 3D vectors - default: break; - } -} - -//================================================================================= -// function : GetBooleanValue() -// purpose : -//================================================================================= -bool SMESHGUI_Preferences_ColorDlg::GetBooleanValue( int type ) -{ - bool res = false; - switch ( type ) { - case 1 : res = CheckBox_Orientation_3DVectors->isChecked(); break; // 3D vectors - default: break; - } - return res; -} - -//================================================================================= -// function : setCustomMarkerMap() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap ) -{ - MarkerWidget->setCustomMarkerMap( theMarkerMap ); -} - -//================================================================================= -// function : getCustomMarkerMap() -// purpose : -//================================================================================= -VTK::MarkerMap SMESHGUI_Preferences_ColorDlg::getCustomMarkerMap() -{ - return MarkerWidget->getCustomMarkerMap(); -} - -//================================================================================= -// function : setStandardMarker() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::setStandardMarker( VTK::MarkerType theMarkerType, - VTK::MarkerScale theMarkerScale ) -{ - MarkerWidget->setStandardMarker( theMarkerType, theMarkerScale ); -} - -//================================================================================= -// function : setCustomMarker() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::setCustomMarker( int theId ) -{ - MarkerWidget->setCustomMarker( theId ); -} - -//================================================================================= -// function : getMarkerType() -// purpose : -//================================================================================= -VTK::MarkerType SMESHGUI_Preferences_ColorDlg::getMarkerType() const -{ - return MarkerWidget->getMarkerType(); -} - -//================================================================================= -// function : getStandardMarkerScale() -// purpose : -//================================================================================= -VTK::MarkerScale SMESHGUI_Preferences_ColorDlg::getStandardMarkerScale() const -{ - return MarkerWidget->getStandardMarkerScale(); -} - -//================================================================================= -// function : getCustomMarkerID() -// purpose : -//================================================================================= -int SMESHGUI_Preferences_ColorDlg::getCustomMarkerID() const -{ - return MarkerWidget->getCustomMarkerID(); -} - -//================================================================================= -// function : SetDeltaBrightness(int) -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::SetDeltaBrightness(int delta) -{ - toolSurfColor->setDelta(delta); -} -//================================================================================= -// function : GetDeltaBrightness() -// purpose : -//================================================================================= -int SMESHGUI_Preferences_ColorDlg::GetDeltaBrightness() -{ - return toolSurfColor->delta(); -} - -//================================================================================= -// function : keyPressEvent() -// purpose : -//================================================================================= -void SMESHGUI_Preferences_ColorDlg::keyPressEvent( QKeyEvent* e ) -{ - QDialog::keyPressEvent( e ); - if ( e->isAccepted() ) - return; - - if ( e->key() == Qt::Key_F1 ) { - e->accept(); - ClickOnHelp(); - } -} diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h b/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h deleted file mode 100644 index 9533ca748..000000000 --- a/src/SMESHGUI/SMESHGUI_Preferences_ColorDlg.h +++ /dev/null @@ -1,110 +0,0 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// SMESH SMESHGUI : GUI for SMESH component -// File : SMESHGUI_Preferences_ColorDlg.h -// Author : Nicolas REJNERI, Open CASCADE S.A.S. -// -#ifndef SMESHGUI_PREFERENCES_COLORDLG_H -#define SMESHGUI_PREFERENCES_COLORDLG_H - -// SMESH includes -#include "SMESH_SMESHGUI.hxx" - -// SALOME GUI includes -#include -#include - -// Qt includes -#include - -class QCheckBox; -class SMESHGUI; -class SMESHGUI_SpinBox; -class SalomeApp_IntSpinBox; -class QtxColorButton; -class VTKViewer_MarkerWidget; - -class SMESHGUI_EXPORT SMESHGUI_Preferences_ColorDlg : public QDialog -{ - Q_OBJECT - -public: - SMESHGUI_Preferences_ColorDlg( SMESHGUI* ); - ~SMESHGUI_Preferences_ColorDlg(); - - void SetColor( int, const QColor& ); - QColor GetColor( int ); - void SetIntValue( int, int ); - int GetIntValue( int ); - void SetDoubleValue( int, double ); - double GetDoubleValue( int ); - void SetBooleanValue( int, bool ); - bool GetBooleanValue( int ); - - void setCustomMarkerMap( VTK::MarkerMap ); - VTK::MarkerMap getCustomMarkerMap(); - - void SetDeltaBrightness(int); - int GetDeltaBrightness(); - - void setStandardMarker( VTK::MarkerType, VTK::MarkerScale ); - void setCustomMarker( int ); - VTK::MarkerType getMarkerType() const; - VTK::MarkerScale getStandardMarkerScale() const; - int getCustomMarkerID() const; - -protected: - void closeEvent( QCloseEvent* ); - void keyPressEvent( QKeyEvent* ); - -private slots: - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnHelp(); - void DeactivateActiveDialog(); - void ActivateThisDialog(); - -private: - SMESHGUI* mySMESHGUI; - - QtxBiColorTool* toolSurfColor; - QtxColorButton* btnWireframeColor; - QtxColorButton* btnOutlineColor; - QtxColorButton* btn0DElementsColor; - QtxColorButton* btnBallElemColor; - SalomeApp_IntSpinBox* SpinBox_0DElements_Size; - SalomeApp_IntSpinBox* SpinBox_BallElem_Size; - SalomeApp_IntSpinBox* SpinBox_Width; - SalomeApp_IntSpinBox* SpinBox_Shrink; - QtxColorButton* btnNodeColor; - VTKViewer_MarkerWidget* MarkerWidget; - QtxColorButton* btnOrientationColor; - SMESHGUI_SpinBox* SpinBox_Orientation_Scale; - QCheckBox* CheckBox_Orientation_3DVectors; - QtxColorButton* btnPreselectionColor; - QtxColorButton* btnSelectionColor; - - QString myHelpFileName; -}; - -#endif // SMESHGUI_PREFERENCES_COLORDLG_H diff --git a/src/SMESHGUI/SMESHGUI_PropertiesDlg.cxx b/src/SMESHGUI/SMESHGUI_PropertiesDlg.cxx new file mode 100644 index 000000000..419169d8f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PropertiesDlg.cxx @@ -0,0 +1,636 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESHGUI_PropertiesDlg.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "SMESHGUI_PropertiesDlg.h" +#include "SMESH_Actor.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +const int MARGIN = 9; +const int SPACING = 6; + +/*! + \class SMESHGUI_PropertiesDlg + \brief Dialog box to set-up mesh presentation properties: colors, + sizes of elements, width of lines etc +*/ + +/* + \brief Constructor + \param customMarkers custom node markers + \param parent parent widget +*/ +SMESHGUI_PropertiesDlg::SMESHGUI_PropertiesDlg( const VTK::MarkerMap& customMarkers, QWidget* parent ) + : SMESHGUI_Dialog( parent, true, true, Standard ) +{ + // set title + setWindowTitle( tr( "TITLE" ) ); + + // create widgets + + QHBoxLayout* hl; + int widthLab1 = 0, widthLab2 = 0; + + // -- node controls + myNodeGrp = new QGroupBox( tr( "NODES" ), mainFrame() ); + QLabel* nodeColorLab = new QLabel( tr( "COLOR" ), myNodeGrp ); + myNodeColor = new QtxColorButton( myNodeGrp ); + myNodeMarker = new VTKViewer_MarkerWidget( myNodeGrp ); + hl = new QHBoxLayout( myNodeGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( nodeColorLab ); + hl->addWidget( myNodeColor ); + hl->addWidget( myNodeMarker ); + widthLab1 = qMax( widthLab1, nodeColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, myNodeMarker->typeLabel()->minimumSizeHint().width() ); + + // -- edge controls + myEdgeGrp = new QGroupBox( tr( "EDGES" ), mainFrame() ); + QLabel* edgeColorLab = new QLabel( tr( "COLOR" ), myEdgeGrp ); + myEdgeColor = new QtxColorButton( myEdgeGrp ); + QLabel* edgeWidthLab = new QLabel( tr( "WIDTH" ), myEdgeGrp ); + myEdgeWidth = new QtxIntSpinBox( myEdgeGrp ); + hl = new QHBoxLayout( myEdgeGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( edgeColorLab ); + hl->addWidget( myEdgeColor ); + hl->addWidget( edgeWidthLab ); + hl->addWidget( myEdgeWidth ); + widthLab1 = qMax( widthLab1, edgeColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, edgeWidthLab->minimumSizeHint().width() ); + + // -- face controls + myFaceGrp = new QGroupBox( tr( "FACES" ), mainFrame() ); + QLabel* faceColorLab = new QLabel( tr( "FACE_FRONT" ), myFaceGrp ); + myFaceColor = new QtxBiColorTool( myFaceGrp ); + myFaceColor->label()->setText( tr( "FACE_BACK" ) ); + hl = new QHBoxLayout( myFaceGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( faceColorLab ); + hl->addWidget( myFaceColor ); + widthLab1 = qMax( widthLab1, faceColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, myFaceColor->label()->minimumSizeHint().width() ); + + // -- volumes + myVolumeGrp = new QGroupBox( tr( "VOLUMES" ), mainFrame() ); + QLabel* volumeColorLab = new QLabel( tr( "VOLUME_NORMAL" ), myVolumeGrp ); + myVolumeColor = new QtxBiColorTool( myVolumeGrp ); + myVolumeColor->label()->setText( tr( "VOLUME_REVERSED" ) ); + hl = new QHBoxLayout( myVolumeGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( volumeColorLab ); + hl->addWidget( myVolumeColor ); + widthLab1 = qMax( widthLab1, volumeColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, myVolumeColor->label()->minimumSizeHint().width() ); + + // -- outline controls + myOutlineGrp = new QGroupBox( tr( "OUTLINES" ), mainFrame() ); + QLabel* outlineColorLab = new QLabel( tr( "COLOR" ), myOutlineGrp ); + myOutlineColor = new QtxColorButton( myOutlineGrp ); + QLabel* outlineWidthLab = new QLabel( tr( "WIDTH" ), myOutlineGrp ); + myOutlineWidth = new QtxIntSpinBox( myOutlineGrp ); + hl = new QHBoxLayout( myOutlineGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( outlineColorLab ); + hl->addWidget( myOutlineColor ); + hl->addWidget( outlineWidthLab ); + hl->addWidget( myOutlineWidth ); + widthLab1 = qMax( widthLab1, outlineColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, outlineWidthLab->minimumSizeHint().width() ); + + // -- 0d element controls + myElem0dGrp = new QGroupBox( tr( "0D_ELEMENTS" ), mainFrame() ); + QLabel* elem0dColorLab = new QLabel( tr( "COLOR" ), myElem0dGrp ); + myElem0dColor = new QtxColorButton( myElem0dGrp ); + QLabel* elem0dSizeLab = new QLabel( tr( "SIZE" ), myElem0dGrp ); + myElem0dSize = new QtxIntSpinBox( myElem0dGrp ); + hl = new QHBoxLayout( myElem0dGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( elem0dColorLab ); + hl->addWidget( myElem0dColor ); + hl->addWidget( elem0dSizeLab ); + hl->addWidget( myElem0dSize ); + widthLab1 = qMax( widthLab1, elem0dColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, elem0dSizeLab->minimumSizeHint().width() ); + + // -- ball controls + myBallGrp = new QGroupBox( tr( "BALLS" ), mainFrame() ); + QLabel* ballColorLab = new QLabel( tr( "COLOR" ), myBallGrp ); + myBallColor = new QtxColorButton( myBallGrp ); + QLabel* ballSizeLab = new QLabel( tr( "SIZE" ), myBallGrp ); + myBallSize = new QtxIntSpinBox( myBallGrp ); + hl = new QHBoxLayout( myBallGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( ballColorLab ); + hl->addWidget( myBallColor ); + hl->addWidget( ballSizeLab ); + hl->addWidget( myBallSize ); + widthLab1 = qMax( widthLab1, ballColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, ballSizeLab->minimumSizeHint().width() ); + + // -- orientation vector controls + myOrientationGrp = new QGroupBox( tr( "ORIENTATIONS" ), mainFrame() ); + QLabel* orientationColorLab = new QLabel( tr( "COLOR" ), myOrientationGrp ); + myOrientationColor = new QtxColorButton( myOrientationGrp ); + QLabel* orientationScaleLab = new QLabel( tr( "ORIENTATION_SCALE" ), myOrientationGrp ); + myOrientationSize = new QtxIntSpinBox( myOrientationGrp ); + myOrientationSize->setSuffix( "% "); + myOrientation3d = new QCheckBox( tr("ORIENTATION_3D"), myOrientationGrp ); + hl = new QHBoxLayout( myOrientationGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( orientationColorLab ); + hl->addWidget( myOrientationColor ); + hl->addWidget( orientationScaleLab ); + hl->addWidget( myOrientationSize ); + hl->addWidget( myOrientation3d ); + widthLab1 = qMax( widthLab1, orientationColorLab->minimumSizeHint().width() ); + widthLab2 = qMax( widthLab2, orientationScaleLab->minimumSizeHint().width() ); + + // -- other controls + myExtraGrp = new QFrame( mainFrame() ); + QLabel* shrinkSizeLab = new QLabel( tr( "SHRINK" ), myExtraGrp ); + myShrinkSize = new QtxIntSpinBox( myExtraGrp ); + myShrinkSize->setSuffix( "% "); + hl = new QHBoxLayout( myExtraGrp ); + hl->setMargin( MARGIN ); + hl->setSpacing( SPACING ); + hl->addWidget( shrinkSizeLab ); + hl->addWidget( myShrinkSize ); + hl->addStretch(); + widthLab1 = qMax( widthLab1, shrinkSizeLab->minimumSizeHint().width() ); + + // layout widgets + QVBoxLayout* vl = new QVBoxLayout( mainFrame() ); + vl->setMargin( 0 ); + vl->setSpacing( SPACING ); + vl->addWidget( myNodeGrp ); + vl->addWidget( myEdgeGrp ); + vl->addWidget( myFaceGrp ); + vl->addWidget( myVolumeGrp ); + vl->addWidget( myOutlineGrp ); + vl->addWidget( myElem0dGrp ); + vl->addWidget( myBallGrp ); + vl->addWidget( myOrientationGrp ); + vl->addWidget( myExtraGrp ); + + nodeColorLab->setMinimumWidth( widthLab1 ); + edgeColorLab->setMinimumWidth( widthLab1 ); + faceColorLab->setMinimumWidth( widthLab1 ); + volumeColorLab->setMinimumWidth( widthLab1 ); + outlineColorLab->setMinimumWidth( widthLab1 ); + elem0dColorLab->setMinimumWidth( widthLab1 ); + ballColorLab->setMinimumWidth( widthLab1 ); + orientationColorLab->setMinimumWidth( widthLab1 ); + shrinkSizeLab->setMinimumWidth( widthLab1 ); + + myNodeMarker->typeLabel()->setMinimumWidth( widthLab2 ); + edgeWidthLab->setMinimumWidth( widthLab2 ); + myFaceColor->label()->setMinimumWidth( widthLab2 ); + myVolumeColor->label()->setMinimumWidth( widthLab2 ); + outlineWidthLab->setMinimumWidth( widthLab2 ); + elem0dSizeLab->setMinimumWidth( widthLab2 ); + ballSizeLab->setMinimumWidth( widthLab2 ); + orientationScaleLab->setMinimumWidth( widthLab2 ); + + myEdgeWidth->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myOutlineWidth->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myElem0dSize->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myBallSize->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myOrientationSize->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + myShrinkSize->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); + + // initialize widgets + myNodeMarker->setCustomMarkers( customMarkers ); + myElem0dSize->setRange( 1, 10 ); + myBallSize->setRange( 1, 10 ); + myEdgeWidth->setRange( 1, 5 ); + myOutlineWidth->setRange( 1, 5 ); + myShrinkSize->setRange( 20, 100 ); + myOrientationSize->setRange( 5, 100 ); + + button( OK )->setText( tr( "SMESH_BUT_OK" ) ); +} + +/* + \brief Destructor: clean-up resources if necessary +*/ +SMESHGUI_PropertiesDlg::~SMESHGUI_PropertiesDlg() +{ +} + +/*! + \brief Set nodes color + \param color nodes color +*/ +void SMESHGUI_PropertiesDlg::setNodeColor( const QColor& color ) +{ + myNodeColor->setColor( color ); +} + +/*! + \brief Get nodes color + \return current nodes color +*/ +QColor SMESHGUI_PropertiesDlg::nodeColor() const +{ + return myNodeColor->color(); +} + +/*! + \brief Set standard nodes marker + \param type standard nodes marker type + \param scale standard nodes marker scale +*/ +void SMESHGUI_PropertiesDlg::setNodeMarker( VTK::MarkerType type, VTK::MarkerScale scale ) +{ + myNodeMarker->setMarker( type, scale ); +} + +/*! + \brief Set custom nodes marker + \param id custom nodes marker id +*/ +void SMESHGUI_PropertiesDlg::setNodeCustomMarker( int id ) +{ + myNodeMarker->setCustomMarker( id ); +} + +/*! + \brief Get nodes marker type. + For custom marker, VTK::MT_USER is returned and markerId() function + then returns its identifier. + \return currently selected nodes marker type +*/ +VTK::MarkerType SMESHGUI_PropertiesDlg::nodeMarkerType() const +{ + return myNodeMarker->markerType(); +} + +/*! + \brief Get nodes marker scale. + For custom marker return value is undefined. + \return currently selected nodes marker scale +*/ +VTK::MarkerScale SMESHGUI_PropertiesDlg::nodeMarkerScale() const +{ + return myNodeMarker->markerScale(); +} + +/*! + \brief Get custom nodes marker. + For standard markers return value is VTK::MT_NONE. + \return custom nodes marker id +*/ +int SMESHGUI_PropertiesDlg::nodeMarkerId() const +{ + return myNodeMarker->markerId(); +} + +/*! + \brief Set edges (wireframe) color + \param color edges color +*/ +void SMESHGUI_PropertiesDlg::setEdgeColor( const QColor& color ) +{ + myEdgeColor->setColor( color ); +} + +/*! + \brief Get edges (wireframe) color + \return current edges color +*/ +QColor SMESHGUI_PropertiesDlg::edgeColor() const +{ + return myEdgeColor->color(); +} + +/*! + \brief Set edges width + \param width edges width +*/ +void SMESHGUI_PropertiesDlg::setEdgeWidth( int width ) +{ + myEdgeWidth->setValue( width ); +} + +/*! + \brief Get edges width + \return current edges width +*/ +int SMESHGUI_PropertiesDlg::edgeWidth() const +{ + return myEdgeWidth->value(); +} + +/*! + \brief Set faces colors + \param color front faces color + \param delta back faces coloring delta +*/ +void SMESHGUI_PropertiesDlg::setFaceColor( const QColor& color, int delta ) +{ + myFaceColor->setMainColor( color ); + myFaceColor->setDelta( delta ); +} + +/*! + \brief Get front faces color + \return current front faces color +*/ +QColor SMESHGUI_PropertiesDlg::faceColor() const +{ + return myFaceColor->mainColor(); +} + +/*! + \brief Get back faces coloring delta + \return current back faces coloring delta +*/ +int SMESHGUI_PropertiesDlg::faceColorDelta() const +{ + return myFaceColor->delta(); +} + +/*! + \brief Set volumes colors + \param color normal volumes color + \param delta reversed volumes coloring delta +*/ +void SMESHGUI_PropertiesDlg::setVolumeColor( const QColor& color, int delta ) +{ + myVolumeColor->setMainColor( color ); + myVolumeColor->setDelta( delta ); +} + +/*! + \brief Get normal volumes color + \return current normal volumes color +*/ +QColor SMESHGUI_PropertiesDlg::volumeColor() const +{ + return myVolumeColor->mainColor(); +} + +/*! + \brief Get reversed volumes coloring delta + \return current reversed volumes coloring delta +*/ +int SMESHGUI_PropertiesDlg::volumeColorDelta() const +{ + return myVolumeColor->delta(); +} + +/*! + \brief Set outlines color + \param color outlines color +*/ +void SMESHGUI_PropertiesDlg::setOutlineColor( const QColor& color ) +{ + myOutlineColor->setColor( color ); +} + +/*! + \brief Get outlines color + \return current outlines color +*/ +QColor SMESHGUI_PropertiesDlg::outlineColor() const +{ + return myOutlineColor->color(); +} + +/*! + \brief Set outlines width + \param width outlines width +*/ +void SMESHGUI_PropertiesDlg::setOutlineWidth( int width ) +{ + myOutlineWidth->setValue( width ); +} + +/*! + \brief Get outlines width + \return current outlines width +*/ +int SMESHGUI_PropertiesDlg::outlineWidth() const +{ + return myOutlineWidth->value(); +} + +/*! + \brief Set 0D elements color + \param color 0D elements color +*/ +void SMESHGUI_PropertiesDlg::setElem0dColor( const QColor& color ) +{ + myElem0dColor->setColor( color ); +} + +/*! + \brief Get 0D elements color + \return current 0D elements color +*/ +QColor SMESHGUI_PropertiesDlg::elem0dColor() const +{ + return myElem0dColor->color(); +} + +/*! + \brief Set 0D elements size + \param size 0D elements size +*/ +void SMESHGUI_PropertiesDlg::setElem0dSize( int size ) +{ + myElem0dSize->setValue( size ); +} + +/*! + \brief Get 0D elements size + \return current 0D elements size +*/ +int SMESHGUI_PropertiesDlg::elem0dSize() const +{ + return myElem0dSize->value(); +} + +/*! + \brief Set discrete elements (balls) color + \param color discrete elements (balls) color +*/ +void SMESHGUI_PropertiesDlg::setBallColor( const QColor& color ) +{ + myBallColor->setColor( color ); +} + +/*! + \brief Get discrete elements (balls) color + \return current discrete elements (balls) color +*/ +QColor SMESHGUI_PropertiesDlg::ballColor() const +{ + return myBallColor->color(); +} + +/*! + \brief Set discrete elements (balls) size + \param size discrete elements (balls) size +*/ +void SMESHGUI_PropertiesDlg::setBallSize( int size ) +{ + myBallSize->setValue( size ); +} + +/*! + \brief Get discrete elements (balls) size + \return current discrete elements (balls) size +*/ +int SMESHGUI_PropertiesDlg::ballSize() const +{ + return myBallSize->value(); +} + +/*! + \brief Set orientation vectors color + \param color orientation vectors color +*/ +void SMESHGUI_PropertiesDlg::setOrientationColor( const QColor& color ) +{ + myOrientationColor->setColor( color ); +} + +/*! + \brief Get orientation vectors color + \return current orientation vectors color +*/ +QColor SMESHGUI_PropertiesDlg::orientationColor() const +{ + return myOrientationColor->color(); +} + +/*! + \brief Set orientation vectors scale (percent) + \param scale orientation vectors scale +*/ +void SMESHGUI_PropertiesDlg::setOrientationSize( int scale ) +{ + myOrientationSize->setValue( scale ); +} + +/*! + \brief Get orientation vectors scale (percent) + \return current orientation vectors scale +*/ +int SMESHGUI_PropertiesDlg::orientationSize() const +{ + return myOrientationSize->value(); +} + +/*! + \brief Set orientation vectors 3d flag + \param on orientation vectors 3d flag value +*/ +void SMESHGUI_PropertiesDlg::setOrientation3d( bool on ) +{ + myOrientation3d->setChecked( on ); +} + +/*! + \brief Get orientation vectors 3d flag + \return orientation vectors 3d flag value +*/ +bool SMESHGUI_PropertiesDlg::orientation3d() const +{ + return myOrientation3d->isChecked(); +} + +/*! + \brief Set shrink coefficient (percent) + \param coef shrink coefficient +*/ +void SMESHGUI_PropertiesDlg::setShrinkCoef( int coef ) +{ + myShrinkSize->setValue( coef ); +} + +/*! + \brief Get shrink coefficient (percent) + \return current shrink coefficient +*/ +int SMESHGUI_PropertiesDlg::shrinkCoef() const +{ + return myShrinkSize->value(); +} + +/* + \brief Get custom markers + \return custom markers map +*/ +VTK::MarkerMap SMESHGUI_PropertiesDlg::customMarkers() const +{ + return myNodeMarker->customMarkers(); +} + +/*! + \brief Show / hide controls for specified entity type + \param elements mesh element types (an or-ed combination of flags) + \param nodes mesh nodes presence flag +*/ +void SMESHGUI_PropertiesDlg::showControls( int elements, bool nodes ) +{ + // node controls are supposed to be shown if at least any element type is present + // or if there are only nodes + myNodeGrp->setVisible( nodes || elements & SMESH_Actor::eAllEntity ); + // edge controls are shown only if there are edges + myEdgeGrp->setVisible( elements & SMESH_Actor::eEdges ); + // face controls are shown only if there are faces + myFaceGrp->setVisible( elements & SMESH_Actor::eFaces ); + // volume controls are shown only if there are volumes + myVolumeGrp->setVisible( elements & SMESH_Actor::eVolumes ); + // 0d elements controls are shown only if there are 0d elements + myElem0dGrp->setVisible( elements & SMESH_Actor::e0DElements ); + // ball controls are shown only if there are balls + myBallGrp->setVisible( elements & SMESH_Actor::eBallElem ); + // outline controls are needed for faces and volumes + myOutlineGrp->setVisible( elements & ( SMESH_Actor::eFaces | SMESH_Actor::eVolumes ) ); + // orientation controls are needed for faces and volumes + myOrientationGrp->setVisible( elements & ( SMESH_Actor::eFaces | SMESH_Actor::eVolumes ) ); + // shrink factor is shown if there are edges and/or faces and/or volumes + myExtraGrp->setVisible( elements & ( SMESH_Actor::eEdges | SMESH_Actor::eFaces | SMESH_Actor::eVolumes ) ); +} diff --git a/src/SMESHGUI/SMESHGUI_PropertiesDlg.h b/src/SMESHGUI/SMESHGUI_PropertiesDlg.h new file mode 100644 index 000000000..4ff5c2ad5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PropertiesDlg.h @@ -0,0 +1,140 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SMESHGUI_PropertiesDlg.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef SMESHGUI_PROPERTIESDLG_H +#define SMESHGUI_PROPERTIESDLG_H + +#include "SMESH_SMESHGUI.hxx" +#include "SMESHGUI_Dialog.h" + +#include +#include +#include CORBA_CLIENT_HEADER(SMESH_Mesh) + +class QCheckBox; +class QFrame; +class QGroupBox; +class QtxColorButton; +class QtxBiColorTool; +class QtxIntSpinBox; +class VTKViewer_MarkerWidget; + +class SMESHGUI_EXPORT SMESHGUI_PropertiesDlg : public SMESHGUI_Dialog +{ + Q_OBJECT + +public: + SMESHGUI_PropertiesDlg( const VTK::MarkerMap&, QWidget* parent ); + ~SMESHGUI_PropertiesDlg(); + + void setNodeColor( const QColor& ); + QColor nodeColor() const; + void setNodeMarker( VTK::MarkerType, VTK::MarkerScale ); + void setNodeCustomMarker( int ); + VTK::MarkerType nodeMarkerType() const; + VTK::MarkerScale nodeMarkerScale() const; + int nodeMarkerId() const; + + void setEdgeColor( const QColor& ); + QColor edgeColor() const; + void setEdgeWidth( int ); + int edgeWidth() const; + + void setFaceColor( const QColor&, int ); + QColor faceColor() const; + int faceColorDelta() const; + + void setVolumeColor( const QColor&, int ); + QColor volumeColor() const; + int volumeColorDelta() const; + + void setOutlineColor( const QColor& ); + QColor outlineColor() const; + void setOutlineWidth( int ); + int outlineWidth() const; + + void setElem0dColor( const QColor& ); + QColor elem0dColor() const; + void setElem0dSize( int ); + int elem0dSize() const; + + void setBallColor( const QColor& ); + QColor ballColor() const; + void setBallSize( int ); + int ballSize() const; + + void setOrientationColor( const QColor& ); + QColor orientationColor() const; + void setOrientationSize( int ); + int orientationSize() const; + void setOrientation3d( bool ); + bool orientation3d() const; + + void setShrinkCoef( int ); + int shrinkCoef() const; + + VTK::MarkerMap customMarkers() const; + + void showControls( int, bool ); + +private: + // group boxes + QGroupBox* myNodeGrp; + QGroupBox* myEdgeGrp; + QGroupBox* myFaceGrp; + QGroupBox* myVolumeGrp; + QGroupBox* myOutlineGrp; + QGroupBox* myElem0dGrp; + QGroupBox* myBallGrp; + QGroupBox* myOrientationGrp; + QFrame* myExtraGrp; + // widgets + // - nodes + QtxColorButton* myNodeColor; + VTKViewer_MarkerWidget* myNodeMarker; + // - edges + QtxColorButton* myEdgeColor; + QtxIntSpinBox* myEdgeWidth; + // - faces + QtxBiColorTool* myFaceColor; + // - volumes + QtxBiColorTool* myVolumeColor; + // - outlines + QtxColorButton* myOutlineColor; + QtxIntSpinBox* myOutlineWidth; + // - 0d elements + QtxColorButton* myElem0dColor; + QtxIntSpinBox* myElem0dSize; + // - balls + QtxColorButton* myBallColor; + QtxIntSpinBox* myBallSize; + // - orientation vectors + QtxColorButton* myOrientationColor; + QtxIntSpinBox* myOrientationSize; + QCheckBox* myOrientation3d; + // - shrink coefficient + QtxIntSpinBox* myShrinkSize; +}; + +#endif // SMESHGUI_PROPERTIESDLG_H diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx index baafa985c..0da8d3a3a 100644 --- a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -610,14 +610,17 @@ namespace SMESH SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( aSObj )); if(!CORBA::is_nil(aGroup) && anActor) { - QColor c;int delta; - SMESH::GetColor( "SMESH", "fill_color", c, delta, "0,170,255|-100" ); + QColor c; + int deltaF, deltaV; + SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" ); + SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" ); + SMESH::GetColor( "SMESH", "default_grp_color", c ); SALOMEDS::Color aColor = aGroup->GetColor(); if( !( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 )) { - aColor.R = (float)c.red() / 255.0; - aColor.G = (float)c.green() / 255.0; - aColor.B = (float)c.blue() / 255.0; + aColor.R = c.redF(); + aColor.G = c.greenF(); + aColor.B = c.blueF(); aGroup->SetColor( aColor ); } if( aGroup->GetType() == SMESH::NODE ) @@ -628,8 +631,10 @@ namespace SMESH anActor->Set0DColor( aColor.R, aColor.G, aColor.B ); else if( aGroup->GetType() == SMESH::BALL ) anActor->SetBallColor( aColor.R, aColor.G, aColor.B ); + else if( aGroup->GetType() == SMESH::VOLUME ) + anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, deltaV ); else - anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, delta ); + anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, deltaF ); } } } @@ -1337,7 +1342,7 @@ namespace SMESH if( !anIsOk ) return false; - + DistanceToPosition( theBounds, theNormal, theDist, theOrigin ); return true; } diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index 584f9424f..84f6c2ee1 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -4063,6 +4063,14 @@ Please, create VTK viewer and try again PREF_BACKFACE Back surface color + + PREF_VOLUME + Volume color + + + PREF_REVERSEDVOLUME + Reversed volume color + PREF_WIREFRAME Wireframe color @@ -4305,7 +4313,11 @@ Please, create VTK viewer and try again PREF_WIDTH - Width + Line width + + + PREF_OUTLINE_WIDTH + Outline width PREF_PREVIEW_CHUNK_SIZE @@ -6860,152 +6872,140 @@ as they are of improper type: - SMESHGUI_Preferences_ColorDlg - - DIALOG_TITLE - Properties (color, line width, shrink size, ...) - - - GRP_ELEMENTS - Elements - - - SURFACE_COLOR_LBL - Surface color - + SMESHGUI_ReorientFacesDlg - BACKSURFACE_COLOR_LBL - Back surface color + CAPTION + Reorient faces by vector - OUTLINE_COLOR_LBL - Outline color + REORIENT_FACES + Reorient - WIREFRAME_COLOR_LBL - Wireframe color + DIRECTION + Direction - 0D_ELEMENTS_COLOR_LBL - 0D elements + OBJECT + Object - 0D_ELEMENTS_SIZE_LBL - Size of 0D elements + POINT + Point - BALL_ELEMENTS_COLOR_LBL - Ball elements + FACE + Face - BALL_ELEMENTS_SIZE_LBL - Size of balls + FACES + Faces source - LINE_WIDTH_LBL - Line width + ORIENTATION + Orientation + + + SMESHGUI_ReorientFacesOp - SHRINK_COEF_LBL - Shrink coef. + NO_OBJECT_SELECTED + No object selected - GRP_NODES - Nodes + NO_FACES + Object includes no faces - NODES_COLOR_LBL - Color + ZERO_SIZE_VECTOR + Zero size vector - NODES_MARKER_LBL - Marker + INVALID_FACE + Not valid face - GRP_ORIENTATION - Orientation of faces + NB_REORIENTED + %1 faces reversed + + + SMESHGUI_PropertiesDlg - ORIENTATION_COLOR_LBL - Color + TITLE + Properties - ORIENTATION_SCALE_LBL - Scale + NODES + Nodes - 3D_VECTORS_LBL - 3D vectors + EDGES + Edges / wireframe - GRP_SELECTION - Selection + FACES + Faces - SELECTION_COLOR_LBL - Selection color + VOLUMES + Volumes - PRESELECTION_COLOR_LBL - Pre-selection color + OUTLINES + Outlines - - - SMESHGUI_ReorientFacesDlg - CAPTION - Reorient faces by vector + 0D_ELEMENTS + 0D elements - REORIENT_FACES - Reorient + BALLS + Balls - DIRECTION - Direction + ORIENTATIONS + Orientation vectors - OBJECT - Object + COLOR + Color: - POINT - Point + WIDTH + Width: - FACE - Face + FACE_FRONT + Front: - FACES - Faces source + FACE_BACK + Back: - ORIENTATION - Orientation + VOLUME_NORMAL + Normal: - - - SMESHGUI_ReorientFacesOp - NO_OBJECT_SELECTED - No object selected + VOLUME_REVERSED + Reversed: - NO_FACES - Object includes no faces + SIZE + Size: - ZERO_SIZE_VECTOR - Zero size vector + ORIENTATION_SCALE + Scale: - INVALID_FACE - Not valid face + ORIENTATION_3D + 3D vectors - NB_REORIENTED - %1 faces reversed + SHRINK + Shrink coef: diff --git a/src/SMESHGUI/SMESH_msg_fr.ts b/src/SMESHGUI/SMESH_msg_fr.ts index 8d5abcce0..f4eb29edd 100755 --- a/src/SMESHGUI/SMESH_msg_fr.ts +++ b/src/SMESHGUI/SMESH_msg_fr.ts @@ -4031,6 +4031,14 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_BACKFACE Face arrière + + PREF_VOLUME + Volume color + + + PREF_REVERSEDVOLUME + Reversed volume color + PREF_WIREFRAME Couleur de contour @@ -4273,7 +4281,11 @@ Ouvrez une fenêtre VTK et essayez de nouveau PREF_WIDTH - Epaisseur + Line width + + + PREF_OUTLINE_WIDTH + Outline width PREF_PREVIEW_CHUNK_SIZE @@ -6821,152 +6833,140 @@ en raison de leurs types incompatibles: - SMESHGUI_Preferences_ColorDlg - - DIALOG_TITLE - Propriétés (couleur, épaisseur des traits, taille des éléments réduits, ...) - - - GRP_ELEMENTS - Eléments - - - SURFACE_COLOR_LBL - Couleur de surface - + SMESHGUI_ReorientFacesDlg - BACKSURFACE_COLOR_LBL - Couleur arrière + CAPTION + Réorienter des faces selon un vector - OUTLINE_COLOR_LBL - Couleur de contour + REORIENT_FACES + Réorienter - WIREFRAME_COLOR_LBL - Couleur en mode fil de fer + DIRECTION + Direction - 0D_ELEMENTS_COLOR_LBL - Eléments 0D + OBJECT + Objet - 0D_ELEMENTS_SIZE_LBL - Taille des éléments 0D + POINT + Point - BALL_ELEMENTS_COLOR_LBL - Eléments particulaires + FACE + Face - BALL_ELEMENTS_SIZE_LBL - Taille des éléments particulaires + FACES + Source des faces - LINE_WIDTH_LBL - Epaisseur des traits + ORIENTATION + Orientation + + + SMESHGUI_ReorientFacesOp - SHRINK_COEF_LBL - Coef. de contraction + NO_OBJECT_SELECTED + Aucun objet sélectionné - GRP_NODES - Nœuds + NO_FACES + L'objet ne contient pas de faces - NODES_COLOR_LBL - Couleur + ZERO_SIZE_VECTOR + Vecteur de taille nulle - NODES_MARKER_LBL - Marqueur + INVALID_FACE + Face non valide - GRP_ORIENTATION - Orientation des faces + NB_REORIENTED + %1 face(s) inversée(s) + + + SMESHGUI_PropertiesDlg - ORIENTATION_COLOR_LBL - Couleur + TITLE + Properties - ORIENTATION_SCALE_LBL - Facteur d'échelle + NODES + Nodes - 3D_VECTORS_LBL - Vecteurs 3D + EDGES + Edges / wireframe - GRP_SELECTION - Sélection + FACES + Faces - SELECTION_COLOR_LBL - Couleur de sélection + VOLUMES + Volumes - PRESELECTION_COLOR_LBL - Couleur de pré-sélection + OUTLINES + Outlines - - - SMESHGUI_ReorientFacesDlg - CAPTION - Réorienter des faces selon un vector + 0D_ELEMENTS + 0D elements - REORIENT_FACES - Réorienter + BALLS + Balls - DIRECTION - Direction + ORIENTATIONS + Orientation vectors - OBJECT - Objet + COLOR + Color: - POINT - Point + WIDTH + Width: - FACE - Face + FACE_FRONT + Front: - FACES - Source des faces + FACE_BACK + Back: - ORIENTATION - Orientation + VOLUME_NORMAL + Normal: - - - SMESHGUI_ReorientFacesOp - NO_OBJECT_SELECTED - Aucun objet sélectionné + VOLUME_REVERSED + Reversed: - NO_FACES - L'objet ne contient pas de faces + SIZE + Size: - ZERO_SIZE_VECTOR - Vecteur de taille nulle + ORIENTATION_SCALE + Scale: - INVALID_FACE - Face non valide + ORIENTATION_3D + 3D vectors - NB_REORIENTED - %1 face(s) inversée(s) + SHRINK + Shrink coef: