- 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 );