#include <QStringList>
static const Standard_GUID GUID_MUST_BE_UPDATED("80f2bb81-3873-4631-8ddd-940d2119f000");
+static const Standard_GUID GUID_SELF_SPLITTED("997995aa-5c19-40bf-9a60-ab4b70ad04d8");
#define PYTHON_IMAGE_ID "1"
for ( int i = 0; i < aNbReferences; ++i )
{
- Handle(HYDROData_Image) aRefImg = Reference( i );
+ Handle(HYDROData_Image) aRefImg = Handle(HYDROData_Image)::DownCast( Reference( i ) );
if ( aRefImg.IsNull() )
continue;
}
}
-void HYDROData_Image::AppendReference(Handle(HYDROData_Image) theReferenced)
+bool HYDROData_Image::HasTrsfPoints() const
+{
+ Handle(TDataStd_RealArray) anArray;
+ return myLab.FindChild(DataTag_TrsfPoints).FindAttribute(TDataStd_RealArray::GetID(), anArray);
+}
+
+void HYDROData_Image::AppendReference(Handle(HYDROData_Object) theReferenced)
{
Handle(TDataStd_ReferenceList) aRefs;
if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
return aRefs->Extent();
}
-Handle(HYDROData_Image) HYDROData_Image::Reference(const int theIndex) const
+Handle(HYDROData_Object) HYDROData_Image::Reference(const int theIndex) const
{
Handle(TDataStd_ReferenceList) aRefs;
if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
- return Handle(HYDROData_Image)();
+ return Handle(HYDROData_Object)();
if (theIndex < 0 || theIndex >= aRefs->Extent())
- return Handle(HYDROData_Image)();
+ return Handle(HYDROData_Object)();
TDF_ListIteratorOfLabelList anIter(aRefs->List());
for(int anIndex = 0; anIndex != theIndex; anIter.Next(), anIndex++);
const TDF_Label& aRefLab = anIter.Value();
- return Handle(HYDROData_Image)::DownCast(HYDROData_Iterator::Object(aRefLab));
+ return Handle(HYDROData_Object)::DownCast(HYDROData_Iterator::Object(aRefLab));
}
void HYDROData_Image::ChangeReference(
- const int theIndex, Handle(HYDROData_Image) theReferenced)
+ const int theIndex, Handle(HYDROData_Object) theReferenced)
{
Handle(TDataStd_ReferenceList) aRefs;
if (!myLab.FindAttribute(TDataStd_ReferenceList::GetID(), aRefs))
}
}
-bool HYDROData_Image::MustBeUpdated()
+bool HYDROData_Image::MustBeUpdated() const
{
return myLab.IsAttribute(GUID_MUST_BE_UPDATED);
}
+
+void HYDROData_Image::SetIsSelfSplitted(bool theFlag)
+{
+ if (theFlag) {
+ TDataStd_UAttribute::Set(myLab, GUID_SELF_SPLITTED);
+ } else {
+ myLab.ForgetAttribute(GUID_SELF_SPLITTED);
+ }
+}
+
+bool HYDROData_Image::IsSelfSplitted() const
+{
+ return myLab.IsAttribute(GUID_SELF_SPLITTED);
+}
QPointF& thePointBOut,
QPointF& thePointCOut) const;
+ HYDRODATA_EXPORT bool HasTrsfPoints() const;
+
/**
- * Appends reference to other image.
- * \param theReferenced the image referenced by this
+ * Appends reference to other object (image or polyline).
+ * \param theReferenced the object referenced by this
*/
- HYDRODATA_EXPORT void AppendReference(Handle(HYDROData_Image) theReferenced);
+ HYDRODATA_EXPORT void AppendReference(Handle(HYDROData_Object) theReferenced);
/**
- * Returns the number of referenced images
+ * Returns the number of referenced objects
* \return zero if there is no references
*/
HYDRODATA_EXPORT int NbReferences() const;
/**
* Returns reference by index.
* \param theIndex number of reference [0; NbReference)
- * \returns the referenced image, or Null if index is invalid
+ * \returns the referenced object, or Null if index is invalid
*/
- HYDRODATA_EXPORT Handle(HYDROData_Image) Reference(const int theIndex) const;
+ HYDRODATA_EXPORT Handle(HYDROData_Object) Reference(const int theIndex) const;
/**
* Updates reference by index. If index is one-bigger than \a NbReferences,
* this method appends it to the end (NbReferences is incremented).
* \param theIndex number of reference [0; NbReference]
- * \param theReferenced the image referenced by this
+ * \param theReferenced the object referenced by this
*/
HYDRODATA_EXPORT void ChangeReference(
- const int theIndex, Handle(HYDROData_Image) theReferenced);
+ const int theIndex, Handle(HYDROData_Object) theReferenced);
/**
* Removes reference by index
* Returns the "MustBeUpdated" flag: is image must be recomputed or not
* \returns false if image is up to date
*/
- HYDRODATA_EXPORT bool MustBeUpdated();
+ HYDRODATA_EXPORT bool MustBeUpdated() const;
+
+ /**
+ * Marks the image as self-splitted.
+ * \param theFlag is true for self-splitted image
+ */
+ HYDRODATA_EXPORT void SetIsSelfSplitted(bool theFlag);
+
+ /**
+ * Checks that the image is self-splitted.
+ * \returns true if image is self-splitted
+ */
+ HYDRODATA_EXPORT bool IsSelfSplitted() const;
protected:
{
QPainterPath aPath;
int aDim = getDimension();
- if( ( aDim != 2 ) || ( aDim != 3) )
+ if( ( aDim != 2 ) && ( aDim != 3) )
return aPath;
QList<PolylineSection> aSects = getPolylineData();
- for( int i = 0 ; aSects.size() ; i++ ){
+ for( int i = 0 ; i < aSects.size() ; i++ ){
int aPntCnt = aSects[i].myCoords.size()/aDim;
if( aPntCnt ){
aPath.moveTo(aSects[i].myCoords[0], aSects[i].myCoords[1] );
QTransform aTransform;
ImageComposer_Image anImage1; // first referenced image
if (theImage->NbReferences()) {
- Handle(HYDROData_Image) anImage = theImage->Reference(0);
- anImage1 = anImage->Image();
- anImage1.setTransform(anImage->Trsf());
- aTransform = anImage1.transform();
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast( theImage->Reference(0) );
+ if( !anImage.IsNull() )
+ {
+ anImage1 = anImage->Image();
+ anImage1.setTransform(anImage->Trsf());
+ aTransform = anImage1.transform();
+ }
}
ImageComposer_Image anImage2; // second referenced image
if (theImage->NbReferences() > 1) {
- Handle(HYDROData_Image) anImage = theImage->Reference(1);
- anImage2 = anImage->Image();
- anImage2.setTransform(anImage->Trsf());
+ Handle(HYDROData_Image) anImage =
+ Handle(HYDROData_Image)::DownCast( theImage->Reference(1) );
+ if( !anImage.IsNull() )
+ {
+ anImage2 = anImage->Image();
+ anImage2.setTransform(anImage->Trsf());
+ }
}
ImageComposer_Image aResImg = anOp->process(anImage1, anImage2);
theImage->SetImage(aResImg);
if (!anImage->MustBeUpdated()) {
int a, aNBRefs = anImage->NbReferences();
for(a = 0; a < aNBRefs; a++) {
- if (anImage->Reference(a)->MustBeUpdated()) {
+ Handle(HYDROData_Image) aRefImage =
+ Handle(HYDROData_Image)::DownCast(anImage->Reference(a));
+ if (!aRefImage.IsNull() && aRefImage->MustBeUpdated()) {
// image references to updated => also must be updated
anImage->MustBeUpdated(true);
aChanged = true;
{
for( int anIndex = 0, aNbRef = anImageObj->NbReferences(); anIndex < aNbRef; anIndex++ )
{
- Handle(HYDROData_Image) aRefImageObj = anImageObj->Reference( anIndex );
- if( !aRefImageObj.IsNull() && !aRefImageObj->IsRemoved() )
- createObject( anImageDataObj, aRefImageObj, anImageDataObj->entry() );
+ Handle(HYDROData_Object) aRefObj = anImageObj->Reference( anIndex );
+ if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
+ createObject( anImageDataObj, aRefObj, anImageDataObj->entry() );
}
}
}
#include <HYDROData_Image.h>
+#include <HYDROOperations_Factory.h>
+
#include <GraphicsView_ViewFrame.h>
#include <GraphicsView_ViewManager.h>
#include <GraphicsView_ViewPort.h>
#include <GraphicsView_Viewer.h>
+#include <ImageComposer_CutOperator.h>
+#include <ImageComposer_CropOperator.h>
+#include <ImageComposer_FuseOperator.h>
+
#include <LightApp_Application.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
bool anIsHiddenInSelection = false;
bool anIsImage = false;
+ bool anIsImportedImage = false;
bool anIsCompositeImage = false;
+ bool anIsFusedImage = false;
+ bool anIsCutImage = false;
+ bool anIsSplittedImage = false;
bool anIsMustBeUpdatedImage = false;
bool anIsPolyline = false;
bool anIsVisualState = false;
Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
if( !anImage.IsNull() )
{
+ anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
anIsCompositeImage = anImage->NbReferences() > 0;
+ if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
+ {
+ if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
+ {
+ if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
+ anIsFusedImage = true;
+ else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
+ anIsCutImage = true;
+ else if( dynamic_cast<ImageComposer_CropOperator*>( anOperator ) )
+ anIsSplittedImage = true;
+ }
+ }
anIsMustBeUpdatedImage = anImage->MustBeUpdated();
}
}
{
if( anIsImage )
{
- theMenu->addAction( action( anIsCompositeImage ? EditCompositeImageId : EditImportedImageId ) );
+ if( anIsImportedImage )
+ theMenu->addAction( action( EditImportedImageId ) );
+ else if( anIsCompositeImage )
+ {
+ if( anIsFusedImage )
+ theMenu->addAction( action( EditFusedImageId ) );
+ else if( anIsCutImage )
+ theMenu->addAction( action( EditCutImageId ) );
+ else if( anIsSplittedImage )
+ theMenu->addAction( action( EditSplittedImageId ) );
+ }
+
theMenu->addAction( action( ObserveImageId ) );
theMenu->addAction( action( ExportImageId ) );
theMenu->addSeparator();
#include <QLineEdit>
#include <QToolButton>
-HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent )
-: QAbstractButton( theParent ), myModule( theModule )
+HYDROGUI_ObjSelector::HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
+ const ObjectKind theObjectKind,
+ QWidget* theParent )
+: QAbstractButton( theParent ),
+ myObjectKind( theObjectKind ),
+ myModule( theModule )
{
QHBoxLayout* aLayout = new QHBoxLayout( this );
aLayout->setMargin( 0 );
QString anObjName;
Handle(HYDROData_Object) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
if( !anObject.IsNull() )
- anObjName = anObject->GetName();
+ if( myObjectKind == KIND_UNKNOWN || myObjectKind == anObject->GetKind() )
+ anObjName = anObject->GetName();
SetName( anObjName );
}
#ifndef HYDROGUI_OBJSELECTOR_H
#define HYDROGUI_OBJSELECTOR_H
+#include <HYDROData_Object.h>
+
#include <QAbstractButton>
class QToolButton;
Q_OBJECT
public:
- HYDROGUI_ObjSelector( HYDROGUI_Module* theModule, QWidget* theParent );
+ HYDROGUI_ObjSelector( HYDROGUI_Module* theModule,
+ const ObjectKind theObjectKind,
+ QWidget* theParent );
virtual ~HYDROGUI_ObjSelector();
void Clear();
private:
HYDROGUI_Module* myModule;
+ ObjectKind myObjectKind;
+
QToolButton* myBtn;
QLineEdit* myObjName;
};
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE" );
- createAction( EditCompositeImageId, "EDIT_COMPOSITE_IMAGE" );
createAction( ObserveImageId, "OBSERVE_IMAGE" );
createAction( ExportImageId, "EXPORT_IMAGE" );
createAction( UpdateImageId, "UPDATE_IMAGE" );
createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "", Qt::CTRL + Qt::SHIFT + Qt::Key_I );
- createAction( FuseId, "FUSE_IMAGES" );
- createAction( CutId, "CUT_IMAGES" );
+ createAction( FuseImagesId, "FUSE_IMAGES" );
+ createAction( EditFusedImageId, "EDIT_FUSED_IMAGE" );
+
+ createAction( CutImagesId, "CUT_IMAGES" );
+ createAction( EditCutImageId, "EDIT_CUT_IMAGE" );
+
+ createAction( SplitImageId, "SPLIT_IMAGE" );
+ createAction( EditSplittedImageId, "EDIT_SPLITTED_IMAGE" );
createAction( DeleteId, "DELETE", "", Qt::Key_Delete );
createMenu( ImportImageId, aHydroId, -1, -1 );
createMenu( ImportBathymetryId, aHydroId, -1, -1 );
createMenu( CreatePolylineId, aHydroId, -1, -1 );
- createMenu( FuseId, aHydroId, -1, -1 );
- createMenu( CutId, aHydroId, -1, -1 );
+ createMenu( FuseImagesId, aHydroId, -1, -1 );
+ createMenu( CutImagesId, aHydroId, -1, -1 );
+ createMenu( SplitImageId, aHydroId, -1, -1 );
}
void HYDROGUI_Module::createPopups()
case EditPolylineId:
anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
break;
- case FuseId:
- anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse );
+ case ImportBathymetryId:
+ anOp = new HYDROGUI_ImportBathymetryOp( aModule );
break;
- case CutId:
- anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut );
+ case FuseImagesId:
+ case EditFusedImageId:
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
break;
- case EditCompositeImageId:
- anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Edit );
+ case CutImagesId:
+ case EditCutImageId:
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
break;
- case ImportBathymetryId:
- anOp = new HYDROGUI_ImportBathymetryOp( aModule );
+ case SplitImageId:
+ case EditSplittedImageId:
+ anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplittedImageId );
break;
case DeleteId:
anOp = new HYDROGUI_DeleteOp( aModule );
ImportImageId,
EditImportedImageId,
- EditCompositeImageId,
ObserveImageId,
ExportImageId,
UpdateImageId,
ImportBathymetryId,
EditImportedBathymetryId,
- FuseId,
- CutId,
+ FuseImagesId,
+ EditFusedImageId,
+
+ CutImagesId,
+ EditCutImageId,
+
+ SplitImageId,
+ EditSplittedImageId,
+
DeleteId,
ShowId,
for( int anIndex = 0, aNbRef = theImage->NbReferences(); anIndex < aNbRef; anIndex++ )
{
- Handle(HYDROData_Image) aRefImage = theImage->Reference( anIndex );
- if( !aRefImage.IsNull() && !aRefImage->IsRemoved() )
+ Handle(HYDROData_Object) aRefObj = theImage->Reference( anIndex );
+ if( !aRefObj.IsNull() && !aRefObj->IsRemoved() )
{
- QString aName = aRefImage->GetName();
+ QString aName = aRefObj->GetName();
if( !theRefNames.contains( aName ) )
{
- theRefObjects.Append( aRefImage );
- theRefNames.append( aRefImage->GetName() );
- GetObjectReferences( aRefImage, theRefObjects, theRefNames );
+ theRefObjects.Append( aRefObj );
+ theRefNames.append( aRefObj->GetName() );
+ if( aRefObj->GetKind() == KIND_IMAGE )
+ {
+ Handle(HYDROData_Image) aRefImage = Handle(HYDROData_Image)::DownCast( aRefObj );
+ if( !aRefImage.IsNull() )
+ GetObjectReferences( aRefImage, theRefObjects, theRefNames );
+ }
}
}
}
#include "HYDROGUI_ColorWidget.h"
#include "HYDROGUI_ObjSelector.h"
+#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <QLayout>
#include <QRadioButton>
HYDROGUI_TwoImagesDlg::HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ),
+ myMode( TwoImages ),
+ myIsEdit( false )
{
// Image name
QGroupBox* anImageNameGroup = new QGroupBox( tr( "IMAGE_NAME" ) );
QLabel* anImageNameLabel = new QLabel( tr( "NAME" ), anImageNameGroup );
myImageName = new QLineEdit( anImageNameGroup );
- QBoxLayout* anImageNameLayout = new QHBoxLayout( anImageNameGroup );
+ myModifySelectedImage = new QCheckBox( tr( "MODIFY_SELECTED_IMAGE" ) );
+
+ QGridLayout* anImageNameLayout = new QGridLayout( anImageNameGroup );
anImageNameLayout->setMargin( 5 );
anImageNameLayout->setSpacing( 5 );
- anImageNameLayout->addWidget( anImageNameLabel );
- anImageNameLayout->addWidget( myImageName );
+ anImageNameLayout->addWidget( anImageNameLabel, 0, 0 );
+ anImageNameLayout->addWidget( myImageName, 0, 1 );
+ anImageNameLayout->addWidget( myModifySelectedImage, 1, 0, 1, 2 );
- // Image name
+ // Parameters
QGroupBox* aParamGroup = new QGroupBox( tr( "PARAMETERS" ) );
- QLabel* anImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup );
- myImage1 = new HYDROGUI_ObjSelector( theModule, aParamGroup );
+ myImage1Label = new QLabel( tr( "IMAGE_1" ), aParamGroup );
+ myImage1 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup );
+
+ myImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup );
+ myImage2 = new HYDROGUI_ObjSelector( theModule, KIND_IMAGE, aParamGroup );
- QLabel* anImage2Label = new QLabel( tr( "IMAGE_2" ), aParamGroup );
- myImage2 = new HYDROGUI_ObjSelector( theModule, aParamGroup );
+ myPolylineLabel = new QLabel( tr( "POLYLINE" ), aParamGroup );
+ myPolyline = new HYDROGUI_ObjSelector( theModule, KIND_POLYLINE, aParamGroup );
QFrame* aBackgroundFrame = new QFrame( aParamGroup );
QLabel* aBackgroundLabel = new QLabel( tr( "BACKGROUND" ), aBackgroundFrame );
QGridLayout* aParamLayout = new QGridLayout( aParamGroup );
aParamLayout->setMargin( 5 );
aParamLayout->setSpacing( 5 );
- aParamLayout->addWidget( anImage1Label, 0, 0 );
+ aParamLayout->addWidget( myImage1Label, 0, 0 );
aParamLayout->addWidget( myImage1, 0, 1 );
- aParamLayout->addWidget( anImage2Label, 1, 0 );
+ aParamLayout->addWidget( myImage2Label, 1, 0 );
aParamLayout->addWidget( myImage2, 1, 1 );
+ aParamLayout->addWidget( myPolylineLabel, 1, 0 );
+ aParamLayout->addWidget( myPolyline, 1, 1 );
aParamLayout->addWidget( aBackgroundFrame, 2, 0, 1, 2 );
// Common
addWidget( anImageNameGroup );
addWidget( aParamGroup );
addStretch();
+
+ connect( myModifySelectedImage, SIGNAL( toggled( bool ) ),
+ this, SLOT( onModifySelectedImage( bool ) ) );
+
+ setMode( myMode, myIsEdit );
}
HYDROGUI_TwoImagesDlg::~HYDROGUI_TwoImagesDlg()
void HYDROGUI_TwoImagesDlg::reset()
{
myImageName->clear();
+ myModifySelectedImage->setChecked( false );
myImage1->Clear();
myImage2->Clear();
+ myPolyline->Clear();
myTransparent->setChecked( true );
myColorBox->resetColor();
}
+void HYDROGUI_TwoImagesDlg::setMode( const int theMode, const bool theIsEdit )
+{
+ myMode = theMode;
+ myIsEdit = theIsEdit;
+
+ bool anIsTwoImages = myMode == TwoImages;
+
+ myModifySelectedImage->setVisible( !anIsTwoImages && !myIsEdit );
+
+ myImage1Label->setText( anIsTwoImages ? tr( "IMAGE_1" ) : tr( "IMAGE" ) );
+
+ myImage2Label->setVisible( anIsTwoImages );
+ myImage2->setVisible( anIsTwoImages );
+ myPolylineLabel->setVisible( !anIsTwoImages );
+ myPolyline->setVisible( !anIsTwoImages );
+}
+
+bool HYDROGUI_TwoImagesDlg::isModifySelected() const
+{
+ return myModifySelectedImage->isChecked();
+}
+
void HYDROGUI_TwoImagesDlg::setImageName( const QString& theName )
{
myImageName->setText( theName );
return myImageName->text();
}
-void HYDROGUI_TwoImagesDlg::setSelectedImages( const QString& theName1,
- const QString& theName2 )
+void HYDROGUI_TwoImagesDlg::setSelectedObjects( const QString& theName1,
+ const QString& theName2 )
{
myImage1->SetName( theName1 );
- myImage2->SetName( theName2 );
+ if( myMode == TwoImages )
+ myImage2->SetName( theName2 );
+ else
+ myPolyline->SetName( theName2 );
}
-bool HYDROGUI_TwoImagesDlg::getSelectedImages( QString& theName1,
- QString& theName2 ) const
+bool HYDROGUI_TwoImagesDlg::getSelectedObjects( QString& theName1,
+ QString& theName2 ) const
{
theName1 = myImage1->GetName();
- theName2 = myImage2->GetName();
+ if( myMode == TwoImages )
+ theName2 = myImage2->GetName();
+ else
+ theName2 = myPolyline->GetName();
return !theName1.isEmpty() && !theName2.isEmpty();
}
aColor = myColorBox->color();
return aColor;
}
+
+void HYDROGUI_TwoImagesDlg::onModifySelectedImage( bool theState )
+{
+ myImageName->setEnabled( !theState );
+}
#include "HYDROGUI_InputPanel.h"
+class QCheckBox;
+class QLabel;
class QLineEdit;
class QRadioButton;
{
Q_OBJECT
+public:
+ enum Mode { TwoImages = 0, ImageAndPolyline };
+
public:
HYDROGUI_TwoImagesDlg( HYDROGUI_Module* theModule, const QString& theTitle );
virtual ~HYDROGUI_TwoImagesDlg();
void reset();
+ void setMode( const int theMode, const bool theIsEdit );
+
+ bool isModifySelected() const;
+
void setImageName( const QString& theName );
QString getImageName() const;
- void setSelectedImages( const QString& theName1,
- const QString& theName2 );
- bool getSelectedImages( QString& theName1,
- QString& theName2 ) const;
+ void setSelectedObjects( const QString& theName1,
+ const QString& theName2 );
+ bool getSelectedObjects( QString& theName1,
+ QString& theName2 ) const;
void setColor( const QColor& theColor );
QColor getColor() const;
+protected slots:
+ void onModifySelectedImage( bool theState );
+
private:
+ int myMode;
+ bool myIsEdit;
+
QLineEdit* myImageName;
+ QCheckBox* myModifySelectedImage;
+
+ QLabel* myImage1Label;
HYDROGUI_ObjSelector* myImage1;
+
+ QLabel* myImage2Label;
HYDROGUI_ObjSelector* myImage2;
+
+ QLabel* myPolylineLabel;
+ HYDROGUI_ObjSelector* myPolyline;
+
QRadioButton* myTransparent;
QRadioButton* myColor;
HYDROGUI_ColorWidget* myColorBox;
#include <HYDROData_Document.h>
#include <HYDROData_Image.h>
+#include <HYDROData_Polyline.h>
#include <HYDROOperations_Factory.h>
#include <ImageComposer_CutOperator.h>
+#include <ImageComposer_CropOperator.h>
#include <ImageComposer_FuseOperator.h>
-HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType )
+HYDROGUI_TwoImagesOp::HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule,
+ const int theType,
+ const bool theIsEdit )
: HYDROGUI_Operation( theModule ),
myType( theType ),
- myIsEdit( false ),
+ myIsEdit( theIsEdit ),
myEditedObject( 0 )
{
- if( myType == Edit )
- {
- myIsEdit = true;
- myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
- if( !myEditedObject.IsNull() )
- {
- if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
- {
- if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
- {
- if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
- myType = Fuse;
- else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
- myType = Cut;
- }
- }
- }
- }
-
QString aName;
switch( myType )
{
- case Fuse: aName = tr( "FUSE" ); break;
- case Cut: aName = tr( "CUT" ); break;
+ case Fuse: aName = theIsEdit ? tr( "EDIT_FUSED_IMAGE" ) : tr( "FUSE_IMAGES" ); break;
+ case Cut: aName = theIsEdit ? tr( "EDIT_CUT_IMAGE" ) : tr( "CUT_IMAGES" ); break;
+ case Split: aName = theIsEdit ? tr( "EDIT_SPLITTED_IMAGE" ) : tr( "SPLIT_IMAGE" ); break;
default: break;
}
setName( aName );
HYDROGUI_TwoImagesDlg* aPanel = (HYDROGUI_TwoImagesDlg*)inputPanel();
aPanel->reset();
+ if( myType == Fuse || myType == Cut )
+ aPanel->setMode( HYDROGUI_TwoImagesDlg::TwoImages, myIsEdit );
+ else if( myType == Split )
+ aPanel->setMode( HYDROGUI_TwoImagesDlg::ImageAndPolyline, myIsEdit );
+
QString anImageName;
if( myIsEdit )
{
+ myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
if( !myEditedObject.IsNull() )
anImageName = myEditedObject->GetName();
}
else
- anImageName = HYDROGUI_Tool::GenerateObjectName( module(), getName() );
+ {
+ QString aPrefix;
+ switch( myType )
+ {
+ case Fuse: aPrefix = tr( "FUSE" ); break;
+ case Cut: aPrefix = tr( "CUT" ); break;
+ case Split: aPrefix = tr( "SPLIT" ); break;
+ default: break;
+ }
+ anImageName = HYDROGUI_Tool::GenerateObjectName( module(), aPrefix );
+ }
aPanel->setImageName( anImageName );
QString aSelectedName1, aSelectedName2;
{
if( myEditedObject->NbReferences() > 0 )
{
- Handle(HYDROData_Image) anImage1 = myEditedObject->Reference( 0 );
- if( !anImage1.IsNull() )
- aSelectedName1 = anImage1->GetName();
+ Handle(HYDROData_Object) anObject1 = myEditedObject->Reference( 0 );
+ if( !anObject1.IsNull() )
+ aSelectedName1 = anObject1->GetName();
}
if( myEditedObject->NbReferences() > 1 )
{
- Handle(HYDROData_Image) anImage2 = myEditedObject->Reference( 1 );
- if( !anImage2.IsNull() )
- aSelectedName2 = anImage2->GetName();
+ Handle(HYDROData_Object) anObject2 = myEditedObject->Reference( 1 );
+ if( !anObject2.IsNull() )
+ aSelectedName2 = anObject2->GetName();
}
- aPanel->setSelectedImages( aSelectedName1, aSelectedName2 );
+ aPanel->setSelectedObjects( aSelectedName1, aSelectedName2 );
HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
if( ImageComposer_Operator* anOperator = aFactory->Operator( myEditedObject ) )
{
HYDROGUI_TwoImagesDlg* aPanel = dynamic_cast<HYDROGUI_TwoImagesDlg*>( inputPanel() );
+ bool anIsModifySelected = myType == Split && aPanel->isModifySelected();
+
QString anImageName = aPanel->getImageName();
- if( anImageName.isEmpty() )
+ if( !anIsModifySelected && anImageName.isEmpty() )
return false;
QString aSelectedName1, aSelectedName2;
- if( !aPanel->getSelectedImages( aSelectedName1, aSelectedName2 ) )
+ if( !aPanel->getSelectedObjects( aSelectedName1, aSelectedName2 ) )
return false;
- if( !myIsEdit || ( !myEditedObject.IsNull() && myEditedObject->GetName() != anImageName ) )
+ if( !anIsModifySelected &&
+ ( !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_Image) anImage1 = Handle(HYDROData_Image)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aSelectedName1, KIND_IMAGE ) );
- Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast(
- HYDROGUI_Tool::FindObjectByName( module(), aSelectedName2, KIND_IMAGE ) );
- if( anImage1.IsNull() || anImage2.IsNull() )
+ 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 ) );
+ if( anObject1.IsNull() || anObject2.IsNull() )
return false;
HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory();
{
case Fuse: anOperator = new ImageComposer_FuseOperator(); break;
case Cut: anOperator = new ImageComposer_CutOperator(); break;
+ case Split: anOperator = new ImageComposer_CropOperator(); break;
default: break;
}
return false;
aResult->SetName( anImageName );
- aResult->AppendReference( anImage1 );
- aResult->AppendReference( anImage2 );
+ aResult->AppendReference( anObject1 );
+ aResult->AppendReference( anObject2 );
+ // Setting the operator arguments (probably, it should be done somewhere else).
+ // For Fuse and Cut operators: setting background color.
+ // For Crop operator: setting background color and polyline path to crop.
if( ImageComposer_Operator* anOperator = aFactory->Operator( aResult ) )
{
- anOperator->setArgs( aPanel->getColor() );
+ if( ImageComposer_CropOperator* aCropOperator =
+ dynamic_cast<ImageComposer_CropOperator*>( anOperator ) )
+ {
+ Handle(HYDROData_Polyline) aPolyline = Handle(HYDROData_Polyline)::DownCast( anObject2 );
+ if( !aPolyline.IsNull() )
+ aCropOperator->setArgs( aPanel->getColor(), aPolyline->painterPath() );
+ }
+ else
+ anOperator->setArgs( aPanel->getColor() );
aResult->SetArgs( anOperator->getBinArgs() );
}
aFactory->UpdateImage( doc(), aResult );
- if( !myIsEdit )
+ if( anIsModifySelected )
+ {
+ Handle(HYDROData_Image) aSelectedImage = Handle(HYDROData_Image)::DownCast( anObject1 );
+ if( !aSelectedImage.IsNull() )
+ {
+ aSelectedImage->SetIsSelfSplitted( true );
+ aSelectedImage->SetImage( aResult->Image() );
+ aSelectedImage->SetTrsf( aResult->Trsf() );
+ aResult->Remove();
+ }
+ }
+
+ if( !myIsEdit && !anIsModifySelected )
{
size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( module() );
- module()->setObjectVisible( aViewId, anImage1, false );
- module()->setObjectVisible( aViewId, anImage2, false );
+ module()->setObjectVisible( aViewId, anObject1, false );
+ module()->setObjectVisible( aViewId, anObject2, false );
module()->setObjectVisible( aViewId, aResult, true );
}
Q_OBJECT
public:
- enum OperationType { Fuse, Cut, Edit };
+ enum OperationType { Fuse, Cut, Split };
public:
- HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType );
+ HYDROGUI_TwoImagesOp( HYDROGUI_Module* theModule, const int theType, const bool theIsEdit );
virtual ~HYDROGUI_TwoImagesOp();
protected:
<translation>Delete</translation>
</message>
<message>
- <source>DSK_EDIT_COMPOSITE_IMAGE</source>
- <translation>Edit composite image</translation>
+ <source>DSK_EDIT_CUT_IMAGE</source>
+ <translation>Edit cut image</translation>
+ </message>
+ <message>
+ <source>DSK_EDIT_FUSED_IMAGE</source>
+ <translation>Edit fused image</translation>
</message>
<message>
<source>DSK_EDIT_IMPORTED_IMAGE</source>
<source>DSK_EDIT_POLYLINE</source>
<translation>Edit polyline</translation>
</message>
+ <message>
+ <source>DSK_EDIT_SPLITTED_IMAGE</source>
+ <translation>Edit splitted image</translation>
+ </message>
<message>
<source>DSK_EXPORT_IMAGE</source>
<translation>Export image</translation>
<source>DSK_SHOW_ONLY</source>
<translation>Show only</translation>
</message>
+ <message>
+ <source>DSK_SPLIT_IMAGE</source>
+ <translation>Split image</translation>
+ </message>
<message>
<source>DSK_UNDO</source>
<translation>Undo</translation>
<translation>HYDRO</translation>
</message>
<message>
- <source>MEN_EDIT_COMPOSITE_IMAGE</source>
- <translation>Edit composite image</translation>
+ <source>MEN_EDIT_CUT_IMAGE</source>
+ <translation>Edit cut image</translation>
+ </message>
+ <message>
+ <source>MEN_EDIT_FUSED_IMAGE</source>
+ <translation>Edit fused image</translation>
</message>
<message>
<source>MEN_EDIT_IMPORTED_IMAGE</source>
<source>MEN_EDIT_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>MEN_EDIT_SPLITTED_IMAGE</source>
+ <translation>Edit splitted image</translation>
+ </message>
<message>
<source>MEN_EXPORT_IMAGE</source>
<translation>Export image</translation>
<source>MEN_SHOW_ONLY</source>
<translation>Show only</translation>
</message>
+ <message>
+ <source>MEN_SPLIT_IMAGE</source>
+ <translation>Split image</translation>
+ </message>
<message>
<source>MEN_UNDO</source>
<translation>Undo</translation>
<translation>Delete</translation>
</message>
<message>
- <source>STB_EDIT_COMPOSITE_IMAGE</source>
- <translation>Edit composite image</translation>
+ <source>STB_EDIT_CUT_IMAGE</source>
+ <translation>Edit cut image</translation>
+ </message>
+ <message>
+ <source>STB_EDIT_FUSED_IMAGE</source>
+ <translation>Edit fused image</translation>
</message>
<message>
<source>STB_EDIT_IMPORTED_IMAGE</source>
<source>STB_EDIT_POLYLINE</source>
<translation>Edit polyline</translation>
</message>
+ <message>
+ <source>STB_EDIT_SPLITTED_IMAGE</source>
+ <translation>Edit splitted image</translation>
+ </message>
<message>
<source>STB_EXPORT_IMAGE</source>
<translation>Export image</translation>
<source>STB_SHOW_ONLY</source>
<translation>Show only</translation>
</message>
+ <message>
+ <source>STB_SPLIT_IMAGE</source>
+ <translation>Split image</translation>
+ </message>
<message>
<source>STB_UNDO</source>
<translation>Undo</translation>
<source>COLOR</source>
<translation>Color</translation>
</message>
+ <message>
+ <source>IMAGE</source>
+ <translation>Image</translation>
+ </message>
<message>
<source>IMAGE_1</source>
<translation>Image 1</translation>
<source>IMAGE_NAME</source>
<translation>Image name</translation>
</message>
+ <message>
+ <source>MODIFY_SELECTED_IMAGE</source>
+ <translation>Modify selected image</translation>
+ </message>
<message>
<source>NAME</source>
<translation>Name</translation>
<source>PARAMETERS</source>
<translation>Parameters</translation>
</message>
+ <message>
+ <source>POLYLINE</source>
+ <translation>Polyline</translation>
+ </message>
<message>
<source>TRANSPARENT</source>
<translation>Transparent</translation>
<source>CUT</source>
<translation>Cut</translation>
</message>
+ <message>
+ <source>CUT_IMAGES</source>
+ <translation>Cut images</translation>
+ </message>
+ <message>
+ <source>EDIT_CUT_IMAGE</source>
+ <translation>Edit cut image</translation>
+ </message>
+ <message>
+ <source>EDIT_FUSED_IMAGE</source>
+ <translation>Edit fused image</translation>
+ </message>
+ <message>
+ <source>EDIT_SPLITTED_IMAGE</source>
+ <translation>Edit splitted image</translation>
+ </message>
<message>
<source>FUSE</source>
<translation>Fuse</translation>
</message>
+ <message>
+ <source>FUSE_IMAGES</source>
+ <translation>Fuse images</translation>
+ </message>
+ <message>
+ <source>SPLIT</source>
+ <translation>Split</translation>
+ </message>
+ <message>
+ <source>SPLIT_IMAGE</source>
+ <translation>Split image</translation>
+ </message>
</context>
<context>