2013-04-01 18:25:01 +06:00
|
|
|
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
|
|
|
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
|
2005-08-18 12:15:31 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-08-18 12:15:31 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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.
|
2005-08-18 12:15:31 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// 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
|
2005-08-18 12:15:31 +06:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
// File : GEOMToolsGUI_1.cxx
|
|
|
|
// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com)
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <PyConsole_Console.h>
|
2005-06-09 15:10:51 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GEOMToolsGUI.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "GEOMToolsGUI_TransparencyDlg.h"
|
2009-02-13 17:16:39 +05:00
|
|
|
#include "GEOMToolsGUI_NbIsosDlg.h"
|
2012-08-09 13:58:02 +06:00
|
|
|
#include "GEOMToolsGUI_DeflectionDlg.h"
|
|
|
|
#include "GEOMToolsGUI_MarkerDlg.h"
|
|
|
|
#include "GEOMToolsGUI_PublishDlg.h"
|
|
|
|
#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
|
|
|
|
#include "GEOMToolsGUI_LineWidthDlg.h"
|
2013-02-12 17:35:16 +06:00
|
|
|
#include <Material_Model.h>
|
|
|
|
|
|
|
|
#include <GEOM_VTKPropertyMaterial.hxx>
|
2009-02-13 17:16:39 +05:00
|
|
|
|
|
|
|
#include <GeometryGUI.h>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <GeometryGUI_Operations.h>
|
|
|
|
#include <GEOM_Constants.h>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <GEOM_Displayer.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <GEOMBase.h>
|
|
|
|
#include <GEOM_Actor.h>
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <Basics_OCCTVersion.hxx>
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <SALOME_ListIO.hxx>
|
|
|
|
#include <SALOME_ListIteratorOfListIO.hxx>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2013-06-28 14:18:20 +06:00
|
|
|
#include <SALOMEDS_SObject.hxx>
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <SOCC_Prs.h>
|
|
|
|
|
|
|
|
#include <SVTK_Prs.h>
|
2005-10-05 12:28:23 +06:00
|
|
|
#include <SVTK_ViewModel.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SVTK_ViewWindow.h>
|
2006-02-07 20:58:35 +05:00
|
|
|
#include <SVTK_View.h>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-10-05 12:28:23 +06:00
|
|
|
#include <OCCViewer_ViewModel.h>
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SUIT_Desktop.h>
|
|
|
|
#include <SUIT_ResourceMgr.h>
|
|
|
|
#include <SUIT_Session.h>
|
|
|
|
#include <SUIT_OverrideCursor.h>
|
2005-06-03 16:42:52 +06:00
|
|
|
#include <SUIT_MessageBox.h>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <SUIT_Tools.h>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SalomeApp_Application.h>
|
2005-06-03 16:42:52 +06:00
|
|
|
#include <SalomeApp_Study.h>
|
|
|
|
#include <SalomeApp_Module.h>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2006-03-13 20:11:51 +05:00
|
|
|
#include <LightApp_SelectionMgr.h>
|
|
|
|
#include <LightApp_NameDlg.h>
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <GEOMImpl_Types.hxx>
|
|
|
|
|
2005-08-18 12:15:31 +06:00
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
// OCCT Includes
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <AIS_Drawer.hxx>
|
|
|
|
#include <Prs3d_IsoAspect.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <Prs3d_PointAspect.hxx>
|
|
|
|
#include <Graphic3d_AspectMarker3d.hxx>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <Graphic3d_AspectLine3d.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
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-18 12:15:31 +06:00
|
|
|
// QT Includes
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <QAction>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <QColorDialog>
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QFileDialog>
|
2009-02-13 17:16:39 +05:00
|
|
|
#include <QList>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QGroupBox>
|
|
|
|
#include <QSpinBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QKeyEvent>
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
// VTK includes
|
|
|
|
#include <vtkRenderer.h>
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
class QtxDialog;
|
2012-10-08 17:16:36 +06:00
|
|
|
// If the next macro is defined, autocolor feature works for all sub-shapes;
|
|
|
|
// if it is undefined, autocolor feature works for groups only
|
2012-12-13 14:40:36 +06:00
|
|
|
#define GENERAL_AUTOCOLOR
|
2012-10-08 17:16:36 +06:00
|
|
|
// Below macro, when uncommented, switches on simplified (more performant) algorithm
|
|
|
|
// of auto-color picking up
|
2012-12-13 14:40:36 +06:00
|
|
|
#define SIMPLE_AUTOCOLOR
|
2012-10-08 17:16:36 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
void GEOMToolsGUI::OnCheckGeometry()
|
|
|
|
{
|
2012-08-09 13:58:02 +06:00
|
|
|
SalomeApp_Application* app =
|
|
|
|
dynamic_cast< SalomeApp_Application* >(SUIT_Session::session()->activeApplication());
|
2009-02-13 17:16:39 +05:00
|
|
|
PyConsole_Console* pyConsole = app->pythonConsole();
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
if (pyConsole)
|
2005-06-09 15:10:51 +06:00
|
|
|
pyConsole->exec("from GEOM_usinggeom import *");
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
void GEOMToolsGUI::OnAutoColor()
|
|
|
|
{
|
2013-02-28 20:00:05 +06:00
|
|
|
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;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( !aSelMgr ) return;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) anIObject = selected.First();
|
|
|
|
|
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
2012-08-09 13:58:02 +06:00
|
|
|
_PTR(SObject) aMainSObject(aStudy->FindObjectID(anIObject->getEntry()));
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOM::GEOM_Object_var aMainObject = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aMainSObject));
|
2013-02-28 20:00:05 +06:00
|
|
|
if (CORBA::is_nil(aMainObject)) return;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
aMainObject->SetAutoColor( true );
|
|
|
|
|
2009-02-13 17:16:39 +05:00
|
|
|
QList<SALOMEDS::Color> aReservedColors;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer ( appStudy );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
for( _PTR(ChildIterator) it( aStudy->NewChildIterator( aMainSObject ) ); 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;
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
#ifndef GENERAL_AUTOCOLOR // auto-color for groups only
|
2008-03-07 12:45:34 +05:00
|
|
|
if( aChildObject->GetType() != GEOM_GROUP )
|
|
|
|
continue;
|
2012-10-08 17:16:36 +06:00
|
|
|
#endif // GENERAL_AUTOCOLOR
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
#ifdef SIMPLE_AUTOCOLOR // simplified algorithm for auto-colors
|
|
|
|
SALOMEDS::Color aColor = GEOM_Displayer::getPredefinedUniqueColor();
|
|
|
|
#else // old algorithm for auto-colors
|
2008-03-07 12:45:34 +05:00
|
|
|
SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
|
|
|
|
aReservedColors.append( aColor );
|
2012-10-08 17:16:36 +06:00
|
|
|
#endif // SIMPLE_AUTOCOLOR
|
|
|
|
aChildObject->SetColor( aColor );
|
2013-02-28 20:00:05 +06:00
|
|
|
|
2008-03-07 12:45:34 +05:00
|
|
|
QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SUIT_OverrideCursor();
|
|
|
|
|
|
|
|
appStudy->setObjectProperty( aMgrId, aChildObject->GetEntry(), GEOM::propertyName( GEOM::Color ), c );
|
2013-04-12 20:01:18 +06:00
|
|
|
Handle( SALOME_InteractiveObject ) io = new SALOME_InteractiveObject( aChildObject->GetStudyEntry(), "GEOM", "" );
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
displayer.UpdateViewer();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// update actions
|
|
|
|
appStudy->Modified();
|
2008-03-07 12:45:34 +05:00
|
|
|
app->updateActions(); //SRN: To update a Save button in the toolbar
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnDisableAutoColor()
|
|
|
|
{
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if( !app )
|
|
|
|
return;
|
|
|
|
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if( !aSelMgr || !appStudy )
|
|
|
|
return;
|
|
|
|
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if( selected.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
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 ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
aMainObject->SetAutoColor( false );
|
2012-10-08 17:16:36 +06:00
|
|
|
}
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
void GEOMToolsGUI::OnColor()
|
2012-10-08 17:16:36 +06:00
|
|
|
{
|
|
|
|
// get active application
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
// get current study
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
2012-10-08 17:16:36 +06:00
|
|
|
if ( !appStudy ) return;
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// 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( appStudy );
|
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
// get active view
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
2012-10-08 17:16:36 +06:00
|
|
|
if ( !window ) return;
|
|
|
|
|
|
|
|
// get view id
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-10-08 17:16:36 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
QColor color;
|
|
|
|
QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// show Choose Color dialog box
|
|
|
|
color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
|
|
|
|
if ( !color.isValid() ) return;
|
2012-10-08 17:16:36 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// iterate through list of objects and assign new color
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
|
|
|
Handle( SALOME_InteractiveObject ) io = It.Value();
|
|
|
|
appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Color ), color );
|
|
|
|
if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
|
2012-10-08 17:16:36 +06:00
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
displayer.UpdateViewer();
|
2012-10-08 17:16:36 +06:00
|
|
|
GeometryGUI::Modified();
|
2013-02-28 20:00:05 +06:00
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
// update actions
|
|
|
|
app->updateActions(); //SRN: To update a Save button in the toolbar
|
2008-03-07 12:45:34 +05:00
|
|
|
}
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
void GEOMToolsGUI::OnTexture()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
2012-10-08 17:16:36 +06:00
|
|
|
if ( !app ) return;
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
2012-10-08 17:16:36 +06:00
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
2012-10-08 17:16:36 +06:00
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2012-10-08 17:16:36 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-10-08 17:16:36 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
QString aTexture = QFileDialog::getOpenFileName( dynamic_cast< SUIT_ViewWindow* >( window ),tr("GEOM_SELECT_IMAGE"),QString(), tr("OCC_TEXTURE_FILES"));
|
|
|
|
if( !aTexture.isEmpty() ) {
|
2012-10-08 17:16:36 +06:00
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
2013-02-28 20:00:05 +06:00
|
|
|
Handle( SALOME_InteractiveObject ) io = It.Value();
|
2013-12-18 20:23:59 +06:00
|
|
|
appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::Texture ), aTexture );
|
2013-02-28 20:00:05 +06:00
|
|
|
appStudy->setObjectProperty( aMgrId, io->getEntry(), GEOM::propertyName( GEOM::DisplayMode ), 3 );
|
|
|
|
if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
displayer.UpdateViewer();
|
2012-10-08 17:16:36 +06:00
|
|
|
GeometryGUI::Modified();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// update actions
|
2005-08-22 17:45:30 +06:00
|
|
|
app->updateActions(); //SRN: To update a Save button in the toolbar
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnTransparency()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
|
|
|
|
dlg.exec();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
void GEOMToolsGUI::OnChangeTransparency( bool increase )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2013-02-28 20:00:05 +06:00
|
|
|
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;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( !aSelMgr ) return;
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
|
|
|
|
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
// Delta
|
|
|
|
float delta = 0.1; // VSR: 23/11/2010 (transparency value <= 0.05 is ignored)
|
|
|
|
if ( !increase )
|
|
|
|
delta *= -1;
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
QVariant v = appStudy->getObjectProperty( aMgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Transparency ), QVariant() );
|
|
|
|
float transp = v.isValid() ? v.toFloat() : 1;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
// Compute new transparency value
|
|
|
|
transp = transp + delta;
|
|
|
|
if ( transp < 0 )
|
|
|
|
transp = 0;
|
|
|
|
else if ( transp > 1 )
|
|
|
|
transp = 1;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnNbIsos( ActionType actionType )
|
|
|
|
{
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
|
|
|
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();
|
2009-02-13 17:16:39 +05:00
|
|
|
}
|
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int newNbUIso = -1;
|
|
|
|
int newNbVIso = -1;
|
2013-02-12 17:35:16 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( actionType == SHOWDLG ) {
|
|
|
|
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
|
|
|
|
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
2009-02-13 17:16:39 +05:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
NbIsosDlg->setU( UIso );
|
|
|
|
NbIsosDlg->setV( VIso );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( NbIsosDlg->exec() ) {
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
newNbUIso = NbIsosDlg->getU();
|
|
|
|
newNbVIso = NbIsosDlg->getV();
|
|
|
|
} else //Cancel case
|
2009-02-13 17:16:39 +05:00
|
|
|
return;
|
2013-02-28 20:00:05 +06:00
|
|
|
}
|
|
|
|
else if ( actionType == INCR || actionType == DECR ) {
|
|
|
|
int delta = 1;
|
|
|
|
if (actionType == DECR)
|
|
|
|
delta = -1;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
newNbUIso = UIso + delta;
|
|
|
|
newNbVIso = VIso + delta;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
|
2009-02-13 17:16:39 +05:00
|
|
|
return;
|
2013-02-28 20:00:05 +06:00
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
2012-08-09 13:58:02 +06:00
|
|
|
void GEOMToolsGUI::OnDeflection()
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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 );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg
|
|
|
|
( SUIT_Session::session()->activeApplication()->desktop() );
|
|
|
|
DeflectionDlg->setTheDC( aDC );
|
|
|
|
if ( DeflectionDlg->exec() ) {
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
aDC = DeflectionDlg->getTheDC();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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 );
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
}
|
|
|
|
displayer.UpdateViewer();
|
|
|
|
GeometryGUI::Modified();
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
void GEOMToolsGUI::OnSelectOnly(int mode)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
aDisp.GlobalSelection(mode);
|
|
|
|
getGeometryGUI()->setLocalSelectionMode(mode);
|
|
|
|
}
|
|
|
|
}
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2012-10-08 17:16:36 +06:00
|
|
|
void GEOMToolsGUI::OnDiscloseConcealChildren( bool show )
|
2012-08-09 13:58:02 +06:00
|
|
|
{
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
SalomeApp_Application* app =
|
|
|
|
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
|
|
|
|
SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
|
|
|
|
|
|
|
|
GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
|
|
|
|
|
|
|
|
if ( app && disp ) {
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( aSelMgr && appStudy ) {
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( !selected.IsEmpty() ) {
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app->updateObjectBrowser( false );
|
|
|
|
app->updateActions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnPointMarker()
|
|
|
|
{
|
|
|
|
GEOMToolsGUI_MarkerDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
|
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnMaterialProperties()
|
|
|
|
{
|
2013-02-12 17:35:16 +06:00
|
|
|
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()
|
|
|
|
{
|
2013-06-17 18:15:50 +06:00
|
|
|
GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop(), false, true, QtxDialog::Standard );
|
|
|
|
dlg.setWindowTitle( tr( "MATERIAL_LIBRARY_TLT" ) );
|
2012-08-09 13:58:02 +06:00
|
|
|
dlg.exec();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnUnpublishObject() {
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
SalomeApp_Application* app =
|
|
|
|
dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
|
|
|
|
SalomeApp_Module* mod = app ? dynamic_cast<SalomeApp_Module*>(app->activeModule()) : 0;
|
|
|
|
|
|
|
|
GEOM_Displayer* disp = mod ? dynamic_cast<GEOM_Displayer*>(mod->displayer()) : 0;
|
|
|
|
|
|
|
|
if ( app && disp ) {
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( aSelMgr && appStudy ) {
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( !selected.IsEmpty() ) {
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
} // if ( obj )
|
|
|
|
} // iterator
|
|
|
|
aSelMgr->clearSelected();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
app->updateObjectBrowser( false );
|
|
|
|
app->updateActions();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnPublishObject() {
|
|
|
|
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;
|
|
|
|
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
2013-11-14 20:16:31 +06:00
|
|
|
GEOMToolsGUI_PublishDlg* publishDlg =
|
2012-08-09 13:58:02 +06:00
|
|
|
new GEOMToolsGUI_PublishDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
2013-11-14 20:16:31 +06:00
|
|
|
publishDlg->show();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnEdgeWidth()
|
|
|
|
{
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOMToolsGUI_LineWidthDlg* Dlg =
|
|
|
|
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "EDGE_WIDTH_TLT" );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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 );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
Dlg->setTheLW( aWidth );
|
|
|
|
if ( Dlg->exec() ) {
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
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 );
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
displayer.UpdateViewer();
|
|
|
|
GeometryGUI::Modified();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnIsosWidth() {
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr ) return;
|
2013-02-12 17:35:16 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOMToolsGUI_LineWidthDlg* Dlg =
|
|
|
|
new GEOMToolsGUI_LineWidthDlg( SUIT_Session::session()->activeApplication()->desktop(), "ISOS_WIDTH_TLT" );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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();
|
|
|
|
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();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnBringToFront() {
|
2013-02-28 20:00:05 +06:00
|
|
|
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;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( !aSelMgr ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
2013-02-28 20:00:05 +06:00
|
|
|
if ( selected.IsEmpty() ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
int aMgrId = dynamic_cast< SUIT_ViewModel* >( window )->getViewManager()->getGlobalId();
|
2012-08-09 13:58:02 +06:00
|
|
|
|
|
|
|
QAction* a = getGeometryGUI()->getAction( GEOMOp::OpBringToFront );
|
|
|
|
bool checked = a->isChecked();
|
2013-02-28 20:00:05 +06:00
|
|
|
|
|
|
|
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();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnClsBringToFront() {
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
|
|
|
|
if ( !appStudy ) return;
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
GEOM_Displayer displayer( appStudy );
|
2012-08-09 13:58:02 +06:00
|
|
|
|
2013-02-28 20:00:05 +06:00
|
|
|
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 );
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
2013-02-28 20:00:05 +06:00
|
|
|
displayer.Redisplay( anIOlst );
|
|
|
|
displayer.UpdateViewer();
|
|
|
|
GeometryGUI::Modified();
|
2012-08-09 13:58:02 +06:00
|
|
|
}
|
|
|
|
|
2013-02-12 17:35:16 +06:00
|
|
|
void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam )
|
|
|
|
{
|
|
|
|
if ( !theParam.canConvert<QString>() ) return;
|
|
|
|
|
|
|
|
QString theName = theParam.toString();
|
|
|
|
|
|
|
|
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( !study ) return;
|
|
|
|
|
|
|
|
LightApp_SelectionMgr* selMgr = app->selectionMgr();
|
|
|
|
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
selMgr->selectedObjects( selected );
|
|
|
|
|
|
|
|
if ( selected.IsEmpty() ) return;
|
|
|
|
|
|
|
|
GEOM_Displayer displayer( study );
|
|
|
|
|
|
|
|
SALOME_View* window = displayer.GetActiveView();
|
|
|
|
if ( !window ) return;
|
|
|
|
|
|
|
|
int mgrId = dynamic_cast<SUIT_ViewModel*>( 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();
|
|
|
|
}
|
2013-06-28 14:18:20 +06:00
|
|
|
|
|
|
|
void GEOMToolsGUI::OnCreateFolder()
|
|
|
|
{
|
|
|
|
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").toLatin1().constData(),
|
|
|
|
_CAST(SObject, aFatherSO)->GetSObject() );
|
|
|
|
app->updateObjectBrowser( false );
|
|
|
|
}
|
2013-07-09 14:22:16 +06:00
|
|
|
|
|
|
|
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 );
|
|
|
|
}
|