Salome HOME
projects
/
modules
/
hydro.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refs #550: fix crash when myObject is NULL
[modules/hydro.git]
/
src
/
HYDROGUI
/
HYDROGUI_TwoImagesOp.cxx
diff --git
a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
index d946766c8e1b781d66f2e304ed05fac26e6279b5..ab3bbb12803e0ca030191d966d29163696e85cd1 100644
(file)
--- a/
src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
+++ b/
src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx
@@
-1,12
+1,8
@@
-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
+// Copyright (C) 2014-2015 EDF-R&D
// 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
// 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.
+// version 2.1 of the License
, or (at your option) any later version
.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-26,17
+22,21
@@
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_TwoImagesDlg.h"
#include "HYDROGUI_UpdateFlags.h"
#include "HYDROGUI_Tool.h"
#include "HYDROGUI_TwoImagesDlg.h"
#include "HYDROGUI_UpdateFlags.h"
+#include <HYDROGUI_DataObject.h>
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
-#include <HYDROData_Polyline.h>
-#include <HYDRO
Operations_
Factory.h>
+#include <HYDRO
Data_Operations
Factory.h>
#include <ImageComposer_CutOperator.h>
#include <ImageComposer_CropOperator.h>
#include <ImageComposer_FuseOperator.h>
#include <ImageComposer_CutOperator.h>
#include <ImageComposer_CropOperator.h>
#include <ImageComposer_FuseOperator.h>
+#include <LightApp_Application.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_MessageBox.h>
+
HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule,
const int theType,
const bool theIsEdit )
HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule,
const int theType,
const bool theIsEdit )
@@
-72,15
+72,20
@@
void HYDROGUI_TwoImagesOp::startOperation()
HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
aPanel->reset();
HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
aPanel->reset();
- if( myType == Fuse || myType == Cut )
- aPanel->setMode( HYDROGUI_TwoImagesDlg::TwoImages, myIsEdit );
+ int aMode;
+ if( myType == Fuse )
+ aMode = HYDROGUI_TwoImagesDlg::TwoFuseImage;
+ if ( myType == Cut )
+ aMode = HYDROGUI_TwoImagesDlg::TwoCutImage;
else if( myType == Split )
else if( myType == Split )
- aPanel->setMode( HYDROGUI_TwoImagesDlg::ImageAndPolyline, myIsEdit );
+ aMode = HYDROGUI_TwoImagesDlg::ImageAndPolyline;
+ aPanel->setMode( aMode, myIsEdit );
QString anImageName;
if( myIsEdit )
{
QString anImageName;
if( myIsEdit )
{
- myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if ( isApplyAndClose() )
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
anImageName = myEditedObject->GetName();
}
if( !myEditedObject.IsNull() )
anImageName = myEditedObject->GetName();
}
@@
-103,19
+108,19
@@
void HYDROGUI_TwoImagesOp::startOperation()
{
if( myEditedObject->NbReferences() > 0 )
{
{
if( myEditedObject->NbReferences() > 0 )
{
- Handle(HYDROData_
Object
) anObject1 = myEditedObject->Reference( 0 );
+ Handle(HYDROData_
Entity
) anObject1 = myEditedObject->Reference( 0 );
if( !anObject1.IsNull() )
aSelectedName1 = anObject1->GetName();
}
if( myEditedObject->NbReferences() > 1 )
{
if( !anObject1.IsNull() )
aSelectedName1 = anObject1->GetName();
}
if( myEditedObject->NbReferences() > 1 )
{
- Handle(HYDROData_
Object
) anObject2 = myEditedObject->Reference( 1 );
+ Handle(HYDROData_
Entity
) anObject2 = myEditedObject->Reference( 1 );
if( !anObject2.IsNull() )
aSelectedName2 = anObject2->GetName();
}
aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 );
if( !anObject2.IsNull() )
aSelectedName2 = anObject2->GetName();
}
aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 );
- HYDRO
Operations_Factory* aFactory = HYDROOperations_
Factory::Factory();
+ HYDRO
Data_OperationsFactory* aFactory = HYDROData_Operations
Factory::Factory();
if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
{
QColor aColor;
if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
{
QColor aColor;
@@
-133,10
+138,19
@@
void HYDROGUI_TwoImagesOp::startOperation()
aPanel->setPreselectedObject( aSelectedName );
}
}
aPanel->setPreselectedObject( aSelectedName );
}
}
+ connect( aPanel, SIGNAL( alreadySelected( const QString& ) ), SLOT( onAlreadySelected( const QString& ) ) );
+}
+
+void HYDROGUI_TwoImagesOp::onAlreadySelected( const QString& theName )
+{
+ QString aTitle = tr( "INSUFFICIENT_INPUT_DATA" );
+ QString aMessage = tr( "OBJECT_ALREADY_SELECTED" ).arg( theName );
+ SUIT_MessageBox::critical( module()->getApp()->desktop(), aTitle, aMessage );
}
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
}
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
@@
-154,7
+168,7
@@
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) )
{
// check that there are no other objects with the same name in the document
( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) ) )
{
// check that there are no other objects with the same name in the document
- Handle(HYDROData_
Object
) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
+ Handle(HYDROData_
Entity
) anObject = HYDROGUI_Tool::FindObjectByName( module(), anImageName );
if( !anObject.IsNull() )
{
theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
if( !anObject.IsNull() )
{
theErrorMsg = tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( anImageName );
@@
-162,14
+176,14
@@
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
}
}
}
}
- Handle(HYDROData_
Object) anObject1 = Handle(HYDROData_Object)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN )
)
;
- Handle(HYDROData_
Object) anObject2 = Handle(HYDROData_Object)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN )
)
;
+ Handle(HYDROData_
Entity) anObject1 =
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_UNKNOWN ) ;
+ Handle(HYDROData_
Entity) anObject2 =
+ HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_UNKNOWN );
if( anObject1.IsNull() || anObject2.IsNull() )
return false;
if( anObject1.IsNull() || anObject2.IsNull() )
return false;
- HYDRO
Operations_Factory* aFactory = HYDROOperations_
Factory::Factory();
+ HYDRO
Data_OperationsFactory* aFactory = HYDROData_Operations
Factory::Factory();
Handle(HYDROData_Image) aResult;
ImageComposer_Operator* anOperator = 0;
Handle(HYDROData_Image) aResult;
ImageComposer_Operator* anOperator = 0;
@@
-193,6
+207,8
@@
bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags,
anOperator = aFactory->Operator( anOperatorName );
aResult = aFactory->CreateImage( doc(), anOperator );
anOperator = aFactory->Operator( anOperatorName );
aResult = aFactory->CreateImage( doc(), anOperator );
+ QString anEntry = HYDROGUI_DataObject::dataObjectEntry( aResult );
+ theBrowseObjectsEntries.append( anEntry );
}
if( aResult.IsNull() || !anOperator )
}
if( aResult.IsNull() || !anOperator )