+
+
+
+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 = aResMgr->integerValue("VTKViewer", "iso_number_u", 1);
+ aVIsoNumber = aResMgr->integerValue("VTKViewer", "iso_number_u", 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;
+
+ if(viewer_type == SOCC_Viewer::Type()) {
+ aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
+ } else if( viewer_type==SVTK_Viewer::Type()) {
+ aDC = 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;
+}
+
+
+void GEOM_Displayer::EraseWithChildren(const Handle(SALOME_InteractiveObject)& theIO,
+ const bool eraseOnlyChildren) {
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if ( !app )
+ return;
+
+ SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( !appStudy )
+ return;
+
+ LightApp_DataObject* parent = appStudy->findObjectByEntry(theIO->getEntry());
+
+ if( !parent)
+ return;
+
+ // Erase from all views
+ QList<SALOME_View*> views;
+ SALOME_View* view;
+ ViewManagerList vmans = app->viewManagers();
+ SUIT_ViewManager* vman;
+ foreach ( vman, vmans ) {
+ SUIT_ViewModel* vmod = vman->getViewModel();
+ view = dynamic_cast<SALOME_View*> ( vmod );
+ if ( view )
+ views.append( view );
+ }
+
+ if( views.count() == 0 )
+ return;
+
+ //Erase childrens w/o update views
+ DataObjectList listObj = parent->children( true );
+ SUIT_DataObject* obj;
+ foreach( obj, listObj ) {
+ LightApp_DataObject* l_obj = dynamic_cast<LightApp_DataObject*>(obj);
+ if(l_obj)
+ foreach ( view, views ) {
+ Handle(SALOME_InteractiveObject) anIO =
+ new SALOME_InteractiveObject(qPrintable(l_obj->entry()), "GEOM", "");
+ Erase(anIO, false, false, view);
+ }
+ }
+
+ //Erase parent with view update or repaint views
+ foreach ( view, views ) {
+ if(!eraseOnlyChildren)
+ Erase(theIO, false, true, view);
+ else
+ view->Repaint();
+ }
+}