-// 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
// File : GEOMToolsGUI_1.cxx
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
+#ifndef DISABLE_PYCONSOLE
#include <PyConsole_Console.h>
+#endif
#include "GEOMToolsGUI.h"
#include "GEOMToolsGUI_TransparencyDlg.h"
#include "GEOMToolsGUI_PublishDlg.h"
#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
#include "GEOMToolsGUI_LineWidthDlg.h"
+#include "GEOMToolsGUI_ReduceStudyDlg.h"
#include <Material_Model.h>
#include <GEOM_VTKPropertyMaterial.hxx>
#include <GEOMBase.h>
#include <GEOM_Actor.h>
-#include <Basics_OCCTVersion.hxx>
+#ifndef DISABLE_GRAPHICSVIEW
+#include <DependencyTree_ViewModel.h>
+#include <DependencyTree_View.h>
+#include <DependencyTree_Selector.h>
+#endif
#include <SALOME_ListIO.hxx>
-#include <SALOME_ListIteratorOfListIO.hxx>
#include <SALOMEDS_SObject.hxx>
#include <SUIT_MessageBox.h>
#include <SUIT_Tools.h>
+#include <STD_TabDesktop.h>
+
+#include <QtxWorkstack.h>
+
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Module.h>
#include "utilities.h"
// OCCT Includes
-#include <AIS_Drawer.hxx>
#include <Prs3d_IsoAspect.hxx>
#include <Prs3d_PointAspect.hxx>
#include <Graphic3d_AspectMarker3d.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <AIS_ListOfInteractive.hxx>
-
-#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1
#include <TColStd_HArray1OfByte.hxx>
-#else
-#include <Graphic3d_HArray1OfBytes.hxx>
-#endif
// QT Includes
#include <QAction>
+#include <QApplication>
#include <QColorDialog>
#include <QInputDialog>
#include <QFileDialog>
// VTK includes
#include <vtkRenderer.h>
-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 =
if (pyConsole)
pyConsole->exec("from GEOM_usinggeom import *");
}
+#endif
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<SALOMEDS::Color> aReservedColors;
- GEOM_Displayer displayer ( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
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 );
}
_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 );
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
// get active view
SALOME_View* window = displayer.GetActiveView();
color = QColorDialog::getColor( v.value<QColor>(), 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 );
}
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
NbIsosDlg->setV( VIso );
if ( NbIsosDlg->exec() ) {
- SUIT_OverrideCursor();
+ SUIT_OverrideCursor wc;
newNbUIso = NbIsosDlg->getU();
newNbVIso = NbIsosDlg->getV();
} else //Cancel case
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() ) {
{
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( app ) {
- SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
- GEOM_Displayer aDisp (appStudy);
+ GEOM_Displayer aDisp;
aDisp.GlobalSelection(mode);
getGeometryGUI()->setLocalSelectionMode(mode);
}
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();
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 );
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();
_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() {
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
Dlg->setTheLW( aWidth );
if ( Dlg->exec() ) {
- SUIT_OverrideCursor();
+ SUIT_OverrideCursor wc;
aWidth = Dlg->getTheLW();
} else
return; //Cancel case
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
Dlg->setTheLW( aWidth );
if ( Dlg->exec() ) {
- SUIT_OverrideCursor();
+ SUIT_OverrideCursor wc;
aWidth = Dlg->getTheLW();
} else
return; //Cancel case
aSelMgr->selectedObjects( selected );
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( appStudy );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
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;
if ( selected.IsEmpty() ) return;
- GEOM_Displayer displayer( study );
+ GEOM_Displayer displayer;
SALOME_View* window = displayer.GetActiveView();
if ( !window ) return;
_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 );
}
app->updateObjectBrowser( true );
}
+
+#ifndef DISABLE_GRAPHICSVIEW
+void GEOMToolsGUI::OnShowDependencyTree()
+{
+ //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<GraphicsView_ViewFrame*>( depVw );
+
+ view->init( aViewFrame );
+ depVm->setTitle( view->getViewName() );
+ }
+ else if ( DependencyTree_ViewModel* viewModel = dynamic_cast<DependencyTree_ViewModel*>( depVm->getViewModel() ) ) {
+ if ( DependencyTree_View* view = dynamic_cast<DependencyTree_View*>( viewModel->getActiveViewPort() ) ) {
+ depVw = depVm->getActiveView();
+ view->updateModel();
+ }
+ }
+
+#ifdef LAYOUT_DEPVIEW
+ // layout views properly
+ STD_TabDesktop* d = dynamic_cast<STD_TabDesktop*>( 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();
+}