geom/src/TransformationGUI/TransformationGUI.cxx

187 lines
6.9 KiB
C++
Raw Normal View History

2015-02-10 14:25:19 +05:00
// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +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
2004-01-07 20:46:21 +05: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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
2004-01-07 20:46:21 +05: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.
2009-02-13 17:16:39 +05: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
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2009-02-13 17:16:39 +05:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : TransformationGUI.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2012-08-09 13:58:02 +06:00
2004-01-07 20:46:21 +05:00
#include "TransformationGUI.h"
2009-02-13 17:16:39 +05:00
#include <GEOMBase.h>
#include <GeometryGUI.h>
2012-08-09 13:58:02 +06:00
#include "GeometryGUI_Operations.h"
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
#include <SUIT_Desktop.h>
#include <SUIT_ViewModel.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
#include <SALOME_ListIO.hxx>
#include "TransformationGUI_ExtensionDlg.h" // Method EXTENSION
2004-01-07 20:46:21 +05:00
#include "TransformationGUI_MultiTranslationDlg.h" // Method MULTI TRANSLATION
#include "TransformationGUI_MultiRotationDlg.h" // Method MULTI ROTATION
#include "TransformationGUI_TranslationDlg.h" // Method TRANSLATION
#include "TransformationGUI_RotationDlg.h" // Method ROTATION
#include "TransformationGUI_MirrorDlg.h" // Method MIRROR
#include "TransformationGUI_ScaleDlg.h" // Method SCALE
2004-12-01 15:39:14 +05:00
#include "TransformationGUI_OffsetDlg.h" // Method OFFSET
2012-08-09 13:58:02 +06:00
#include "TransformationGUI_ProjectionDlg.h" // Method PROJECTION
2004-12-01 15:39:14 +05:00
#include "TransformationGUI_PositionDlg.h" // Method POSITION
#include "TransformationGUI_ProjectionOnCylDlg.h" // Method PROJECTION ON CYLINDER
2004-12-01 15:39:14 +05:00
2004-01-07 20:46:21 +05:00
//=======================================================================
// function : TransformationGUI()
// purpose : Constructor
//=======================================================================
2009-02-13 17:16:39 +05:00
TransformationGUI::TransformationGUI( GeometryGUI* parent )
: GEOMGUI( parent )
2004-01-07 20:46:21 +05:00
{
}
//=======================================================================
// function : ~TransformationGUI()
// purpose : Destructor
//=======================================================================
TransformationGUI::~TransformationGUI()
{
}
//=======================================================================
// function : OnGUIEvent()
// purpose :
//=======================================================================
2009-02-13 17:16:39 +05:00
bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
2004-01-07 20:46:21 +05:00
{
SalomeApp_Application* app = getGeometryGUI()->getApp();
2009-02-13 17:16:39 +05:00
if ( !app ) return false;
getGeometryGUI()->EmitSignalDeactivateDialog();
2004-12-01 15:39:14 +05:00
QDialog* aDlg = NULL;
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
switch ( theCommandID ) {
2012-08-09 13:58:02 +06:00
case GEOMOp::OpTranslate: // TRANSLATION
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpRotate: // ROTATION
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpChangeLoc: // POSITION
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpMirror: // MIRROR
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpScale: // SCALE
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpOffset: // OFFSET
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpProjection: // PROJECTION
aDlg = new TransformationGUI_ProjectionDlg( getGeometryGUI(), parent );
break;
case GEOMOp::OpProjOnCyl: // PROJECTION ON CYLINDER
aDlg = new TransformationGUI_ProjectionOnCylDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpMultiTranslate: // MULTI TRANSLATION
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpMultiRotate: // MULTI ROTATION
2009-02-13 17:16:39 +05:00
aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpReimport: // RELOAD IMPORTED SHAPE
2009-02-13 17:16:39 +05:00
{
SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
GEOM::GEOM_ITransformOperations_var anOp =
GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
if (anOp->_is_nil()) return false;
GEOM_Displayer aDisp (anAppStudy);
SUIT_Desktop* desk = app->desktop();
QList<SUIT_ViewWindow*> wnds = desk->windows();
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
SALOME_ListIteratorOfListIO aSelIt (aSelList);
for (; aSelIt.More(); aSelIt.Next()) {
Handle(SALOME_InteractiveObject) io = aSelIt.Value();
2012-08-09 13:58:02 +06:00
GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( io );
if ( !CORBA::is_nil( aGeomObj ) ) {
2009-02-13 17:16:39 +05:00
anOp->RecomputeObject(aGeomObj);
SUIT_ViewWindow* wnd;
QListIterator<SUIT_ViewWindow*> it (wnds);
while (it.hasNext() && (wnd = it.next()))
{
if (SUIT_ViewManager* vman = wnd->getViewManager()) {
if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
if (view->isVisible(io)) {
2012-08-09 13:58:02 +06:00
aDisp.Erase(io, true, false, view);
2013-06-17 18:15:50 +06:00
getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( getGeometryGUI()->getApp()->orb()->object_to_string( aGeomObj.in() ) );
2009-02-13 17:16:39 +05:00
aDisp.Display(io, true, view);
}
// ? Redisplay subshapes ?
}
}
}
}
}
} // for (; aSelIt.More(); aSelIt.Next())
}
break;
case GEOMOp::OpExtension: // EXTENSION
aDlg = new TransformationGUI_ExtensionDlg( getGeometryGUI(), parent );
break;
default:
2009-02-13 17:16:39 +05:00
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break;
}
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
if ( aDlg != NULL )
2004-12-01 15:39:14 +05:00
aDlg->show();
2004-01-07 20:46:21 +05:00
2004-12-01 15:39:14 +05:00
return true;
2004-01-07 20:46:21 +05:00
}
//=====================================================================================
// EXPORTED METHODS
//=====================================================================================
extern "C"
{
#ifdef WIN32
2009-02-13 17:16:39 +05:00
__declspec( dllexport )
2005-08-29 12:03:08 +06:00
#endif
GEOMGUI* GetLibGUI( GeometryGUI* parent )
2004-12-01 15:39:14 +05:00
{
return new TransformationGUI( parent );
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
}