X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI_1.cxx;h=95086a66061934e0aaaea24cd3d06b28b0c00e09;hb=b6f0965afb72083a5234f9b4fb0b233adaaf8d9d;hp=07f21b9755781a02843ce22602de8a8ce871bcd8;hpb=46b338c04592e735f8da37ac2095105fea715eb1;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 07f21b975..95086a660 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -1,413 +1,951 @@ -// GEOM GEOMGUI : GUI for Geometry component +// 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 +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. // -// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org or email : webmaster.salome@opencascade.org +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. // -// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// GEOM GEOMGUI : GUI for Geometry component // File : GEOMToolsGUI_1.cxx -// Author : Sergey ANIKIN -// Module : GEOM -// $Header$ +// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -#include +#ifndef DISABLE_PYCONSOLE +#include +#endif #include "GEOMToolsGUI.h" -#include "GeometryGUI.h" -#include "GEOM_Actor.h" -#include "GEOMBase.h" #include "GEOMToolsGUI_TransparencyDlg.h" -#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement -#include "GEOMToolsGUI_NameDlg.h" +#include "GEOMToolsGUI_NbIsosDlg.h" +#include "GEOMToolsGUI_DeflectionDlg.h" +#include "GEOMToolsGUI_MarkerDlg.h" +#include "GEOMToolsGUI_PublishDlg.h" +#include "GEOMToolsGUI_MaterialPropertiesDlg.h" +#include "GEOMToolsGUI_LineWidthDlg.h" +#include "GEOMToolsGUI_ReduceStudyDlg.h" +#include + +#include + +#include +#include +#include +#include + +#include +#include + +#ifndef DISABLE_GRAPHICSVIEW +#include +#include +#include +#endif #include -#include -#include -#include -#include +#include +#include + +#include +#include #include -#include +#include + +#include #include -#include #include #include #include #include #include +#include + +#include + +#include #include -#include #include #include -#include -#include -#include +#include +#include + +#include + +#include "utilities.h" + +// OCCT Includes #include +#include +#include +#include +#include +#include + +#include + +// QT Includes +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +// VTK includes #include -#include -#include -#include -#include +// 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 = + dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication()); + PyConsole_Console* pyConsole = app->pythonConsole(); -#include "utilities.h" + if (pyConsole) + pyConsole->exec("from GEOM_usinggeom import *"); +} +#endif + +void GEOMToolsGUI::OnAutoColor() +{ + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; -using namespace std; + SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !appStudy ) return; -#include "SALOMEDSClient.hxx" -#include "SALOMEDS_Study.hxx" + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + Handle(SALOME_InteractiveObject) anIObject = selected.First(); -void GEOMToolsGUI::OnSettingsColor() -{ - SUIT_Session* sess = SUIT_Session::session(); - SUIT_ResourceMgr* resMgr = sess->resourceMgr(); - SUIT_Desktop* desk = sess->activeApplication()->desktop(); + _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) || !GeometryGUI::IsInGeomComponent( aMainSObject )) return; - QColor anInitColor = resMgr->colorValue( "Geometry:SettingsShadingColor", QColor( "yellow" ) ); - - QColor aDialogColor = QColorDialog::getColor(anInitColor, desk ); - if( aDialogColor.isValid() ) + aMainObject->SetAutoColor( true ); + + QList aReservedColors; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); it->More(); it->Next() ) { - QString type = desk->activeWindow()->getViewManager()->getType(); - if( type != OCCViewer_Viewer::Type() && type != VTKViewer_Viewer::Type() ) - MESSAGE("Settings Color is not supported for current Viewer"); + _PTR(SObject) aChildSObject( it->Value() ); + GEOM::GEOM_Object_var aChildObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aChildSObject)); + if( CORBA::is_nil( aChildObject ) ) + continue; + +#ifndef GENERAL_AUTOCOLOR // auto-color for groups only + if( aChildObject->GetType() != GEOM_GROUP ) + continue; +#endif // GENERAL_AUTOCOLOR + +#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors + SALOMEDS::Color aColor = GEOM_Displayer::getPredefinedUniqueColor(); +#else // old algorithm for auto-colors + SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors ); + aReservedColors.append( aColor ); +#endif // SIMPLE_AUTOCOLOR + aChildObject->SetColor( aColor ); + + QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) ); + + SUIT_OverrideCursor wc; - resMgr->setValue( "Geometry:SettingsShadingColor", aDialogColor ); + 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 ); } + displayer.UpdateViewer(); + + // update actions + appStudy->Modified(); + app->updateActions(); //SRN: To update a Save button in the toolbar } -void GEOMToolsGUI::OnSettingsIsos() +void GEOMToolsGUI::OnDisableAutoColor() { -/* - SUIT_Session* sess = SUIT_Session::session(); - SUIT_ResourceMgr* resMgr = sess->resourceMgr(); - SUIT_Desktop* desk = sess->activeApplication()->desktop(); + SALOME_ListIO selected; + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if( !app ) + return; - SUIT_ViewManager* vman = desk->activeWindow()->getViewManager(); - QString type = vman->getType(); + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if( !aSelMgr || !appStudy ) + return; - if ( type != OCCViewer_Viewer::Type() ) + aSelMgr->selectedObjects( selected ); + if( selected.IsEmpty() ) return; - - OCCViewer_Viewer* vm = (OCCViewer_Viewer*)vman->getViewModel(); - Handle (AIS_InteractiveContext) ic = vm->getAISContext(); - - int IsoU = resMgr->integerValue( "Geometry:SettingsIsoU", 1 ); - int IsoV = resMgr->integerValue( "Geometry:SettingsIsoV", 1 ); - - ic->DefaultDrawer()->UIsoAspect()->SetNumber( IsoU ); - ic->DefaultDrawer()->VIsoAspect()->SetNumber( IsoV ); - - GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(desk, tr("GEOM_MEN_ISOS"), TRUE); - - NbIsosDlg->SpinBoxU->setValue(IsoU); - NbIsosDlg->SpinBoxV->setValue(IsoV); - - if(NbIsosDlg->exec()) { - IsoU = NbIsosDlg->SpinBoxU->text().toInt(); - IsoV = NbIsosDlg->SpinBoxV->text().toInt(); - - ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso); - ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso); - resMgr->setValue("Geometry:SettingsIsoU", isoU); - resMgr->setValue("Geometry:SettingsIsoV", isoV); + + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + + _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 ) || !GeometryGUI::IsInGeomComponent( aMainSObject )) + return; + + aMainObject->SetAutoColor( false ); +} + +void GEOMToolsGUI::OnColor() +{ + // get active application + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + // get current study + SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !appStudy ) return; + + // get selection manager + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + // get selection + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + + // get active view + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + // get view id + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + QColor color; + QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color ); + + // show Choose Color dialog box + 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 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 ); } -*/ + displayer.UpdateViewer(); + GeometryGUI::Modified(); + + // update actions + app->updateActions(); //SRN: To update a Save button in the toolbar } -void GEOMToolsGUI::OnSettingsStep() +void GEOMToolsGUI::OnTexture() { - SUIT_Session* sess = SUIT_Session::session(); - SUIT_ResourceMgr* resMgr = sess->resourceMgr(); + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; - double step = resMgr->doubleValue( "Geometry:SettingsGeomStep", 100. ); - - Standard_Boolean res = false; - double dd = GEOMBase::Parameter(res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3); - if(res) { - resMgr->setValue( "Geometry:SettingsGeomStep", dd ); - - /* Emit signal to GeometryGUI_SpinBoxes */ - getGeometryGUI()->EmitSignalDefaultStepValueChanged( dd ); + SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() ); + if ( !appStudy ) return; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + QString aTexture = QFileDialog::getOpenFileName( dynamic_cast< SUIT_ViewWindow* >( window ),tr("GEOM_SELECT_IMAGE"),QString(), tr("OCC_TEXTURE_FILES")); + if( !aTexture.isEmpty() ) { + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Texture ), aTexture ); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), 3 ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); + + // update actions + app->updateActions(); //SRN: To update a Save button in the toolbar +} + +void GEOMToolsGUI::OnTransparency() +{ + GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() ); + dlg.exec(); +} + +void GEOMToolsGUI::OnChangeTransparency( bool increase ) +{ + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + // Delta + float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored) + if ( !increase ) + delta *= -1; + + QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Transparency ), QVariant() ); + float transp = v.isValid() ? v.toFloat() : 1; + + // Compute new transparency value + transp = transp + delta; + if ( transp < 0 ) + transp = 0; + else if ( transp > 1 ) + transp = 1; + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId ,io->getEntry(), GEOM::propertyName( GEOM::Transparency ), transp ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +void GEOMToolsGUI::OnNbIsos( ActionType actionType ) +{ + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + 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::NbIsos ) , QVariant() ); + QString aStr = v.toString(); + QStringList aStrList = aStr.split( GEOM::subSectionSeparator() ); + int UIso = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "iso_number_u", 1 ); + int VIso = SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "iso_number_v", 1 ); + if ( aStrList.count() == 2 ) { + if ( !aStrList[0].isEmpty() ) UIso = aStrList[0].toInt(); + if ( !aStrList[1].isEmpty() ) VIso = aStrList[1].toInt(); + } + + int newNbUIso = -1; + int newNbVIso = -1; + + if ( actionType == SHOWDLG ) { + GEOMToolsGUI_NbIsosDlg * NbIsosDlg = + new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); + + NbIsosDlg->setU( UIso ); + NbIsosDlg->setV( VIso ); + + if ( NbIsosDlg->exec() ) { + SUIT_OverrideCursor wc; + newNbUIso = NbIsosDlg->getU(); + newNbVIso = NbIsosDlg->getV(); + } else //Cancel case + return; + } + else if ( actionType == INCR || actionType == DECR ) { + int delta = 1; + if (actionType == DECR) + delta = -1; + + newNbUIso = UIso + delta; + newNbVIso = VIso + delta; + + if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 ) + return; } - else - sess->activeApplication()->putInfo(tr("GEOM_PRP_ABORT")); + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + QString anIsos = QString( "%1%2%3" ).arg( newNbUIso ).arg( GEOM::subSectionSeparator() ).arg( newNbVIso ); + appStudy->setObjectProperty( aMgrId ,io->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); } -void GEOMToolsGUI::OnRename() +void GEOMToolsGUI::OnDeflection() { + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + 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_coeff", 0.001 ); + + GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg + ( SUIT_Session::session()->activeApplication()->desktop() ); + DeflectionDlg->setTheDC( aDC ); + if ( DeflectionDlg->exec() ) { + SUIT_OverrideCursor wc; + aDC = DeflectionDlg->getTheDC(); + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Deflection ), aDC ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +void GEOMToolsGUI::OnSelectOnly(int mode) +{ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( app ) { - SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr(); + GEOM_Displayer aDisp; + aDisp.GlobalSelection(mode); + getGeometryGUI()->setLocalSelectionMode(mode); + } +} + +void GEOMToolsGUI::OnDiscloseConcealChildren( bool show ) +{ + SALOME_ListIO selected; + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + + SalomeApp_Module* mod = app ? dynamic_cast(app->activeModule()) : 0; + + GEOM_Displayer* disp = mod ? dynamic_cast(mod->displayer()) : 0; + + if ( app && disp ) { + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); if ( aSelMgr && appStudy ) { aSelMgr->selectedObjects( selected ); if ( !selected.IsEmpty() ) { - _PTR(Study) aStudy = appStudy->studyDS(); - - bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked(); - if ( aLocked ) { - SUIT_MessageBox::warn1 ( app->desktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); - return; - } - - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) ); - _PTR(GenericAttribute) anAttr; - if ( obj ) { - if( obj->FindAttribute(anAttr, "AttributeName") ) { - _PTR(AttributeName) aName (anAttr); - - QString newName = GEOMToolsGUI_NameDlg::getName( app->desktop(), aName->Value().c_str() ); - if ( !newName.isEmpty() ) { - aName->SetValue( newName.latin1() ); // rename the SObject - IObject->setName( newName.latin1() );// rename the InteractiveObject - (dynamic_cast(app->activeModule()))->updateObjBrowser( false ); - } - } // if ( name attribute ) - } // if ( obj ) - } // iterator + _PTR(Study) aStudy = appStudy->studyDS(); + _PTR(StudyBuilder) B = aStudy->NewBuilder(); + + bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning( app->desktop(), + QObject::tr( "WRN_WARNING" ), + 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(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) ); + _PTR(GenericAttribute) anAttr; + if ( obj ) { + _PTR(AttributeExpandable) aExp = B->FindOrCreateAttribute( obj, "AttributeExpandable" ); + aExp->SetExpandable( show ); + if ( !show ) { + disp->EraseWithChildren(IObject,true); + } + } // if ( obj ) + } // iterator + disp->SetUpdateColorScale( toUpdateColorScale ); } } + app->updateObjectBrowser( false ); + app->updateActions(); } } -void GEOMToolsGUI::OnCheckGeometry() +void GEOMToolsGUI::OnPointMarker() { - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - PythonConsole* pyConsole = app->pythonConsole(); - - if(pyConsole) - pyConsole->exec("from GEOM_usinggeom import *"); + GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() ); + dlg.exec(); } -void GEOMToolsGUI::OnColor() +void GEOMToolsGUI::OnMaterialProperties() +{ + GEOMToolsGUI_MaterialPropertiesDlg* dlg = new GEOMToolsGUI_MaterialPropertiesDlg( SUIT_Session::session()->activeApplication()->desktop(), true, false, QtxDialog::OK | QtxDialog::Close | QtxDialog::Apply | QtxDialog::Help ); + dlg->show(); +} + +void GEOMToolsGUI::OnMaterialsLibrary() { + GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop(), false, true, QtxDialog::Standard ); + dlg.setWindowTitle( tr( "MATERIAL_LIBRARY_TLT" ) ); + dlg.exec(); +} + +void GEOMToolsGUI::OnUnpublishObject() { SALOME_ListIO selected; - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); - if ( app ) { - SalomeApp_SelectionMgr* aSelMgr = app->selectionMgr(); - if ( aSelMgr ) { + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + + SalomeApp_Module* mod = app ? dynamic_cast(app->activeModule()) : 0; + + GEOM_Displayer* disp = mod ? dynamic_cast(mod->displayer()) : 0; + + if ( app && disp ) { + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if ( aSelMgr && appStudy ) { 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() == VTKViewer_Viewer::Type() ); - if ( isVTK ) { - SVTK_ViewWindow* vtkVW = dynamic_cast( window ); - if ( !vtkVW ) - return; - SVTK_RenderWindowInteractor* rwi = vtkVW->getRWInteractor(); - QColor initcolor = rwi->GetColor( selected.First() ); - QColor c = QColorDialog::getColor( QColor(), app->desktop() ); - if ( c.isValid() ) { - SUIT_OverrideCursor(); - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - rwi->SetColor( It.Value(), c ); - } - } - } // if ( isVTK ) - else if ( isOCC ) { - Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() ); - if ( !io.IsNull() ) { - Quantity_Color aColor; - io->Color( aColor ); - QColor initcolor( (int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 ) ); - QColor c = QColorDialog::getColor( initcolor, app->desktop() ); - if ( c.isValid() ) { - SUIT_OverrideCursor(); - aColor = Quantity_Color( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB ); - for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { - io = GEOMBase::GetAIS( It.Value(), true ); - if ( !io.IsNull() ) { - io->SetColor( aColor ); - if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) - Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor ); - - io->Redisplay( Standard_True ); - } - } - } // if c.isValid() - } // first IO is not null - } // if ( isOCC ) - } // if ( selection not empty ) + _PTR(Study) aStudy = appStudy->studyDS(); + _PTR(StudyBuilder) B = aStudy->NewBuilder(); + + bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning( app->desktop(), + QObject::tr( "WRN_WARNING" ), + 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(SObject) obj ( aStudy->FindObjectID( IObject->getEntry() ) ); + _PTR(GenericAttribute) anAttr; + if ( obj ) { + _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::OnTransparency() +void GEOMToolsGUI::OnPublishObject() { + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if(!app) + return; + + SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); + if(!appStudy) + return; + + _PTR(Study) aStudy = appStudy->studyDS(); + + if(!aStudy) + return; + + //Check lock of the study + bool aLocked = ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() ) )->IsLocked(); + if ( aLocked ) { + SUIT_MessageBox::warning( app->desktop(), + QObject::tr( "WRN_WARNING" ), + QObject::tr( "WRN_STUDY_LOCKED" ) ); + return; + } + + GEOMToolsGUI_PublishDlg* publishDlg = + new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() ); + publishDlg->show(); +} + + +void GEOMToolsGUI::OnEdgeWidth() { - GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() ); - dlg.exec(); + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + GEOMToolsGUI_LineWidthDlg* Dlg = + new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "EDGE_WIDTH_TLT" ); + + QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), QVariant() ); + int aWidth = v.isValid() ? v.toInt() : SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "edge_width", 1 ); + + Dlg->setTheLW( aWidth ); + if ( Dlg->exec() ) { + SUIT_OverrideCursor wc; + aWidth = Dlg->getTheLW(); + } else + return; //Cancel case + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aWidth ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + + +void GEOMToolsGUI::OnIsosWidth() { + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + GEOMToolsGUI_LineWidthDlg* Dlg = + new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" ); + + QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), QVariant() ); + int aWidth = v.isValid() ? v.toInt() : SUIT_Session::session()->resourceMgr()->integerValue( "Geometry", "isolines_width", 1 ); + + Dlg->setTheLW( aWidth ); + if ( Dlg->exec() ) { + SUIT_OverrideCursor wc; + aWidth = Dlg->getTheLW(); + } else + return; //Cancel case + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +void GEOMToolsGUI::OnBringToFront() { + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + QAction* a = getGeometryGUI()->getAction( GEOMOp::OpBringToFront ); + bool checked = a->isChecked(); + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::TopLevel ), checked ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.UpdateViewer(); + GeometryGUI::Modified(); } -void GEOMToolsGUI::OnNbIsos() +void GEOMToolsGUI::OnClsBringToFront() { + 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; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId(); + + SALOME_ListIO anIOlst; + window->GetVisible( anIOlst ); + + for ( SALOME_ListIteratorOfListIO It( anIOlst ); It.More(); It.Next() ) { + Handle( SALOME_InteractiveObject ) io = It.Value(); + appStudy->setObjectProperty( aMgrId, QString( io->getEntry() ), GEOM::propertyName( GEOM::TopLevel ), Standard_False ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); + } + displayer.Redisplay( anIOlst ); + displayer.UpdateViewer(); + GeometryGUI::Modified(); +} + +void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam ) { - SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); + if ( !theParam.canConvert() ) return; + + QString theName = theParam.toString(); - if ( !isOCC ) - return; + SalomeApp_Application* app = dynamic_cast( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; - OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); - Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + SalomeApp_Study* study = dynamic_cast( app->activeStudy() ); + if ( !study ) return; - ic->InitCurrent(); - if ( ic->MoreCurrent() ) { - Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - - int UIso = CurDrawer->UIsoAspect()->Number(); - int VIso = CurDrawer->VIsoAspect()->Number(); - - GEOMToolsGUI_NbIsosDlg * NbIsosDlg = - new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); - - NbIsosDlg->setU( UIso ); - NbIsosDlg->setV( VIso ); - - if ( NbIsosDlg->exec() ) { - SUIT_OverrideCursor(); - for(; ic->MoreCurrent(); ic->NextCurrent()) { - CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); - Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - - int nbUIso = NbIsosDlg->getU(); - int nbVIso = NbIsosDlg->getV(); - - CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) ); - CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) ); - - ic->SetLocalAttributes(CurObject, CurDrawer); - ic->Redisplay(CurObject); - } - } + LightApp_SelectionMgr* selMgr = app->selectionMgr(); + + SALOME_ListIO selected; + selMgr->selectedObjects( selected ); + + if ( selected.IsEmpty() ) return; + + GEOM_Displayer displayer; + + SALOME_View* window = displayer.GetActiveView(); + if ( !window ) return; + + int mgrId = dynamic_cast( window )->getViewManager()->getGlobalId(); + + Material_Model aModel; + aModel.fromResources( theName ); + QString prop = aModel.toProperties(); + + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject) io = It.Value(); + study->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Material ), prop ); + if ( window->isVisible( io ) ) displayer.Redisplay( io, false ); } + displayer.UpdateViewer(); } -void GEOMToolsGUI::OnOpen() +void GEOMToolsGUI::OnCreateFolder() { -/* - SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); - _PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) anIObject; - for(;It.More();It.Next()) { - anIObject = It.Value(); - _PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) ); - _PTR(AttributePersistentRef) aPersist; - _PTR(AttributeIOR) anIOR; - if(obj) { - // this SObject may be GEOM module root SObject - _PTR(ChildIterator) anIter ( aStudy->NewChildIterator() ); - _PTR(GenericAttribute) anAttr; - bool useSubItems = false; - while (anIter->More() && !useSubItems) { - _PTR(SObject) subobj ( anIter->Value() ); - if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) { - useSubItems = true; - obj = subobj; - } - else - anIter->Next(); - } - obj->FindAttribute(anAttr, "AttributePersistentRef"); - - while(useSubItems?anIter->More():!anAttr->_is_nil()) { - if(!obj->FindAttribute(anAttr, "AttributeIOR") && - obj->FindAttribute(anAttr, "AttributePersistentRef")) { - _PTR(SComponent) FComp ( obj->GetFatherComponent() ); - if (FComp) { - if (FComp->FindAttribute(anAttr, "AttributeName")) { - _PTR(AttributeName) aName ( anAttr ); - QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str()); - // parent->loadComponentData(parent->getComponentName(aName->Value())); - Engines::Component_var comp ; - if ( compName.compare("SUPERV") == 0 ) { - comp = QAD_Application::getDesktop()->getEngine( "SuperVisionContainer", compName) ; - } - else { - comp = QAD_Application::getDesktop()->getEngine( "FactoryServer", compName); - if ( comp->_is_nil() ) - comp = QAD_Application::getDesktop()->getEngine( "FactoryServerPy", compName); - } - - if (!CORBA::is_nil(comp)) { - SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); - if (!CORBA::is_nil(driver)) { - SALOMEDS::StudyBuilder_var B = dynamic_cast(aStudy.get())->GetStudy()->NewBuilder(); - if (!CORBA::is_nil(B)) { - B->LoadWith(FComp,driver); - } else { - return; - } - } - else { - MESSAGE("loadComponentData(): Driver is null"); - return; - } - } - else { - MESSAGE("loadComponentData(): Engine is null"); - return; - } - // // load - // Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer","GEOM"); - // if (!CORBA::is_nil(comp)) { - // SALOMEDS::Driver_var driver = SALOMEDS::Driver::_narrow(comp); - // SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - // SALOMEDS::SComponent_var SC = aStudy->FindComponent("GEOM"); - // if (!CORBA::is_nil(SC)) - // aStudyBuilder->LoadWith(SC,driver); - } - } - else { - MESSAGE("Component is null"); - } - } - if(useSubItems) { - anIter->Next(); - obj.reset( anIter->Value() ); - } - else - anAttr = NULL; - } + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + + _PTR(Study) aStudy = appStudy->studyDS(); + if( !aStudy ) return; + _PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry())); + if ( !aFatherSO ) return; + + GeometryGUI::GetGeomGen()->CreateFolder( tr("NEW_FOLDER_NAME").toUtf8().constData(), + _CAST(SObject, aFatherSO)->GetSObject() ); + app->updateObjectBrowser( false ); +} + +void GEOMToolsGUI::OnSortChildren() +{ + 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_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects( selected ); + if ( selected.IsEmpty() ) return; + + Handle(SALOME_InteractiveObject) anIObject = selected.First(); + + _PTR(Study) aStudy = appStudy->studyDS(); + if( !aStudy ) return; + _PTR(SObject) aFatherSO(aStudy->FindObjectID(anIObject->getEntry())); + if ( !aFatherSO ) return; + + aStudy->GetUseCaseBuilder()->SortChildren( aFatherSO, true/*AscendingOrder*/ ); + + 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( 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(); }