]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
Salome HOME
f91ca6cb342fd8f5629efcaa5b15a97198a72031
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_TwoImagesOp.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_TwoImagesOp.h"
24
25 #include "HYDROGUI_TwoImagesDlg.h"
26
27 #include <HYDROData_Document.h>
28 #include <HYDROData_Image.h>
29
30 #include <HYDROOperations_Factory.h>
31
32 HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
33 : HYDROGUI_Operation( theModule ),
34   myType( theType )
35 {
36   QString aName;
37   switch( myType )
38   {
39     case Fuse: aName = tr( "FUSE" ); break;
40     case Cut: aName = tr( "CUT" ); break;
41   }
42   setName( aName );
43 }
44
45 HYDROGUI_TwoImagesOp::~HYDROGUI_TwoImagesOp()
46 {
47 }
48
49 HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const
50 {
51   return new HYDROGUI_TwoImagesDlg( module(), getName() );
52 }
53
54 void HYDROGUI_TwoImagesOp::onApply()
55 {
56   HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
57   QString aName1, aName2;
58   aPanel->GetSelectedImages( aName1, aName2 );
59
60   Handle_HYDROData_Image anImage1 = Handle_HYDROData_Image::DownCast(
61     FindObjectByName( aName1, KIND_IMAGE ) );
62   Handle_HYDROData_Image anImage2 = Handle_HYDROData_Image::DownCast(
63     FindObjectByName( aName2, KIND_IMAGE ) );
64
65   HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
66   ImageComposer_Operator* anOperator = 0; //TODO
67
68   Handle(HYDROData_Image) aResult = aFactory->CreateImage( doc(), anOperator );
69   aResult->AppendReference( anImage1 );
70   aResult->AppendReference( anImage2 );
71   aFactory->UpdateImage( doc(), aResult );
72 }