Back to index

salome-geom  6.5.0
TransformationGUI.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // GEOM GEOMGUI : GUI for Geometry component
00024 // File   : TransformationGUI.cxx
00025 // Author : Damien COQUERET, Open CASCADE S.A.S.
00026 
00027 #include "TransformationGUI.h"
00028 
00029 #include <GEOMBase.h>
00030 #include <GeometryGUI.h>
00031 #include "GeometryGUI_Operations.h"
00032 
00033 #include <SUIT_Desktop.h>
00034 #include <SUIT_ViewModel.h>
00035 #include <SUIT_ViewWindow.h>
00036 #include <SUIT_ViewManager.h>
00037 #include <LightApp_SelectionMgr.h>
00038 #include <SalomeApp_Application.h>
00039 #include <SalomeApp_Study.h>
00040 #include <SALOME_ListIteratorOfListIO.hxx>
00041 
00042 #include "TransformationGUI_MultiTranslationDlg.h"   // Method MULTI TRANSLATION
00043 #include "TransformationGUI_MultiRotationDlg.h"      // Method MULTI ROTATION
00044 #include "TransformationGUI_TranslationDlg.h"        // Method TRANSLATION
00045 #include "TransformationGUI_RotationDlg.h"           // Method ROTATION
00046 #include "TransformationGUI_MirrorDlg.h"             // Method MIRROR
00047 #include "TransformationGUI_ScaleDlg.h"              // Method SCALE
00048 #include "TransformationGUI_OffsetDlg.h"             // Method OFFSET
00049 #include "TransformationGUI_ProjectionDlg.h"         // Method PROJECTION
00050 #include "TransformationGUI_PositionDlg.h"           // Method POSITION
00051 
00052 //=======================================================================
00053 // function : TransformationGUI()
00054 // purpose  : Constructor
00055 //=======================================================================
00056 TransformationGUI::TransformationGUI( GeometryGUI* parent )
00057   : GEOMGUI( parent )
00058 {
00059 }
00060 
00061 //=======================================================================
00062 // function : ~TransformationGUI()
00063 // purpose  : Destructor
00064 //=======================================================================
00065 TransformationGUI::~TransformationGUI()
00066 {
00067 }
00068 
00069 
00070 //=======================================================================
00071 // function : OnGUIEvent()
00072 // purpose  : 
00073 //=======================================================================
00074 bool TransformationGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
00075 {
00076   SalomeApp_Application* app = getGeometryGUI()->getApp();
00077   if ( !app ) return false;
00078 
00079   getGeometryGUI()->EmitSignalDeactivateDialog();
00080   QDialog* aDlg = NULL;
00081 
00082   switch ( theCommandID ) {
00083   case GEOMOp::OpTranslate:      // TRANSLATION
00084     aDlg = new TransformationGUI_TranslationDlg( getGeometryGUI(), parent );
00085     break;
00086   case GEOMOp::OpRotate:         // ROTATION
00087     aDlg = new TransformationGUI_RotationDlg( getGeometryGUI(), parent );
00088     break;
00089   case GEOMOp::OpChangeLoc:      // POSITION
00090     aDlg = new TransformationGUI_PositionDlg( getGeometryGUI(), parent );
00091     break;
00092   case GEOMOp::OpMirror:         // MIRROR
00093     aDlg = new TransformationGUI_MirrorDlg( getGeometryGUI(), parent );
00094     break;
00095   case GEOMOp::OpScale:          // SCALE
00096     aDlg = new TransformationGUI_ScaleDlg( getGeometryGUI(), parent );
00097     break;
00098   case GEOMOp::OpOffset:         // OFFSET
00099     aDlg = new TransformationGUI_OffsetDlg( getGeometryGUI(), parent );
00100     break;
00101   case GEOMOp::OpProjection:     // PROJECTION
00102     aDlg = new TransformationGUI_ProjectionDlg( getGeometryGUI(), parent );
00103     break;
00104   case GEOMOp::OpMultiTranslate: // MULTI TRANSLATION
00105     aDlg = new TransformationGUI_MultiTranslationDlg( getGeometryGUI(), parent );
00106     break;
00107   case GEOMOp::OpMultiRotate:    // MULTI ROTATION
00108     aDlg = new TransformationGUI_MultiRotationDlg( getGeometryGUI(), parent );
00109     break;
00110   case GEOMOp::OpReimport:       // RELOAD IMPORTED SHAPE
00111     {
00112       SalomeApp_Study* anAppStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
00113 
00114       GEOM::GEOM_ITransformOperations_var anOp =
00115         GeometryGUI::GetGeomGen()->GetITransformOperations(anAppStudy->id());
00116       if (anOp->_is_nil()) return false;
00117 
00118       GEOM_Displayer aDisp (anAppStudy);
00119       SUIT_Desktop* desk = app->desktop();
00120       QList<SUIT_ViewWindow*> wnds = desk->windows();
00121 
00122       LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
00123       SALOME_ListIO aSelList;
00124       aSelMgr->selectedObjects(aSelList);
00125 
00126       SALOME_ListIteratorOfListIO aSelIt (aSelList);
00127       for (; aSelIt.More(); aSelIt.Next()) {
00128         Handle(SALOME_InteractiveObject) io = aSelIt.Value();
00129         GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( io );
00130         if ( !CORBA::is_nil( aGeomObj ) ) {
00131           anOp->RecomputeObject(aGeomObj);
00132 
00133           SUIT_ViewWindow* wnd;
00134           QListIterator<SUIT_ViewWindow*> it (wnds);
00135           while (it.hasNext() && (wnd = it.next()))
00136           {
00137             if (SUIT_ViewManager* vman = wnd->getViewManager()) {
00138               if (SUIT_ViewModel* vmodel = vman->getViewModel()) {
00139                 if (SALOME_View* view = dynamic_cast<SALOME_View*>(vmodel)) {
00140                   if (view->isVisible(io)) {
00141                     aDisp.Erase(io, true, false, view);
00142                   getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer( getGeometryGUI()->getApp()->orb()->object_to_string( aGeomObj.in() ) );
00143                     aDisp.Display(io, true, view);
00144                   }
00145                   // ? Redisplay subshapes ?
00146                 }
00147               }
00148             }
00149           }
00150         }
00151       } // for (; aSelIt.More(); aSelIt.Next())
00152     }
00153     break;
00154   default:
00155     app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
00156     break;
00157   }
00158 
00159   if ( aDlg != NULL )
00160     aDlg->show();
00161 
00162   return true;
00163 }
00164 
00165 
00166 //=====================================================================================
00167 // EXPORTED METHODS
00168 //=====================================================================================
00169 extern "C"
00170 {
00171 #ifdef WNT
00172   __declspec( dllexport )
00173 #endif
00174   GEOMGUI* GetLibGUI( GeometryGUI* parent )
00175   {
00176     return new TransformationGUI( parent );
00177   }
00178 }