LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr ) return;
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+
+ if(!aStudy)
+ return;
+
SUIT_OverrideCursor();
SALOME_ListIO aList;
if ( viewWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
SVTK_ViewWindow* vw = dynamic_cast<SVTK_ViewWindow*>( viewWindow );
SVTK_View* aView = vw->getView();
+ int mgrId = viewWindow->getViewManager()->getGlobalId();
+ bool vectorMode = false;
aSelMgr->selectedObjects( aList );
SALOME_ListIteratorOfListIO It( aList );
anActors->InitTraversal();
while (vtkActor* anAct = anActors->GetNextActor()) {
GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
- aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode());
+ vectorMode = !aGeomActor->GetVectorMode();
+ aGeomActor->SetVectorMode(vectorMode);
}
}
+ if(mode == 0 || mode == 1) {
+ aStudy->setObjectProperty(mgrId,It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ } else if (mode == 3) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP , vectorMode);
+ }
}
}
aView->Repaint();
aSelMgr->selectedObjects( aList );
SALOME_ListIteratorOfListIO It( aList );
+ int mgrId = viewWindow->getViewManager()->getGlobalId();
+ bool vectorMode = 0;
for( ;It.More(); It.Next() ) {
SOCC_Viewer* soccViewer = (SOCC_Viewer*)(viewWindow->getViewManager()->getViewModel());
if (mode == 2 ) {
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
if ( !aSh.IsNull() ) {
- aSh->SetDisplayVectors(!aSh->isShowVectors());
+ vectorMode = !aSh->isShowVectors();
+ aSh->SetDisplayVectors(vectorMode);
ic->RecomputePrsOnly(interIter.Value());
}
}
}
+ if(mode == 0 || mode == 1) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),DISPLAY_MODE_PROP, mode);
+ } else if (mode == 2) {
+ aStudy->setObjectProperty(mgrId, It.Value()->getEntry(),VECTOR_MODE_PROP, vectorMode);
+ }
}
}
ic->UpdateCurrentViewer();
return 0;
}
+static inline int getViewManagerId( SALOME_View* theViewFrame) {
+ SUIT_ViewModel* aModel = dynamic_cast<SUIT_ViewModel*>(theViewFrame);
+ SUIT_ViewManager* aViewMgr = 0;
+ if(aModel != 0)
+ aViewMgr = aModel->getViewManager();
+ return ((aViewMgr == 0) ? -1 :aViewMgr->getGlobalId());
+}
+
//================================================================
// Function : getTopAbsMode
// Purpose : Get TopAbs_ShapeEnum value corresponding to the
if ( updateViewer )
vf->Repaint();
+ int aMgrId = getViewManagerId(vf);
+ SalomeApp_Study* aStudy = getStudy();
+ aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 1 );
+
+
delete prs; // delete presentation because displayer is its owner
}
}
if ( updateViewer )
vf->Repaint();
delete prs; // delete presentation because displayer is its owner
+
+ int aMgrId = getViewManagerId(vf);
+ SalomeApp_Study* aStudy = getStudy();
+ aStudy->setObjectProperty(aMgrId, theIO->getEntry(), VISIBILITY_PROP, 0 );
}
}
}
SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( prs );
if ( !occPrs )
return;
-
+
if ( myType == GEOM_MARKER && !myShape.IsNull() && myShape.ShapeType() == TopAbs_FACE )
{
TopoDS_Face aFace = TopoDS::Face( myShape );
// if presentation is empty we try to create new one
if ( occPrs->IsNull() )
{
- if ( !myShape.IsNull() )
- {
+ SalomeApp_Study* aStudy = getStudy();
+ if(!aStudy)
+ return;
+ if ( !myShape.IsNull() ) {
+
+ bool onlyVertex = (myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ));
+
+ QString anEntry;
+ int aMgrId = -1;
+ if(!myIO.IsNull()) {
+ aMgrId = getViewManagerId(myViewFrame);
+ anEntry = myIO->getEntry();
+ }
+ bool useStudy = !anEntry.isEmpty() && aMgrId != -1;
+ bool useObjColor = false;
+ bool useObjMarker = false;
+
+ PropMap aPropMap;
+ PropMap aDefPropMap;
+
+ if(useStudy){
+ aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
+ aDefPropMap = getDefaultPropepryMap(SOCC_Viewer::Type());
+ bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
+
+ if(isDiff)
+ aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+ }
+
//Handle(GEOM_AISShape) AISShape = new GEOM_AISShape( myShape, "" );
Handle(GEOM_AISShape) AISShape;
if (myType == GEOM_VECTOR)
AISShape->SetInfiniteState( myShape.Infinite() ); // || myShape.ShapeType() == TopAbs_VERTEX // VSR: 05/04/2010: Fix 20668 (Fit All for points & lines)
// Setup shape properties here ..., e.g. display mode, color, transparency, etc
- AISShape->SetDisplayMode( myDisplayMode );
- AISShape->SetShadingColor( myShadingColor );
+ if(useStudy) {
+ AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
+ AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
+
+ //Color property
+ if(aPropMap.contains(COLOR_PROP)) {
+ Quantity_Color quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
+ AISShape->SetShadingColor( quant_col );
+ } else
+ useObjColor = true;
+ }else {
+ AISShape->SetDisplayMode( myDisplayMode );
+ AISShape->SetShadingColor( myShadingColor );
+ }
+
+
// Set color and number for iso lines
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
QColor col = aResMgr->colorValue( "Geometry", "isos_color",
QColor(int(0.5*255), int(0.5*255), int(0.5*255)) );
Quantity_Color aColor = SalomeApp_Tools::color( col );
- int anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
- int aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
+
+ //get the ISOS number, set transparency if need
+ int anUIsoNumber, aVIsoNumber;
+ if(useStudy) {
+ QString anIsos = aPropMap.value(ISOS_PROP).toString();
+ QStringList uv = anIsos.split(DIGIT_SEPARATOR);
+ anUIsoNumber = uv[0].toInt();
+ aVIsoNumber = uv[1].toInt();
+ AISShape->SetTransparency(aPropMap.value(TRANSPARENCY_PROP).toDouble());
+ } else {
+ anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
+ aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
+ }
Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect();
anAspect->SetNumber( anUIsoNumber );
if ( HasColor() )
{
AISShape->SetColor( (Quantity_NameOfColor)GetColor() );
- Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
- anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
- if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
+ if ( onlyVertex )
{
- anAspect->SetScale( myScaleOfMarker );
- anAspect->SetTypeOfMarker( myTypeOfMarker );
- }
- AISShape->Attributes()->SetPointAspect( anAspect );
+ if(aPropMap.contains(MARKER_TYPE_PROP)) {
+ QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
+ if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
+ Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
+ int aTypeOfMarker = aList[0].toInt();
+ double aScaleOfMarker = aList[1].toDouble();
+ anAspect->SetScale( aScaleOfMarker );
+ anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1) );
+ anAspect->SetColor( (Quantity_NameOfColor)GetColor() );
+ AISShape->Attributes()->SetPointAspect( anAspect );
+ } else { //Custom marker string contains "IdOfTexsture"
+ int textureId = aList[0].toInt();
+ Standard_Integer aWidth, aHeight;
+ Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( aStudy, textureId, aWidth, aHeight );
+ if ( !aTexture.IsNull() ) {
+ static int TextureId = 0;
+ Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect((Quantity_NameOfColor)GetColor(),
+ ++TextureId,
+ aWidth, aHeight,
+ aTexture );
+ AISShape->Attributes()->SetPointAspect( aTextureAspect );
+
+ } else {
+ useObjMarker = true;
+ }
+ }
+ } else {
+ useObjMarker = true;
+ }
+ }
}
else
{
- if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) )
+ if ( onlyVertex )
{
col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) );
aColor = SalomeApp_Tools::color( col );
-
- Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
- anAspect->SetColor( aColor );
- anAspect->SetScale( myScaleOfMarker );
- anAspect->SetTypeOfMarker( myTypeOfMarker );
- AISShape->Attributes()->SetPointAspect( anAspect );
- }
+
+ if(aPropMap.contains(MARKER_TYPE_PROP)) {
+ QStringList aList = aPropMap.value(MARKER_TYPE_PROP).toString().split(DIGIT_SEPARATOR);
+ if(aList.size() == 2) { //Standard marker string contains "TypeOfMarker:ScaleOfMarker"
+ int aTypeOfMarker = aList[0].toInt();
+ double aScaleOfMarker = aList[1].toDouble();
+ Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
+ anAspect->SetScale( aScaleOfMarker );
+ anAspect->SetTypeOfMarker((Aspect_TypeOfMarker) (aTypeOfMarker-1) );
+ anAspect->SetColor( aColor );
+ AISShape->Attributes()->SetPointAspect( anAspect );
+ } else { //Custom marker string contains "IdOfTexsture"
+ int textureId = aList[0].toInt();
+ Standard_Integer aWidth, aHeight;
+ Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( aStudy, textureId, aWidth, aHeight );
+ if ( !aTexture.IsNull() ) {
+ static int TextureId = 0;
+ Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect(aColor,
+ ++TextureId,
+ aWidth, aHeight,
+ aTexture );
+ AISShape->Attributes()->SetPointAspect( aTextureAspect );
+
+ } else {
+ useObjMarker = true;
+ }
+ }
+ } else {
+ useObjMarker = true;
+ }
+ }
else
{
// Set line aspect
//AISShape->SetOwnDeviationAngle( 10*PI/180 );
// IMP 0020626
- double aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
+ double aDC = 0;
+ if(useStudy) {
+ aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
+ }
+ else {
+ aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
+ }
+
aDC = std::max( aDC, DEFLECTION_MIN ); // to avoid to small values of the coefficient
AISShape->SetOwnDeviationCoefficient(aDC);
}
AISShape->SetOwner( anObj );
}
- // Get color and other properties from GEOM_Object
- SUIT_Session* session = SUIT_Session::session();
- SUIT_Application* app = session->activeApplication();
- if ( app )
- {
- SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- if ( study )
- {
- Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO();
- if ( !anIO.IsNull() )
- {
- _PTR(SObject) SO ( study->studyDS()->FindObjectID( anIO->getEntry() ) );
- if ( SO )
- {
- // get CORBA reference to data object
- CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
- if ( !CORBA::is_nil( object ) )
- {
- // downcast to GEOM object
- GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
- if ( !aGeomObject->_is_nil() )
- {
- SALOMEDS::Color aSColor = aGeomObject->GetColor();
- bool hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
- if( !hasColor && aGeomObject->GetType() == GEOM_GROUP ) // auto color for group
- {
- GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
- GEOM::GEOM_IGroupOperations_var anOperations = aGeomGen->GetIGroupOperations( study->id() );
- GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( aGeomObject );
- if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() )
- {
- QList<SALOMEDS::Color> aReservedColors;
-
- SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( app );
- CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
- if ( strcmp(IOR.in(), "") != 0 )
- {
- _PTR(Study) aStudy = study->studyDS();
- _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) );
- _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
- for( ; it->More(); it->Next() )
- {
- _PTR(SObject) aChildSObject( it->Value() );
- GEOM::GEOM_Object_var aChildObject =
- GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
- if( CORBA::is_nil( aChildObject ) )
- continue;
-
- if( aChildObject->GetType() != GEOM_GROUP )
- continue;
-
- SALOMEDS::Color aReservedColor = aChildObject->GetColor();
- aReservedColors.append( aReservedColor );
- }
- }
-
- aSColor = getUniqueColor( aReservedColors );
- hasColor = true;
- }
- }
-
- if( hasColor )
- {
- Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
- AISShape->SetColor( aQuanColor );
- AISShape->SetShadingColor( aQuanColor );
- if ( myShape.ShapeType() == TopAbs_VERTEX || isCompoundOfVertices( myShape ) ) {
- Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
- anAspect->SetColor( aQuanColor );
- anAspect->SetScale( myScaleOfMarker );
- anAspect->SetTypeOfMarker( myTypeOfMarker );
- AISShape->Attributes()->SetPointAspect( anAspect );
- }
- }
- // ... marker type
- GEOM::marker_type aType = aGeomObject->GetMarkerType();
- GEOM::marker_size aSize = aGeomObject->GetMarkerSize();
- if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) {
- Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 );
- double aMSize = ((int)aSize+1)*0.5;
- Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
- anAspect->SetScale( aMSize );
- anAspect->SetTypeOfMarker( aMType );
- Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
- if ( hasColor )
- aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
- anAspect->SetColor( aQuanColor );
- AISShape->Attributes()->SetPointAspect( anAspect );
- }
- else if ( aType == GEOM::MT_USER ) {
- int aTextureId = aGeomObject->GetMarkerTexture();
- Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
- if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
- Standard_Integer aWidth, aHeight;
- Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( getStudy(), aTextureId, aWidth, aHeight );
- if ( !aTexture.IsNull() ) {
- static int TextureId = 0;
- Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect(aQuanColor,
- ++TextureId,
- aWidth, aHeight,
- aTexture );
- AISShape->Attributes()->SetPointAspect( aTextureAspect );
- }
- }
- }
- }
- }
- }
- }
- }
-
+ Handle( SALOME_InteractiveObject ) anIO = AISShape->getIO();
+ if ( !anIO.IsNull() ) {
+ _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
+ if ( SO ) {
+ // get CORBA reference to data object
+ CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
+ if ( !CORBA::is_nil( object ) ) {
+ // downcast to GEOM object
+ GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
+ bool hasColor = false;
+ SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
+ if( hasColor && useObjColor) {
+ Quantity_Color aQuanColor( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
+ AISShape->SetColor( aQuanColor );
+ AISShape->SetShadingColor( aQuanColor );
+ if ( onlyVertex ) {
+ Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
+ anAspect->SetColor( aQuanColor );
+ anAspect->SetScale( myScaleOfMarker );
+ anAspect->SetTypeOfMarker( myTypeOfMarker );
+ AISShape->Attributes()->SetPointAspect( anAspect );
+ }
+ } else if(!hasColor) {
+ //In case if color wasn't defined in the property map of the object
+ //and GEOM_Object color also wasn't defined get default color from Resource Mgr.
+ QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
+ Quantity_Color aQuanColor = SalomeApp_Tools::color( col );
+ AISShape->SetShadingColor( aQuanColor );
+ aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, col );
+ }
+
+ // ... marker type
+ if(useObjMarker) {
+ GEOM::marker_type aType = aGeomObject->GetMarkerType();
+ GEOM::marker_size aSize = aGeomObject->GetMarkerSize();
+ if ( aType > GEOM::MT_NONE && aType < GEOM::MT_USER && aSize > GEOM::MS_NONE && aSize <= GEOM::MS_70 ) {
+ Aspect_TypeOfMarker aMType = (Aspect_TypeOfMarker)( (int)aType-1 );
+ double aMSize = ((int)aSize+1)*0.5;
+ Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
+ anAspect->SetScale( aMSize );
+ anAspect->SetTypeOfMarker( aMType );
+ Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
+ if ( hasColor )
+ aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
+ anAspect->SetColor( aQuanColor );
+ AISShape->Attributes()->SetPointAspect( anAspect );
+ }
+ else if ( aType == GEOM::MT_USER ) {
+ int aTextureId = aGeomObject->GetMarkerTexture();
+ Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
+ if ( hasColor ) aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
+ Standard_Integer aWidth, aHeight;
+ Handle(Graphic3d_HArray1OfBytes) aTexture = GeometryGUI::getTexture( getStudy(), aTextureId, aWidth, aHeight );
+ if ( !aTexture.IsNull() ) {
+ static int TextureId = 0;
+ Handle(Prs3d_PointAspect) aTextureAspect = new Prs3d_PointAspect(aQuanColor,
+ ++TextureId,
+ aWidth, aHeight,
+ aTexture );
+ AISShape->Attributes()->SetPointAspect( aTextureAspect );
+ }
+ } else { //Use marker from the preferences
+ Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect();
+ anAspect->SetScale( myScaleOfMarker );
+ anAspect->SetTypeOfMarker( myTypeOfMarker );
+ Quantity_Color aQuanColor = SalomeApp_Tools::color( aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ) );
+ if ( hasColor )
+ aQuanColor = Quantity_Color( aSColor.R, aSColor.G, aSColor.B, Quantity_TOC_RGB );
+ anAspect->SetColor( aQuanColor );
+ AISShape->Attributes()->SetPointAspect( anAspect );
+ }
+ }
+ }
+ }
+ }
// AISShape->SetName(???); ??? necessary to set name ???
occPrs->AddObject( AISShape );
//=================================================================
void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
{
+ SalomeApp_Study* aStudy = getStudy();
+ int aMgrId = -1;
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
- if ( !vtkPrs || myShape.IsNull() )
+
+ if ( !vtkPrs || myShape.IsNull() || !aStudy)
return;
+
+ bool useStudy = false;
+ PropMap aPropMap;
vtkActorCollection* theActors = 0;
- if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE )
- {
+ if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) {
//myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657)
GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
-
- if ( HasColor() )
- {
+
+ if ( HasColor() ) {
Quantity_Color aColor( (Quantity_NameOfColor)GetColor() );
aTrh->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
}
gp_Ax2 anAx2 = aPlane->Pln().Position().Ax2();
aTrh->SetPlacement( new Geom_Axis2Placement( anAx2 ) );
-
-// if ( SVTK_Viewer* vf = dynamic_cast<SVTK_Viewer*>( GetActiveView() ) )
-// aTrh->SetSize( 0.5 * vf->GetTrihedronSize() );
+
+ // if ( SVTK_Viewer* vf = dynamic_cast<SVTK_Viewer*>( GetActiveView() ) )
+ // aTrh->SetSize( 0.5 * vf->GetTrihedronSize() );
vtkPrs->AddObject( aTrh );
theActors = vtkActorCollection::New();
theActors->AddItem( aTrh );
}
- else
- {
+ else {
theActors = GEOM_AssemblyBuilder::BuildActors( myShape, 0, 0, Standard_True, myType == GEOM_VECTOR );
+ QString anEntry;
+ if(!myIO.IsNull()) {
+ aMgrId = getViewManagerId(myViewFrame);
+ anEntry = myIO->getEntry();
+ }
+ useStudy = !anEntry.isEmpty() && aMgrId != -1;
+
+ if(useStudy){
+ aPropMap = aStudy->getObjectPropMap(aMgrId,anEntry);
+ PropMap aDefPropMap = getDefaultPropepryMap(SOCC_Viewer::Type());
+ bool isDiff = MergePropertyMaps(aPropMap, aDefPropMap);
+ if(isDiff)
+ aStudy->setObjectPropMap(aMgrId,anEntry,aPropMap);
+ }
}
theActors->InitTraversal();
-
+
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
-
+
vtkProperty* aProp = 0;
-
+
if ( HasColor() || HasWidth() )
{
aProp = vtkProperty::New();
{
GActor->SetProperty( aProp );
GActor->SetPreviewProperty( aProp );
-
- GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor );
- if ( aGeomGActor != 0 )
+ }
+
+ GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( anActor );
+ if ( aGeomGActor != 0 )
{
- aGeomGActor->SetShadingProperty( aProp );
- aGeomGActor->SetWireframeProperty( aProp );
+ if ( aProp ) {
+ aGeomGActor->SetShadingProperty( aProp );
+ aGeomGActor->SetWireframeProperty( aProp );
+ }
+ int aIsos[2]= { 1, 1 };
+ if(useStudy) {
+ QString anIsos = aPropMap.value(ISOS_PROP).toString();
+ QStringList uv = anIsos.split(DIGIT_SEPARATOR);
+ aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt();
+ aGeomGActor->SetNbIsos(aIsos);
+ aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
+ aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
+ aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
+ aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(), aGeomGActor->GetIsRelative());
+
+ vtkFloatingPointType aColor[3] = {1.,0.,0.};
+ if(aPropMap.contains(COLOR_PROP)) {
+ QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
+ aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
+ } else { //Get Color from geom object
+ Handle( SALOME_InteractiveObject ) anIO = aGeomGActor->getIO();
+ if ( !anIO.IsNull() ) {
+ _PTR(SObject) SO ( aStudy->studyDS()->FindObjectID( anIO->getEntry() ) );
+ if ( SO ) {
+ // get CORBA reference to data object
+ CORBA::Object_var object = GeometryGUI::ClientSObjectToObject(SO);
+ if ( !CORBA::is_nil( object ) ) {
+ // downcast to GEOM object
+ GEOM::GEOM_Object_var aGeomObject = GEOM::GEOM_Object::_narrow( object );
+ bool hasColor = false;
+ SALOMEDS::Color aSColor = getColor(aGeomObject,hasColor);
+ if(hasColor) {
+ aColor[0] = aSColor.R; aColor[1] = aSColor.G; aColor[2] = aSColor.B;
+ } else {
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if(aResMgr) {
+ QColor c = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
+ aColor[0] = c.red()/255.; aColor[1] = c.green()/255.; aColor[2] = c.blue()/255.;
+ aStudy->setObjectProperty( aMgrId, anIO->getEntry(), COLOR_PROP, c );
+ }
+ }
+ }
+ }
+ }
+ }
+ aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
+ }
}
- }
if ( myToActivate )
GActor->PickableOn();
return aSColor;
}
+
+
+
+PropMap GEOM_Displayer::getDefaultPropepryMap(const QString& viewer_type){
+ PropMap aDefaultMap;
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ //1. Visibility
+ aDefaultMap.insert(VISIBILITY_PROP , 1);
+
+ //2. Nb Isos
+ int anUIsoNumber;
+ int aVIsoNumber;
+ if(viewer_type == SOCC_Viewer::Type()) {
+ anUIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_u", 1);
+ aVIsoNumber = aResMgr->integerValue("OCCViewer", "iso_number_v", 1);
+ } else if( viewer_type==SVTK_Viewer::Type()) {
+ anUIsoNumber = 1;
+ aVIsoNumber = 1;
+ }
+ QString anIsos("%1%2%3");
+ anIsos = anIsos.arg(anUIsoNumber);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(aVIsoNumber);
+ aDefaultMap.insert(ISOS_PROP , anIsos);
+
+ //3. Transparency
+ aDefaultMap.insert( TRANSPARENCY_PROP , 0.0 );
+
+ //4. Display Mode
+ aDefaultMap.insert( DISPLAY_MODE_PROP , aResMgr->integerValue("Geometry", "display_mode", 0));
+
+ //5. Vector Mode
+ aDefaultMap.insert( VECTOR_MODE_PROP , 0);
+
+ //6. Color
+ QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
+ aDefaultMap.insert( COLOR_PROP , col);
+
+ //7. Deflection Coeff
+ double aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
+ aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
+
+ return aDefaultMap;
+}
+
+bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault) {
+ int nbInserted = 0;
+ if(!theOrigin.contains(VISIBILITY_PROP)) {
+ theOrigin.insert(VISIBILITY_PROP, 0);
+ nbInserted++;
+ }
+ if(!theOrigin.contains(TRANSPARENCY_PROP)) {
+ theOrigin.insert(TRANSPARENCY_PROP, theDefault.value(TRANSPARENCY_PROP));
+ nbInserted++;
+ }
+ if(!theOrigin.contains(DISPLAY_MODE_PROP)) {
+ theOrigin.insert(DISPLAY_MODE_PROP, theDefault.value(DISPLAY_MODE_PROP));
+ nbInserted++;
+ }
+ if(!theOrigin.contains(ISOS_PROP)) {
+ theOrigin.insert(ISOS_PROP, theDefault.value(ISOS_PROP));
+ nbInserted++;
+ }
+ if(!theOrigin.contains(VECTOR_MODE_PROP)) {
+ theOrigin.insert(VECTOR_MODE_PROP, theDefault.value(VECTOR_MODE_PROP));
+ nbInserted++;
+ }
+ if(!theOrigin.contains(DEFLECTION_COEFF_PROP)) {
+ theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
+ nbInserted++;
+ }
+ return (nbInserted > 0);
+}
+
+
+SALOMEDS::Color GEOM_Displayer::getColor(GEOM::GEOM_Object_var theGeomObject, bool& hasColor) {
+ SALOMEDS::Color aSColor;
+ hasColor = false;
+
+ SUIT_Session* session = SUIT_Session::session();
+ SUIT_Application* app = session->activeApplication();
+
+ if ( app && !theGeomObject->_is_nil()) {
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+
+ if ( study ) {
+ aSColor = theGeomObject->GetColor();
+ hasColor = aSColor.R >= 0 && aSColor.G >= 0 && aSColor.B >= 0;
+ if( !hasColor && theGeomObject->GetType() == GEOM_GROUP ) { // auto color for group
+ GEOM::GEOM_Gen_var theGeomGen = GeometryGUI::GetGeomGen();
+ GEOM::GEOM_IGroupOperations_var anOperations = theGeomGen->GetIGroupOperations( study->id() );
+ GEOM::GEOM_Object_var aMainObject = anOperations->GetMainShape( theGeomObject );
+ if ( !aMainObject->_is_nil() && aMainObject->GetAutoColor() )
+ {
+ QList<SALOMEDS::Color> aReservedColors;
+
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( app );
+ CORBA::String_var IOR = app->orb()->object_to_string( aMainObject );
+ if ( strcmp(IOR.in(), "") != 0 )
+ {
+ _PTR(Study) aStudy = study->studyDS();
+ _PTR(SObject) aMainSObject( aStudy->FindObjectIOR( std::string(IOR) ) );
+ _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) );
+ for( ; it->More(); it->Next() )
+ {
+ _PTR(SObject) aChildSObject( it->Value() );
+ GEOM::GEOM_Object_var aChildObject =
+ GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject));
+ if( CORBA::is_nil( aChildObject ) )
+ continue;
+
+ if( aChildObject->GetType() != GEOM_GROUP )
+ continue;
+
+ SALOMEDS::Color aReservedColor = aChildObject->GetColor();
+ aReservedColors.append( aReservedColor );
+ }
+ }
+
+ aSColor = getUniqueColor( aReservedColors );
+ hasColor = true;
+ }
+ }
+ }
+ }
+ return aSColor;
+}
#include <TopoDS_Shape.hxx>
#include <Quantity_Color.hxx>
#include <LightApp_Displayer.h>
+#include <LightApp_Study.h>
#include <Aspect_TypeOfMarker.hxx>
#include <QList>
static SALOMEDS::Color getUniqueColor( const QList<SALOMEDS::Color>& );
+ static PropMap getDefaultPropepryMap(const QString& viewer_type);
+
+ static bool MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault);
+
+ /*Get color of the geom object*/
+ static SALOMEDS::Color getColor(GEOM::GEOM_Object_var aGeomObject, bool& hasColor);
+
/* Builds presentation of not published object */
virtual SALOME_Prs* buildSubshapePresentation(const TopoDS_Shape& aShape,
const QString&,
componentName.c_str(),
savePoint);
_PTR(IParameters) ip = ClientFactory::getIParameters(ap);
-
- // viewers counters are used for storing view_numbers in IParameters
- int vtkViewers(0), occViewers(0);
-
+
QList<SUIT_ViewManager*> lst;
QList<SUIT_ViewManager*>::Iterator it;
// main cycle to store parameters of displayed objects
lst.clear();
- vtkViewers = occViewers = 0;
getApp()->viewManagers(lst);
- for (it = lst.begin(); it != lst.end(); it++)
- {
+ for (it = lst.begin(); it != lst.end(); it++) {
SUIT_ViewManager* vman = *it;
QString vType = vman->getType();
-
+ int aMgrId = vman->getGlobalId();
// saving VTK actors properties
- if (vType == SVTK_Viewer::Type())
- {
- 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]))
- {
- vtkActorCollection* allActors = vtkView->getRenderer()->GetActors();
- allActors->InitTraversal();
- while (vtkActor* actor = allActors->GetNextActor())
- {
- if (actor->GetVisibility()) // store only visible actors
- {
- GEOM_Actor* aGeomActor = 0;
- if (actor->IsA("GEOM_Actor"))
- aGeomActor = GEOM_Actor::SafeDownCast(actor);
- if (aGeomActor && aGeomActor->hasIO())
- {
- Handle(SALOME_InteractiveObject) io = aGeomActor->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, occParam = vType.toLatin1().data();
- occParam += gSeparator;
- occParam += QString::number(vtkViewers).toLatin1().data();
- occParam += gSeparator;
-
- param = occParam + "Visibility";
- ip->setParameter(entry, param, "On");
-
- param = occParam + "DisplayMode";
- ip->setParameter(entry, param, QString::number
- (aGeomActor->getDisplayMode()).toLatin1().data());
-
- vtkFloatingPointType r, g, b;
- aGeomActor->GetColor(r, g, b);
- QString colorStr = QString::number(r);
- colorStr += gDigitsSep; colorStr += QString::number(g);
- colorStr += gDigitsSep; colorStr += QString::number(b);
- param = occParam + "Color";
- ip->setParameter(entry, param, colorStr.toLatin1().data());
-
- param = occParam + "Opacity";
- ip->setParameter(entry, param, QString::number(aGeomActor->GetOpacity()).toLatin1().data());
-
- int nbUIso(0), nbVIso(0);
- aGeomActor->GetNbIsos(nbUIso,nbVIso);
- QString isosStr = QString::number(nbUIso);
- isosStr += gDigitsSep;
- isosStr += QString::number(nbVIso);
- param = occParam + "Isos";
- ip->setParameter(entry, param, isosStr.toLatin1().data());
- } // if (io->hasEntry())
- } // GEOM_Actor && hasIO
- } // isVisible
- } // while.. actors traversal
- } // if (vtkView)
- } // for (views)
- vtkViewers++;
- } // if (SVTK view model)
- else if (vType == SOCC_Viewer::Type()) // processing OCC viewers
- {
- QVector<SUIT_ViewWindow*> views = vman->getViews();
- for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++)
- {
- OCCViewer_ViewWindow* occView = dynamic_cast<OCCViewer_ViewWindow*>(views[i]);
- if (occView)
- {
- //Handle(AIS_InteractiveContext) ic =
- // ((OCCViewer_Viewer*)(occView->getViewManager()->getViewModel()))->getAISContext();
- OCCViewer_Viewer* viewModel = (OCCViewer_Viewer*)(vman->getViewModel());
- //OCCViewer_Viewer* viewModel = ((OCCViewer_ViewManager*)vman)->getOCCViewer();
- Handle(AIS_InteractiveContext) ic = viewModel->getAISContext();
-
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
-
- AIS_ListIteratorOfListOfInteractive ite (aList);
- for (; ite.More(); ite.Next())
- {
- if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape)))
- {
- Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
- if (aSh->hasIO())
- {
- Handle(SALOME_InteractiveObject) io =
- Handle(SALOME_InteractiveObject)::DownCast(aSh->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, occParam = vType.toLatin1().data();
- occParam += gSeparator;
- occParam += QString::number(occViewers).toLatin1().data();
- occParam += gSeparator;
-
- // Visibility
- param = occParam + "Visibility";
- ip->setParameter(entry, param, "On");
-
- // DisplayMode
- param = occParam + "DisplayMode";
- int dm = aSh->DisplayMode();
- ip->setParameter(entry, param, QString::number(dm).toLatin1().data());
-
- // Color
- // is a property of GEOM_Object, it is stored by GEOM engine
-
- // Transparency
- param = occParam + "Transparency";
- ip->setParameter(entry, param, QString::number(aSh->Transparency()).toLatin1().data());
-
- // Isos
- Handle(AIS_Drawer) aDrawer = aSh->Attributes();
- int nbUIso = aDrawer->UIsoAspect()->Number();
- int nbVIso = aDrawer->VIsoAspect()->Number();
- QString isosStr = QString::number(nbUIso);
- isosStr += gDigitsSep;
- isosStr += QString::number(nbVIso);
- param = occParam + "Isos";
- ip->setParameter(entry, param, isosStr.toLatin1().data());
- } // if (io->hasEntry())
- } // if (io)
- } // if (GEOM_AISShape)
- } // for (AIS_ListOfInteractive)
- } // if ( occView )
- } // for ( views )
- occViewers++;
- } // if (SOCC view model)
- else
- {
- // unknown viewer type
- }
+ QVector<SUIT_ViewWindow*> views = vman->getViews();
+ for (int i = 0, iEnd = vman->getViewsCount(); i < iEnd; i++) {
+ const ObjMap anObjects = appStudy->getObjectMap(aMgrId);
+ ObjMap::ConstIterator o_it = anObjects.begin();
+ for( ;o_it != anObjects.end(); o_it++ ) {
+ const PropMap aProps = o_it.value();
+
+ //Check that object exists in the study
+ _PTR(SObject) obj( studyDS->FindObjectID( o_it.key().toLatin1().data() ) );
+ if ( !obj )
+ continue;
+ // 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(o_it.key().toLatin1().data(), componentName);
+
+ _PTR(GenericAttribute) anAttr;
+ if( !obj->FindAttribute(anAttr, "AttributeIOR"))
+ continue;
+
+ std::string param, occParam = vType.toLatin1().data();
+ occParam += NAME_SEPARATOR;
+ occParam += QString::number(aMgrId).toLatin1().data();
+ occParam += NAME_SEPARATOR;
+
+ param = occParam + VISIBILITY_PROP;
+ ip->setParameter(entry, param, aProps.value(VISIBILITY_PROP).toInt() == 1 ? "On" : "Off");
+
+ param = occParam + DISPLAY_MODE_PROP;
+
+ ip->setParameter(entry, param, QString::number(aProps.value(DISPLAY_MODE_PROP).toInt()).toLatin1().data());
+
+ QColor c = aProps.value(COLOR_PROP).value<QColor>();
+ QString colorStr = QString::number(c.red()/255.);
+ colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.green()/255.);
+ colorStr += DIGIT_SEPARATOR; colorStr += QString::number(c.blue()/255.);
+ param = occParam + COLOR_PROP;
+ ip->setParameter(entry, param, colorStr.toLatin1().data());
+
+ if(vType == SVTK_Viewer::Type()) {
+ param = occParam + OPACITY_PROP;
+ ip->setParameter(entry, param, QString::number(1. - aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+ } else if (vType == SOCC_Viewer::Type()) {
+ param = occParam + TRANSPARENCY_PROP;
+ ip->setParameter(entry, param, QString::number(aProps.value(TRANSPARENCY_PROP).toDouble()).toLatin1().data());
+ }
+
+ param = occParam + ISOS_PROP;
+ ip->setParameter(entry, param, aProps.value(ISOS_PROP).toString().toLatin1().data());
+
+ param = occParam + VECTOR_MODE_PROP;
+ ip->setParameter(entry, param, QString::number(aProps.value(VECTOR_MODE_PROP).toInt()).toLatin1().data());
+
+ param = occParam + DEFLECTION_COEFF_PROP;
+ ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
+
+ param = occParam + DEFLECTION_COEFF_PROP;
+ ip->setParameter(entry, param, QString::number(aProps.value(DEFLECTION_COEFF_PROP).toDouble()).toLatin1().data());
+
+ //Marker type of the vertex - ONLY for the "Vertex" and "Compound of the Vertex"
+ if(aProps.contains(MARKER_TYPE_PROP)) {
+ param = occParam + MARKER_TYPE_PROP;
+ ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
+ }
+
+ } // object iterator
+ } // for (views)
} // for (viewManagers)
}
-
/*!
* \brief Restore visual parameters
*
NCollection_DataMap<int, GEOM_Actor* > vtkActors;
NCollection_DataMap<int, Handle(GEOM_AISShape)> occActors;
+ QString viewerTypStr;
+ QString viewIndexStr;
+ int viewIndex;
+ QVector<PropMap> aListOfMap;
+
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);
+ QStringList lst = QString((*namesIt).c_str()).split(NAME_SEPARATOR, QString::SkipEmptyParts);
if (lst.size() != 3)
continue;
- QString viewerTypStr = lst[0];
- QString viewIndexStr = lst[1];
+ viewerTypStr = lst[0];
+ viewIndexStr = lst[1];
QString paramNameStr = lst[2];
bool ok;
- int viewIndex = viewIndexStr.toUInt(&ok);
+ viewIndex = viewIndexStr.toUInt(&ok);
if (!ok) // bad conversion of view index to integer
continue;
+
+ if((viewIndex + 1) > aListOfMap.count()) {
+ aListOfMap.resize(viewIndex + 1);
+ }
- // viewers
- if (viewerTypStr == SVTK_Viewer::Type())
- {
- GEOM_Actor* vActor = 0;
- if (vtkActors.IsBound(viewIndex))
- vActor = vtkActors.Find(viewIndex);
+ QString val((*valuesIt).c_str());
+ if(paramNameStr == VISIBILITY_PROP){
+ aListOfMap[viewIndex].insert(VISIBILITY_PROP, val == "On" ? 1 : 0);
+
+ } else if(paramNameStr == OPACITY_PROP) {
+ aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, 1. - val.toDouble());
+
+ } else if(paramNameStr == TRANSPARENCY_PROP) {
+ aListOfMap[viewIndex].insert(TRANSPARENCY_PROP, val.toDouble());
+
+ } else if(paramNameStr == DISPLAY_MODE_PROP) {
+ aListOfMap[viewIndex].insert( DISPLAY_MODE_PROP, val.toInt());
+
+ } else if(paramNameStr == ISOS_PROP) {
+ aListOfMap[viewIndex].insert( ISOS_PROP, val);
+
+ } else if(paramNameStr == COLOR_PROP) {
+ QStringList rgb = val.split(DIGIT_SEPARATOR);
+ if(rgb.count() == 3) {
+ QColor c(int(rgb[0].toDouble()*255), int(rgb[1].toDouble()*255), int(rgb[2].toDouble()*255));
+ aListOfMap[viewIndex].insert( COLOR_PROP, c);
+ }
+ } else if(paramNameStr == VECTOR_MODE_PROP) {
+ aListOfMap[viewIndex].insert( VECTOR_MODE_PROP, val.toInt());
+
+ } else if(paramNameStr == DEFLECTION_COEFF_PROP) {
+ aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
+ } else if(paramNameStr == MARKER_TYPE_PROP) {
+ aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
+ }
- if (paramNameStr == "Visibility")
- {
- if (!vActor && displayer())
- {
- 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);
- 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();
- vtkActorCollection* theActors = Renderer->GetActors();
- theActors->InitTraversal();
- bool isFound = false;
- vtkActor *ac = theActors->GetNextActor();
- for (; ac != NULL && !isFound; ac = theActors->GetNextActor()) {
- if (ac->IsA("GEOM_Actor")) {
- GEOM_Actor* aGeomAc = GEOM_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 GEOM_Actor
- if (vActor)
- {
- QString val ((*valuesIt).c_str());
+ } // for names/parameters iterator
- if (paramNameStr == "DisplayMode") {
- vActor->setDisplayMode(val.toInt());
- }
- else if (paramNameStr == "Color") {
- QStringList colors = val.split(gDigitsSep, QString::SkipEmptyParts);
- if (colors.count() == 3)
- vActor->SetColor(colors[0].toFloat(), colors[1].toFloat(), colors[2].toFloat());
- }
- else if (paramNameStr == "Opacity") {
- vActor->SetOpacity(val.toFloat());
- }
- else if (paramNameStr == "Isos") {
- QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
- if (isos.count() == 2) {
- int aIsos[2] = {isos[0].toInt(), isos[1].toInt()};
- vActor->SetNbIsos(aIsos);
- }
- }
- }
- } // other parameters than Visibility
- }
- else if (viewerTypStr == SOCC_Viewer::Type())
- {
- //Handle(AIS_InteractiveObject) occActor;
- Handle(GEOM_AISShape) occActor;
- if (occActors.IsBound(viewIndex))
- occActor = occActors.Find(viewIndex);
-
- // ViewModel and InteractiveContext
- SOCC_Viewer* occVModel = 0;
- Handle(AIS_InteractiveContext) ic;
-
- QList<SUIT_ViewManager*> lst;
- getApp()->viewManagers(viewerTypStr, lst);
-
- // SOCC 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);
- SUIT_ViewModel* vmodel = vman->getViewModel();
- occVModel = dynamic_cast<SOCC_Viewer*>(vmodel);
- if (occVModel)
- ic = occVModel->getAISContext();
- }
+ QList<SUIT_ViewManager*> lst = getApp()->viewManagers();
- if (ic.IsNull())
- continue;
+ for (int index = 0 ; index < aListOfMap.count(); index++) {
- if (paramNameStr == "Visibility")
- {
- if (occActor.IsNull() && displayer())
- {
- displayer()->Display(entry, true, occVModel);
-
- // store displayed actor in a temporary map for quicker
- // access later when restoring other parameters
- AIS_ListOfInteractive aList;
- ic->DisplayedObjects(aList);
- bool isFound = false;
- AIS_ListIteratorOfListOfInteractive ite (aList);
- for (; ite.More() && !isFound; ite.Next()) {
- if (ite.Value()->IsInstance(STANDARD_TYPE(GEOM_AISShape))) {
- Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(ite.Value());
- if (aSh->hasIO()) {
- Handle(SALOME_InteractiveObject) io =
- Handle(SALOME_InteractiveObject)::DownCast(aSh->getIO());
- if (io->hasEntry() && strcmp(io->getEntry(), entry.toLatin1().data()) == 0) {
- isFound = true;
- occActors.Bind(viewIndex, aSh);
- }
- }
- }
- }
- }
- } // if (paramNameStr == "Visibility")
- else
- {
- // the rest properties "work" with GEOM_AISShape
- if (!occActor.IsNull())
- {
- QString val ((*valuesIt).c_str());
-
- if (paramNameStr == "DisplayMode") {
- ic->SetDisplayMode(occActor, AIS_DisplayMode(val.toInt()), false);
- //ic->Redisplay(occActor, Standard_False, Standard_True);
- }
- // Color is restored by the GEOM engine
- else if (paramNameStr == "Transparency") {
- ic->SetTransparency(occActor, val.toFloat(), false);
- ic->Redisplay(occActor, Standard_False, Standard_True);
- }
- else if (paramNameStr == "Isos") {
- QStringList isos = val.split(gDigitsSep, QString::SkipEmptyParts);
- if (isos.count() == 2) {
- Handle(AIS_Drawer) aDrawer = occActor->Attributes();
- int nbUIso = isos[0].toInt();
- int nbVIso = isos[1].toInt();
- Handle(Prs3d_IsoAspect) uIsoAspect = aDrawer->UIsoAspect();
- Handle(Prs3d_IsoAspect) vIsoAspect = aDrawer->VIsoAspect();
- uIsoAspect->SetNumber(nbUIso);
- vIsoAspect->SetNumber(nbVIso);
- aDrawer->SetUIsoAspect(uIsoAspect);
- aDrawer->SetVIsoAspect(vIsoAspect);
- ic->SetLocalAttributes(occActor, aDrawer);
- ic->Redisplay(occActor);
- }
- }
- }
- } // other parameters than Visibility
- }
- else
- {
- // unknown viewer type
+ appStudy->setObjectPropMap(index, entry, aListOfMap[index]);
+
+ QColor c = aListOfMap[index].value(COLOR_PROP).value<QColor>();
+ //Get Visibility property of the current PropMap
+ if(aListOfMap[index].value(VISIBILITY_PROP) == 1) {
+ SUIT_ViewManager* vman = lst.at(index);
+ SUIT_ViewModel* vmodel = vman->getViewModel();
+ displayer()->Display(entry, true, dynamic_cast<SALOME_View*>(vmodel));
}
- } // for names/parameters iterator
+ }
+
} // for entries iterator
-
+
// update all VTK and OCC views
QList<SUIT_ViewManager*> lst;
getApp()->viewManagers(lst);
// minimum allowed value for deflection coefficient
#define DEFLECTION_MIN 1e-06
+//Define separators
+#define NAME_SEPARATOR '_' // character used to separate parameter names
+#define DIGIT_SEPARATOR ':' // character used to separate numeric parameter values (color = r:g:b)
+
+#define VISIBILITY_PROP "Visibility" //Object visibility property
+#define OPACITY_PROP "Opacity" //Object opacity property
+#define TRANSPARENCY_PROP "Transparency" //Object transparency property
+#define DISPLAY_MODE_PROP "DisplayMode" //Object display mode property
+#define ISOS_PROP "Isos" //Number of the Isos property of the object
+#define COLOR_PROP "Color" //Color of the object
+#define VECTOR_MODE_PROP "VectorMode" //Vector mode property
+#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
+#define MARKER_TYPE_PROP "MarkerType" // Marker type property
+
+
class QDialog;
class QMenu;
class GEOMGUI_OCCSelector;
QMap<QString,QString> toBeDeleted;
QMap<QString,QString> allDeleted;
bool isComponentSelected = false;
+
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject) anIObject = It.Value();
if ( !anIObject->hasEntry() )
// remove object from GEOM engine
removeObjectWithChildren( obj, aStudy, views, disp );
// remove objects from study
- aStudyBuilder->RemoveObjectWithChildren( obj );
+ aStudyBuilder->RemoveObjectWithChildren( obj );
}
}
+
+
selected.Clear();
aSelMgr->setSelectedObjects( selected );
_PTR(GenericAttribute) anAttr;
if (obj->FindAttribute(anAttr, "AttributeIOR")) {
_PTR(AttributeIOR) anIOR (anAttr);
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
// Delete shape in Client
const TCollection_AsciiString ASCIor ((char*)anIOR->Value().c_str());
CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
if (!CORBA::is_nil(geomObj)) {
+
+ //Remove visual properties of the object
+ appStudy->removeObjectFromAll(obj->GetID().c_str());
+
// Erase graphical object
QListIterator<SALOME_View*> it( views );
while ( it.hasNext() )
SUIT_ViewWindow* window = app->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+ int mgrId = window->getViewManager()->getGlobalId();
if ( isVTK ) {
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW )
SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aView->SetColor( It.Value(), c );
- }
+ appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
+ }
GeometryGUI::Modified();
}
} // if ( isVTK )
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
+ appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
+
io->Redisplay( Standard_True );
// store color to GEOM_Object
GEOM::GEOM_Object_var anObject =
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
+
SALOMEDS::Color aSColor;
aSColor.R = (double)c.red() / 255.0;
aSColor.G = (double)c.green() / 255.0;
void GEOMToolsGUI::OnNbIsos( ActionType actionType )
{
- SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SalomeApp_Application* app =
+ dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ SUIT_ViewWindow* window = app->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
newNbUIso = NbIsosDlg->getU();
newNbVIso = NbIsosDlg->getV();
- }
+ } else //Cancel case
+ return;
}
else if ( actionType == INCR || actionType == DECR ) {
int delta = 1;
for(; ic->MoreCurrent(); ic->NextCurrent()) {
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
+
+
+
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
ic->SetLocalAttributes(CurObject, CurDrawer);
ic->Redisplay(CurObject);
+
+ QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
+ int aMgrId = window->getViewManager()->getGlobalId();
+ aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), "Isos", anIsos);
}
}
GeometryGUI::Modified();
newNbUIso = NbIsosDlg->getU();
newNbVIso = NbIsosDlg->getV();
- }
+ } else
+ return; //Cancel case
}
else if ( actionType == INCR || actionType == DECR ) {
int delta = 1;
// There are no casting to needed actor.
int aIsos[2]={newNbUIso,newNbVIso};
anActor->SetNbIsos(aIsos);
+
+ QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
+ int aMgrId = window->getViewManager()->getGlobalId();
+ aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
}
anAct = aCollection->GetNextActor();
}
void GEOMToolsGUI::OnDeflection()
{
SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
+
bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
+ int mgrId = window->getViewManager()->getGlobalId();
if (isOCC) { // if is OCCViewer
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
ic->Redisplay(CurObject);
+ appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
}
}
}
// There are no casting to needed actor.
bool isRel = anActor->GetIsRelative();
anActor->SetDeflection(aDC, isRel);
+ appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
}
anAct = aCollection->GetNextActor();
}
#include <QtxComboBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
{
if ( getStudy() ) {
LightApp_SelectionMgr* selMgr = qobject_cast<SalomeApp_Application*>( getStudy()->application() )->selectionMgr();
- if ( selMgr ) {
- SALOME_ListIO selected;
- selMgr->selectedObjects( selected );
- if ( !selected.IsEmpty() ) {
- _PTR(Study) study = getStudy()->studyDS();
- for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) {
- _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) );
- GEOM::GEOM_Object_var anObject =
- GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) );
- if ( !anObject->_is_nil() ) {
- if ( myWGStack->currentIndex() == 0 )
- anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() );
- else if ( getCustomMarkerID() > 0 )
- anObject->SetMarkerTexture( getCustomMarkerID() );
- }
- }
- GEOM_Displayer displayer( getStudy() );
- displayer.Redisplay( selected, true );
- selMgr->setSelectedObjects( selected );
+
+ SUIT_ViewWindow* window = getStudy()->application()->desktop()->activeWindow();
+ if (window && window->getViewManager()) {
+ int mgrId = window->getViewManager()->getGlobalId();
+ if ( selMgr ) {
+ SALOME_ListIO selected;
+ selMgr->selectedObjects( selected );
+ if ( !selected.IsEmpty() ) {
+ _PTR(Study) study = getStudy()->studyDS();
+ for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) {
+ _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) );
+ GEOM::GEOM_Object_var anObject =
+ GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) );
+ if ( !anObject->_is_nil() ) {
+ if ( myWGStack->currentIndex() == 0 ) {
+ anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() );
+ QString aMarker = "%1%2%3";
+ aMarker = aMarker.arg(getMarkerType());
+ aMarker = aMarker.arg(DIGIT_SEPARATOR);
+ aMarker = aMarker.arg(getStandardMarkerScale());
+ getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, aMarker);
+ }
+ else if ( getCustomMarkerID() > 0 ) {
+ anObject->SetMarkerTexture( getCustomMarkerID() );
+ getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, QString::number(getCustomMarkerID()));
+ }
+ }
+ }
+ GEOM_Displayer displayer( getStudy() );
+ displayer.Redisplay( selected, true );
+ selMgr->setSelectedObjects( selected );
+ }
}
}
}
#include <SalomeApp_Application.h>
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
+#include <SalomeApp_Study.h>
#include <QLabel>
#include <QPushButton>
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( !aSelMgr )
return;
+
+ SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
+
+ if(!aStudy)
+ return;
+
SALOME_ListIO selected;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() )
SUIT_ViewWindow* window = app->desktop()->activeWindow();
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
-
+ int aMgrId = window->getViewManager()->getGlobalId();
if ( isVTK ) {
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW )
SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aView->SetTransparency( It.Value(), newValue );
+ aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue );
}
GeometryGUI::Modified();
aView->Repaint();
if ( found ) {
ic->SetTransparency( aisShape, newValue, false );
ic->Redisplay( aisShape, Standard_False, Standard_True );
+ aStudy->setObjectProperty( aMgrId , It.Value()->getEntry(), TRANSPARENCY_PROP , newValue );
}
} // for...
ic->UpdateCurrentViewer();
// Toggle display mode
setDisplayMode(0); // WIRE FRAME
+ SetVectorMode(0); //
}