2004-12-01 15:39:14 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2004 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
|
2005-08-18 12:15:31 +06:00
|
|
|
// 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
|
|
|
|
//
|
2006-06-01 17:32:40 +06:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2005-08-18 12:15:31 +06:00
|
|
|
//
|
2004-12-01 15:39:14 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : GEOMToolsGUI_1.cxx
|
|
|
|
// Author : Sergey ANIKIN
|
|
|
|
// Module : GEOM
|
|
|
|
// $Header$
|
|
|
|
|
2005-06-09 15:10:51 +06:00
|
|
|
#include <PythonConsole_PyConsole.h>
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GEOMToolsGUI.h"
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GeometryGUI.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
#include "GEOMToolsGUI_TransparencyDlg.h"
|
|
|
|
#include "GEOMToolsGUI_NbIsosDlg.h" // Method ISOS adjustement
|
|
|
|
|
2005-08-18 12:15:31 +06:00
|
|
|
#include "GEOM_Actor.h"
|
|
|
|
#include "GEOMBase.h"
|
|
|
|
|
2006-02-07 20:58:35 +05:00
|
|
|
#include "SALOME_ListIO.hxx"
|
|
|
|
#include "SALOME_ListIteratorOfListIO.hxx"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
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>
|
|
|
|
#include <OCCViewer_ViewWindow.h>
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
#include <SUIT_ViewManager.h>
|
|
|
|
#include <SUIT_Application.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>
|
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 "SALOMEDSClient.hxx"
|
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
|
|
|
|
// OCCT Includes
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <AIS_Drawer.hxx>
|
|
|
|
#include <AIS_ListOfInteractive.hxx>
|
|
|
|
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
|
|
|
#include <Prs3d_IsoAspect.hxx>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <Prs3d_PointAspect.hxx>
|
|
|
|
#include <Graphic3d_AspectMarker3d.hxx>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-08-18 12:15:31 +06:00
|
|
|
// VTK Includes
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <vtkBMPReader.h>
|
|
|
|
#include <vtkTexture.h>
|
|
|
|
#include <vtkTextureMapToPlane.h>
|
|
|
|
#include <vtkTransformTextureCoords.h>
|
|
|
|
#include <vtkDataSetMapper.h>
|
|
|
|
#include <vtkRenderer.h>
|
|
|
|
|
2005-08-18 12:15:31 +06:00
|
|
|
// QT Includes
|
2004-12-01 15:39:14 +05:00
|
|
|
#include <qfileinfo.h>
|
|
|
|
#include <qcolordialog.h>
|
|
|
|
#include <qspinbox.h>
|
|
|
|
#include <qapplication.h>
|
2008-03-07 12:45:34 +05:00
|
|
|
#include <qptrlist.h>
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
void GEOMToolsGUI::OnSettingsColor()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session* sess = SUIT_Session::session();
|
|
|
|
SUIT_ResourceMgr* resMgr = sess->resourceMgr();
|
|
|
|
SUIT_Desktop* desk = sess->activeApplication()->desktop();
|
|
|
|
|
2005-07-29 17:46:49 +06:00
|
|
|
QColor anInitColor = resMgr->colorValue( "Geometry", "SettingsShadingColor", QColor( "yellow" ) );
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
QColor aDialogColor = QColorDialog::getColor(anInitColor, desk );
|
2005-08-18 12:15:31 +06:00
|
|
|
if( aDialogColor.isValid() )
|
2005-06-02 13:17:09 +06:00
|
|
|
{
|
|
|
|
QString type = desk->activeWindow()->getViewManager()->getType();
|
2005-10-05 12:28:23 +06:00
|
|
|
if( type != OCCViewer_Viewer::Type() && type != SVTK_Viewer::Type() )
|
2004-12-01 15:39:14 +05:00
|
|
|
MESSAGE("Settings Color is not supported for current Viewer");
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-07-29 17:46:49 +06:00
|
|
|
resMgr->setValue( "Geometry", "SettingsShadingColor", aDialogColor );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnSettingsIsos()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
/*
|
|
|
|
SUIT_Session* sess = SUIT_Session::session();
|
|
|
|
SUIT_ResourceMgr* resMgr = sess->resourceMgr();
|
|
|
|
SUIT_Desktop* desk = sess->activeApplication()->desktop();
|
|
|
|
|
|
|
|
SUIT_ViewManager* vman = desk->activeWindow()->getViewManager();
|
|
|
|
QString type = vman->getType();
|
|
|
|
|
|
|
|
if ( type != OCCViewer_Viewer::Type() )
|
2004-12-01 15:39:14 +05:00
|
|
|
return;
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
OCCViewer_Viewer* vm = (OCCViewer_Viewer*)vman->getViewModel();
|
|
|
|
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
int IsoU = resMgr->integerValue( "Geometry:SettingsIsoU", 1 );
|
|
|
|
int IsoV = resMgr->integerValue( "Geometry:SettingsIsoV", 1 );
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
ic->DefaultDrawer()->UIsoAspect()->SetNumber( IsoU );
|
|
|
|
ic->DefaultDrawer()->VIsoAspect()->SetNumber( IsoV );
|
2005-08-18 12:15:31 +06:00
|
|
|
|
|
|
|
GEOMBase_NbIsosDlg* NbIsosDlg = new GEOMBase_NbIsosDlg(desk, tr("GEOM_MEN_ISOS"), TRUE);
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
NbIsosDlg->SpinBoxU->setValue(IsoU);
|
|
|
|
NbIsosDlg->SpinBoxV->setValue(IsoV);
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
if(NbIsosDlg->exec()) {
|
2005-06-02 13:17:09 +06:00
|
|
|
IsoU = NbIsosDlg->SpinBoxU->text().toInt();
|
|
|
|
IsoV = NbIsosDlg->SpinBoxV->text().toInt();
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
ic->DefaultDrawer()->UIsoAspect()->SetNumber(UIso);
|
|
|
|
ic->DefaultDrawer()->VIsoAspect()->SetNumber(VIso);
|
2005-06-02 13:17:09 +06:00
|
|
|
resMgr->setValue("Geometry:SettingsIsoU", isoU);
|
|
|
|
resMgr->setValue("Geometry:SettingsIsoV", isoV);
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
*/
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnSettingsStep()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session* sess = SUIT_Session::session();
|
|
|
|
SUIT_ResourceMgr* resMgr = sess->resourceMgr();
|
|
|
|
|
2005-06-22 15:58:12 +06:00
|
|
|
double step = resMgr->doubleValue( "Geometry", "SettingsGeomStep", 100. );
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
Standard_Boolean res = false;
|
2005-06-22 15:58:12 +06:00
|
|
|
double dd = GEOMBase::Parameter( res, QString("%1").arg(step), tr("GEOM_MEN_STEP_LABEL"), tr("GEOM_STEP_TITLE"), 0.001, 10000.0, 3);
|
2004-12-01 15:39:14 +05:00
|
|
|
if(res) {
|
2005-06-22 15:58:12 +06:00
|
|
|
resMgr->setValue( "Geometry", "SettingsGeomStep", dd );
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
/* Emit signal to GeometryGUI_SpinBoxes */
|
2005-06-02 13:17:09 +06:00
|
|
|
getGeometryGUI()->EmitSignalDefaultStepValueChanged( dd );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
else
|
2005-06-02 13:17:09 +06:00
|
|
|
sess->activeApplication()->putInfo(tr("GEOM_PRP_ABORT"));
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnRename()
|
|
|
|
{
|
2005-06-03 16:42:52 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( app ) {
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2005-06-03 16:42:52 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( 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(),
|
2005-08-18 12:15:31 +06:00
|
|
|
QObject::tr("WRN_WARNING"),
|
2005-06-03 16:42:52 +06:00
|
|
|
QObject::tr("WRN_STUDY_LOCKED"),
|
|
|
|
QObject::tr("BUT_OK") );
|
|
|
|
return;
|
|
|
|
}
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-03 16:42:52 +06:00
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
|
|
|
Handle(SALOME_InteractiveObject) IObject = It.Value();
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-03 16:42:52 +06:00
|
|
|
_PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) );
|
|
|
|
_PTR(GenericAttribute) anAttr;
|
|
|
|
if ( obj ) {
|
|
|
|
if( obj->FindAttribute(anAttr, "AttributeName") ) {
|
|
|
|
_PTR(AttributeName) aName (anAttr);
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2006-03-13 20:11:51 +05:00
|
|
|
QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() );
|
2005-06-03 16:42:52 +06:00
|
|
|
if ( !newName.isEmpty() ) {
|
|
|
|
aName->SetValue( newName.latin1() ); // rename the SObject
|
|
|
|
IObject->setName( newName.latin1() );// rename the InteractiveObject
|
2008-03-07 12:45:34 +05:00
|
|
|
// Rename the corresponding GEOM_Object
|
|
|
|
GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj));
|
|
|
|
if (!CORBA::is_nil( anObj ))
|
|
|
|
anObj->SetName( newName.latin1() );
|
2005-06-03 16:42:52 +06:00
|
|
|
(dynamic_cast<SalomeApp_Module*>(app->activeModule()))->updateObjBrowser( false );
|
|
|
|
}
|
|
|
|
} // if ( name attribute )
|
|
|
|
} // if ( obj )
|
|
|
|
} // iterator
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
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::OnCheckGeometry()
|
|
|
|
{
|
2005-06-09 15:10:51 +06:00
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
PythonConsole* pyConsole = app->pythonConsole();
|
2005-08-18 12:15:31 +06:00
|
|
|
|
2005-06-09 15:10:51 +06:00
|
|
|
if(pyConsole)
|
|
|
|
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()
|
|
|
|
{
|
|
|
|
QPtrList<SALOME_Prs> aListOfGroups;
|
|
|
|
|
|
|
|
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( true );
|
|
|
|
|
|
|
|
QValueList<SALOMEDS::Color> aReservedColors;
|
|
|
|
|
|
|
|
GEOM_Displayer aDisp (appStudy);
|
|
|
|
|
|
|
|
SALOME_View* vf = aDisp.GetActiveView();
|
|
|
|
|
|
|
|
SUIT_ViewWindow* window = app->desktop()->activeWindow();
|
|
|
|
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
|
|
|
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if( aChildObject->GetType() != GEOM_GROUP )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
SALOMEDS::Color aColor = GEOM_Displayer::getUniqueColor( aReservedColors );
|
|
|
|
aChildObject->SetColor( aColor );
|
|
|
|
aReservedColors.append( aColor );
|
|
|
|
|
|
|
|
QColor c( (int)( aColor.R * 255.0 ), (int)( aColor.G * 255.0 ), (int)( aColor.B * 255.0 ) );
|
|
|
|
|
|
|
|
SALOME_Prs* aPrs = vf->CreatePrs( aChildSObject->GetID().c_str() );
|
|
|
|
|
|
|
|
if ( isVTK )
|
|
|
|
{
|
|
|
|
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
|
|
|
|
if ( !vtkVW )
|
|
|
|
return;
|
|
|
|
SVTK_View* aView = vtkVW->getView();
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() )
|
|
|
|
aView->SetColor( It.Value(), c );
|
|
|
|
}
|
|
|
|
else if ( isOCC )
|
|
|
|
{
|
|
|
|
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
|
|
|
|
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
|
|
|
|
|
|
|
|
SOCC_Prs* anOCCPrs = dynamic_cast<SOCC_Prs*>( aPrs );
|
|
|
|
if( !anOCCPrs )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
AIS_ListOfInteractive aList;
|
|
|
|
anOCCPrs->GetObjects( aList );
|
|
|
|
if( !aList.Extent() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Handle(AIS_InteractiveObject) io = aList.First();
|
|
|
|
if( io.IsNull() )
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Quantity_Color aQuanColor( c.red() / 255., c.green() / 255., c.blue() / 255., Quantity_TOC_RGB );
|
|
|
|
|
|
|
|
// Set color for a point
|
|
|
|
Handle(AIS_Drawer) aCurDrawer = io->Attributes();
|
|
|
|
Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
|
|
|
|
Quantity_Color aCurColor;
|
|
|
|
Standard_Real aCurScale;
|
|
|
|
Aspect_TypeOfMarker aCurTypeOfMarker;
|
|
|
|
aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
|
|
|
|
aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aQuanColor, aCurScale) );
|
|
|
|
ic->SetLocalAttributes( io, aCurDrawer );
|
|
|
|
|
|
|
|
io->SetColor( aQuanColor );
|
|
|
|
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
|
|
|
|
Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aQuanColor );
|
|
|
|
|
|
|
|
io->Redisplay( Standard_True );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
void GEOMToolsGUI::OnColor()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SALOME_ListIO selected;
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
|
|
|
if ( app && appStudy ) {
|
2005-11-03 13:30:14 +05:00
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( aSelMgr ) {
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( !selected.IsEmpty() ) {
|
|
|
|
SUIT_ViewWindow* window = app->desktop()->activeWindow();
|
|
|
|
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
2005-10-05 12:28:23 +06:00
|
|
|
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( isVTK ) {
|
|
|
|
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
|
|
|
|
if ( !vtkVW )
|
|
|
|
return;
|
2006-02-07 20:58:35 +05:00
|
|
|
SVTK_View* aView = vtkVW->getView();
|
|
|
|
QColor initcolor = aView->GetColor( selected.First() );
|
2008-03-07 12:45:34 +05:00
|
|
|
QColor c = QColorDialog::getColor( initcolor, app->desktop() );
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( c.isValid() ) {
|
|
|
|
SUIT_OverrideCursor();
|
|
|
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
2006-02-07 20:58:35 +05:00
|
|
|
aView->SetColor( It.Value(), c );
|
2005-06-02 13:17:09 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // 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() ) {
|
2008-03-07 12:45:34 +05:00
|
|
|
// Set color for a point
|
|
|
|
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
|
|
|
|
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
|
|
|
|
Handle(AIS_Drawer) aCurDrawer = io->Attributes();
|
|
|
|
Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect();
|
|
|
|
Quantity_Color aCurColor;
|
|
|
|
Standard_Real aCurScale;
|
|
|
|
Aspect_TypeOfMarker aCurTypeOfMarker;
|
|
|
|
aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale );
|
|
|
|
aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale) );
|
|
|
|
ic->SetLocalAttributes(io, aCurDrawer);
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
io->SetColor( aColor );
|
|
|
|
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
|
|
|
|
Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor );
|
2004-12-01 15:39:14 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
io->Redisplay( Standard_True );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
// store color to GEOM_Object
|
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
|
|
|
_PTR(SObject) aSObject( aStudy->FindObjectID( It.Value()->getEntry() ) );
|
|
|
|
GEOM::GEOM_Object_var anObject =
|
|
|
|
GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(aSObject));
|
|
|
|
|
|
|
|
SALOMEDS::Color aSColor;
|
|
|
|
aSColor.R = (double)c.red() / 255.0;
|
|
|
|
aSColor.G = (double)c.green() / 255.0;
|
|
|
|
aSColor.B = (double)c.blue() / 255.0;
|
|
|
|
anObject->SetColor( aSColor );
|
|
|
|
anObject->SetAutoColor( false );
|
2005-06-02 13:17:09 +06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if c.isValid()
|
|
|
|
} // first IO is not null
|
|
|
|
} // if ( isOCC )
|
|
|
|
} // if ( selection not empty )
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnNbIsos()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
2008-03-07 12:45:34 +05:00
|
|
|
const bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
|
|
|
|
|
|
|
// if is OCCViewer
|
|
|
|
if(isOCC){
|
|
|
|
|
|
|
|
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
|
|
|
|
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if(isVTK){ // if is VTKViewer
|
|
|
|
|
|
|
|
//
|
|
|
|
// Warning. It's works incorrect. must be recheked.
|
|
|
|
//
|
|
|
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
|
|
|
if ( !app )
|
|
|
|
return;
|
|
|
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
|
|
|
if ( !aSelMgr )
|
|
|
|
return;
|
|
|
|
SALOME_ListIO selected;
|
|
|
|
aSelMgr->selectedObjects( selected );
|
|
|
|
if ( selected.IsEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
|
|
|
|
if ( FirstIOS.IsNull() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
|
|
|
|
if ( !vtkVW )
|
|
|
|
return;
|
|
|
|
|
|
|
|
SVTK_View* aView = vtkVW->getView();
|
|
|
|
vtkActorCollection* aCollection = aView->getRenderer()->GetActors();
|
|
|
|
|
|
|
|
int UIso = 0;
|
|
|
|
int VIso = 0;
|
|
|
|
if(aCollection){
|
|
|
|
aCollection->InitTraversal();
|
|
|
|
}
|
|
|
|
|
|
|
|
vtkActor *anAct = aCollection->GetNextActor();
|
|
|
|
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
|
|
|
|
anActor->GetNbIsos(UIso,VIso);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
|
|
|
|
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
NbIsosDlg->setU( UIso );
|
|
|
|
NbIsosDlg->setV( VIso );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( NbIsosDlg->exec() ) {
|
|
|
|
SUIT_OverrideCursor();
|
2008-03-07 12:45:34 +05:00
|
|
|
|
|
|
|
while(anAct = aCollection->GetNextActor()) {
|
|
|
|
if(GEOM_Actor *anActor = dynamic_cast<GEOM_Actor*>(anAct)){
|
|
|
|
// There are no casting to needed actor.
|
|
|
|
UIso = NbIsosDlg->getU();
|
|
|
|
VIso = NbIsosDlg->getV();
|
|
|
|
int aIsos[2]={UIso,VIso};
|
|
|
|
anActor->SetNbIsos(aIsos);
|
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
2008-03-07 12:45:34 +05:00
|
|
|
} // end vtkviewer
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
void GEOMToolsGUI::OnOpen()
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
/*
|
2004-12-01 15:39:14 +05:00
|
|
|
SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(Study) aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
2004-12-01 15:39:14 +05:00
|
|
|
|
|
|
|
SALOME_ListIteratorOfListIO It(Sel->StoredIObjects());
|
|
|
|
Handle(SALOME_InteractiveObject) anIObject;
|
|
|
|
for(;It.More();It.Next()) {
|
|
|
|
anIObject = It.Value();
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) obj ( aStudy->FindObjectID(anIObject->getEntry()) );
|
|
|
|
_PTR(AttributePersistentRef) aPersist;
|
|
|
|
_PTR(AttributeIOR) anIOR;
|
|
|
|
if(obj) {
|
2004-12-01 15:39:14 +05:00
|
|
|
// this SObject may be GEOM module root SObject
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(ChildIterator) anIter ( aStudy->NewChildIterator() );
|
|
|
|
_PTR(GenericAttribute) anAttr;
|
2004-12-01 15:39:14 +05:00
|
|
|
bool useSubItems = false;
|
|
|
|
while (anIter->More() && !useSubItems) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) subobj ( anIter->Value() );
|
2004-12-01 15:39:14 +05:00
|
|
|
if (subobj->FindAttribute(anAttr, "AttributePersistentRef")) {
|
|
|
|
useSubItems = true;
|
2005-06-02 13:17:09 +06:00
|
|
|
obj = subobj;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2005-08-18 12:15:31 +06:00
|
|
|
else
|
2004-12-01 15:39:14 +05:00
|
|
|
anIter->Next();
|
|
|
|
}
|
|
|
|
obj->FindAttribute(anAttr, "AttributePersistentRef");
|
2005-08-18 12:15:31 +06:00
|
|
|
|
|
|
|
while(useSubItems?anIter->More():!anAttr->_is_nil()) {
|
2004-12-01 15:39:14 +05:00
|
|
|
if(!obj->FindAttribute(anAttr, "AttributeIOR") &&
|
|
|
|
obj->FindAttribute(anAttr, "AttributePersistentRef")) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SComponent) FComp ( obj->GetFatherComponent() );
|
|
|
|
if (FComp) {
|
2004-12-01 15:39:14 +05:00
|
|
|
if (FComp->FindAttribute(anAttr, "AttributeName")) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(AttributeName) aName ( anAttr );
|
|
|
|
QString compName = QAD_Application::getDesktop()->getComponentName(aName->Value().c_str());
|
2004-12-01 15:39:14 +05:00
|
|
|
// 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)) {
|
2005-06-02 13:17:09 +06:00
|
|
|
SALOMEDS::StudyBuilder_var B = dynamic_cast<SALOMEDS_Study*>(aStudy.get())->GetStudy()->NewBuilder();
|
2004-12-01 15:39:14 +05:00
|
|
|
if (!CORBA::is_nil(B)) {
|
|
|
|
B->LoadWith(FComp,driver);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2005-08-18 12:15:31 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
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);
|
2005-08-18 12:15:31 +06:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
MESSAGE("Component is null");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(useSubItems) {
|
|
|
|
anIter->Next();
|
2005-06-02 13:17:09 +06:00
|
|
|
obj.reset( anIter->Value() );
|
2005-08-18 12:15:31 +06:00
|
|
|
}
|
|
|
|
else
|
2005-06-02 13:17:09 +06:00
|
|
|
anAttr = NULL;
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-02 13:17:09 +06:00
|
|
|
*/
|
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);
|
|
|
|
}
|
|
|
|
}
|