1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_TwoImagesOp.h"
25 #include "HYDROGUI_Module.h"
26 #include "HYDROGUI_TwoImagesDlg.h"
27 #include "HYDROGUI_UpdateFlags.h"
29 #include <HYDROData_Document.h>
30 #include <HYDROData_Image.h>
32 #include <HYDROOperations_Factory.h>
34 #include <ImageComposer_CutOperator.h>
35 #include <ImageComposer_FuseOperator.h>
37 HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
38 : HYDROGUI_Operation( theModule ),
44 case Fuse: aName = tr( "FUSE" ); break;
45 case Cut: aName = tr( "CUT" ); break;
51 HYDROGUI_TwoImagesOp::~HYDROGUI_TwoImagesOp()
55 HYDROGUI_InputPanel* HYDROGUI_TwoImagesOp::createInputPanel() const
57 return new HYDROGUI_TwoImagesDlg( module(), getName() );
60 bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags )
62 HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
64 QString aNewName = aPanel->GetName();
66 QString aName1, aName2;
67 aPanel->GetSelectedImages( aName1, aName2 );
69 if( aNewName.isEmpty() || aName1.isEmpty() || aName2.isEmpty() )
72 Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast(
73 FindObjectByName( aName1, KIND_IMAGE ) );
74 Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast(
75 FindObjectByName( aName2, KIND_IMAGE ) );
76 if( anImage1.IsNull() || anImage2.IsNull() )
79 HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
80 ImageComposer_Operator* anOperator = 0;
83 case Fuse: anOperator = new ImageComposer_FuseOperator(); break;
84 case Cut: anOperator = new ImageComposer_CutOperator(); break;
91 Handle(HYDROData_Image) aResult = aFactory->CreateImage( doc(), anOperator );
92 if( aResult.IsNull() )
95 aResult->SetName( aNewName );
96 aResult->AppendReference( anImage1 );
97 aResult->AppendReference( anImage2 );
98 aFactory->UpdateImage( doc(), aResult );
100 theUpdateFlags = UF_Model | UF_Viewer;