X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI_1.cxx;h=95086a66061934e0aaaea24cd3d06b28b0c00e09;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=fd817c14ac92d41eace7455c361ec7753bf3cf40;hpb=bec320673b7507612a07e033cb3d576eb5d1607b;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index fd817c14a..95086a660 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2022 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 @@ -24,7 +24,9 @@ // File : GEOMToolsGUI_1.cxx // Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) +#ifndef DISABLE_PYCONSOLE #include +#endif #include "GEOMToolsGUI.h" #include "GEOMToolsGUI_TransparencyDlg.h" @@ -34,6 +36,7 @@ #include "GEOMToolsGUI_PublishDlg.h" #include "GEOMToolsGUI_MaterialPropertiesDlg.h" #include "GEOMToolsGUI_LineWidthDlg.h" +#include "GEOMToolsGUI_ReduceStudyDlg.h" #include #include @@ -46,12 +49,13 @@ #include #include -#include - -#include +#ifndef DISABLE_GRAPHICSVIEW +#include +#include +#include +#endif #include -#include #include @@ -72,6 +76,10 @@ #include #include +#include + +#include + #include #include #include @@ -84,7 +92,6 @@ #include "utilities.h" // OCCT Includes -#include #include #include #include @@ -92,15 +99,11 @@ #include #include - -#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 #include -#else -#include -#endif // QT Includes #include +#include #include #include #include @@ -115,14 +118,17 @@ // VTK includes #include -class QtxDialog; // If the next macro is defined, autocolor feature works for all sub-shapes; // if it is undefined, autocolor feature works for groups only #define GENERAL_AUTOCOLOR // Below macro, when uncommented, switches on simplified (more performant) algorithm // of auto-color picking up #define SIMPLE_AUTOCOLOR +// Below macro, when defined, switches on automatic layouting of OCC and Dependency views +// on Show Dependencies operation +#define LAYOUT_DEPVIEW +#ifndef DISABLE_PYCONSOLE void GEOMToolsGUI::OnCheckGeometry() { SalomeApp_Application* app = @@ -132,6 +138,7 @@ void GEOMToolsGUI::OnCheckGeometry() if (pyConsole) pyConsole->exec("from GEOM_usinggeom import *"); } +#endif void GEOMToolsGUI::OnAutoColor() { @@ -153,13 +160,13 @@ void GEOMToolsGUI::OnAutoColor() _PTR(Study) aStudy = appStudy->studyDS(); _PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry())); GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject)); - if (CORBA::is_nil(aMainObject)) return; + if (CORBA::is_nil(aMainObject) || !GeometryGUI::IsInGeomComponent( aMainSObject )) return; aMainObject->SetAutoColor( true ); QList aReservedColors; - GEOM_Displayer displayer ( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -188,9 +195,9 @@ void GEOMToolsGUI::OnAutoColor() QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) ); - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; - appStudy->setObjectProperty( aMgrId, aChildObject->GetEntry(), GEOM::propertyName( GEOM::Color ), c ); + appStudy->setObjectProperty( aMgrId, aChildObject->GetStudyEntry(), GEOM::propertyName( GEOM::Color ), c ); Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject( aChildObject->GetStudyEntry(), "GEOM", "" ); if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); } @@ -222,7 +229,7 @@ void GEOMToolsGUI::OnDisableAutoColor() _PTR(Study) aStudy = appStudy->studyDS(); _PTR(SObject) aMainSObject( aStudy->FindObjectID( anIObject->getEntry() ) ); GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject)); - if( CORBA::is_nil( aMainObject ) ) + if( CORBA::is_nil( aMainObject ) || !GeometryGUI::IsInGeomComponent( aMainSObject )) return; aMainObject->SetAutoColor( false ); @@ -247,7 +254,7 @@ void GEOMToolsGUI::OnColor() aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; // get active view SALOME_View* window = displayer.GetActiveView(); @@ -263,10 +270,17 @@ void GEOMToolsGUI::OnColor() color = QColorDialog::getColor( v.value(), app->desktop() ); if ( !color.isValid() ) return; + SALOMEDS::Color aSColor; + aSColor.R = (double)color.red() / 255.0; + aSColor.G = (double)color.green() / 255.0; + aSColor.B = (double)color.blue() / 255.0; + // iterate through list of objects and assign new color - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle( SALOME_InteractiveObject ) io = It.Value(); + GEOM::GEOM_Object_var aObject = GEOMBase::ConvertIOinGEOMObject( io ); + if ( !CORBA::is_nil( aObject ) ) aObject->SetColor( aSColor ); appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Color ), color ); if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); } @@ -292,7 +306,7 @@ void GEOMToolsGUI::OnTexture() aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -335,7 +349,7 @@ void GEOMToolsGUI::OnChangeTransparency( bool increase ) aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -380,7 +394,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -407,7 +421,7 @@ void GEOMToolsGUI::OnNbIsos( ActionType actionType ) NbIsosDlg->setV( VIso ); if ( NbIsosDlg->exec() ) { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; newNbUIso = NbIsosDlg->getU(); newNbVIso = NbIsosDlg->getV(); } else //Cancel case @@ -450,20 +464,20 @@ void GEOMToolsGUI::OnDeflection() aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Deflection ), QVariant() ); - double aDC = v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coef", 0.001 ); + double aDC = v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coeff", 0.001 ); GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg ( SUIT_Session::session()->activeApplication()->desktop() ); DeflectionDlg->setTheDC( aDC ); if ( DeflectionDlg->exec() ) { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; aDC = DeflectionDlg->getTheDC(); for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { @@ -480,8 +494,7 @@ void GEOMToolsGUI::OnSelectOnly(int mode) { SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( app ) { - SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); - GEOM_Displayer aDisp (appStudy); + GEOM_Displayer aDisp; aDisp.GlobalSelection(mode); getGeometryGUI()->setLocalSelectionMode(mode); } @@ -514,6 +527,8 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show ) return; } + SUIT_OverrideCursor wc; + bool toUpdateColorScale = disp->SetUpdateColorScale( false ); // IPAL54049 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -522,10 +537,12 @@ void GEOMToolsGUI::OnDiscloseConcealChildren( bool show ) if ( obj ) { _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" ); aExp->SetExpandable( show ); - if(!show) + if ( !show ) { disp->EraseWithChildren(IObject,true); + } } // if ( obj ) } // iterator + disp->SetUpdateColorScale( toUpdateColorScale ); } } app->updateObjectBrowser( false ); @@ -577,7 +594,8 @@ void GEOMToolsGUI::OnUnpublishObject() { QObject::tr( "WRN_STUDY_LOCKED" ) ); return; } - + SUIT_OverrideCursor wc; + bool toUpdateColorScale = disp->SetUpdateColorScale( false ); // IPAL54049 for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); @@ -587,15 +605,22 @@ void GEOMToolsGUI::OnUnpublishObject() { _PTR(AttributeDrawable) aDrw = B->FindOrCreateAttribute( obj, "AttributeDrawable" ); aDrw->SetDrawable( false ); disp->EraseWithChildren(IObject); + // hide references if any + std::vector< _PTR(SObject) > vso = aStudy->FindDependances(obj); + for ( int i = 0; i < (int)vso.size(); i++ ) { + _PTR(SObject) refObj = vso[i]; + aDrw = B->FindOrCreateAttribute( refObj, "AttributeDrawable" ); + aDrw->SetDrawable( false ); + } } // if ( obj ) } // iterator + disp->SetUpdateColorScale( toUpdateColorScale ); // IPAL54049 aSelMgr->clearSelected(); } } app->updateObjectBrowser( false ); app->updateActions(); } - } void GEOMToolsGUI::OnPublishObject() { @@ -642,7 +667,7 @@ void GEOMToolsGUI::OnEdgeWidth() aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -657,7 +682,7 @@ void GEOMToolsGUI::OnEdgeWidth() Dlg->setTheLW( aWidth ); if ( Dlg->exec() ) { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; aWidth = Dlg->getTheLW(); } else return; //Cancel case @@ -685,7 +710,7 @@ void GEOMToolsGUI::OnIsosWidth() { aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -700,7 +725,7 @@ void GEOMToolsGUI::OnIsosWidth() { Dlg->setTheLW( aWidth ); if ( Dlg->exec() ) { - SUIT_OverrideCursor(); + SUIT_OverrideCursor wc; aWidth = Dlg->getTheLW(); } else return; //Cancel case @@ -727,7 +752,7 @@ void GEOMToolsGUI::OnBringToFront() { aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -753,7 +778,7 @@ void GEOMToolsGUI::OnClsBringToFront() { SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); if ( !appStudy ) return; - GEOM_Displayer displayer( appStudy ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -792,7 +817,7 @@ void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) if ( selected.IsEmpty() ) return; - GEOM_Displayer displayer( study ); + GEOM_Displayer displayer; SALOME_View* window = displayer.GetActiveView(); if ( !window ) return; @@ -833,8 +858,8 @@ void GEOMToolsGUI::OnCreateFolder() _PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry())); if ( !aFatherSO ) return; - GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toLatin1().constData(), - _CAST(SObject, aFatherSO)->GetSObject() ); + GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toUtf8().constData(), + _CAST(SObject, aFatherSO)->GetSObject() ); app->updateObjectBrowser( false ); } @@ -865,7 +890,62 @@ void GEOMToolsGUI::OnSortChildren() app->updateObjectBrowser( true ); } +#ifndef DISABLE_GRAPHICSVIEW void GEOMToolsGUI::OnShowDependencyTree() { - DependencyTree(); + //SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + +#ifdef LAYOUT_DEPVIEW + SUIT_ViewManager* occVm = app->getViewManager( OCCViewer_Viewer::Type(), true ); + SUIT_ViewWindow* occVw = occVm->getActiveView(); +#endif + SUIT_ViewManager* depVm = app->getViewManager( GraphicsView_Viewer::Type(), false ); + SUIT_ViewWindow* depVw = 0; + + if ( !depVm ) { + DependencyTree_View* view = new DependencyTree_View(); + DependencyTree_ViewModel* viewModel = new DependencyTree_ViewModel( GraphicsView_Viewer::Type(), view ); + depVm = app->createViewManager( viewModel ); + + LightApp_SelectionMgr* selMgr = app->selectionMgr(); + new DependencyTree_Selector( viewModel, (SUIT_SelectionMgr*)selMgr ); + + depVw = depVm->getActiveView(); + GraphicsView_ViewFrame* aViewFrame = 0; + if ( !depVw ) depVw = depVm->createViewWindow(); + if ( depVw ) aViewFrame = dynamic_cast( depVw ); + + view->init( aViewFrame ); + depVm->setTitle( view->getViewName() ); + } + else if ( DependencyTree_ViewModel* viewModel = dynamic_cast( depVm->getViewModel() ) ) { + if ( DependencyTree_View* view = dynamic_cast( viewModel->getActiveViewPort() ) ) { + depVw = depVm->getActiveView(); + view->updateModel(); + } + } + +#ifdef LAYOUT_DEPVIEW + // layout views properly + STD_TabDesktop* d = dynamic_cast( app->desktop() ); + if ( d && depVw && occVw ) { + QtxWorkstack* ws = d->workstack(); + ws->stack(); + QApplication::instance()->processEvents(); + ws->Split( depVw, Qt::Horizontal, QtxWorkstack::SplitMove ); + occVw->setFocus(); + } +#endif + depVw->setFocus(); +} +#endif + +void GEOMToolsGUI::OnReduceStudy() +{ + QDialog* dlg = new GEOMToolsGUI_ReduceStudyDlg( SUIT_Session::session()->activeApplication()->desktop() ); + if( dlg != NULL ) + dlg->show(); }