HYDROGUI_CalculationDlg.h
HYDROGUI_CalculationOp.h
HYDROGUI_ColorWidget.h
+ HYDROGUI_CopyPasteOp.h
HYDROGUI_DataModel.h
HYDROGUI_DataObject.h
HYDROGUI_DeleteOp.h
HYDROGUI_CalculationDlg.cxx
HYDROGUI_CalculationOp.cxx
HYDROGUI_ColorWidget.cxx
+ HYDROGUI_CopyPasteOp.cxx
HYDROGUI_DataModel.cxx
HYDROGUI_DataObject.cxx
HYDROGUI_DeleteOp.cxx
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
+ Version="9,00"
Name="HYDROGUI"
ProjectGUID="{D11F0AD0-D002-4A22-A8E6-3F906379206F}"
RootNamespace="HYDROGUI"
RelativePath=".\HYDROGUI_ColorWidget.cxx"
>
</File>
+ <File
+ RelativePath=".\HYDROGUI_CopyPasteOp.cxx"
+ >
+ </File>
<File
RelativePath=".\HYDROGUI_DataModel.cxx"
>
<Tool
Name="VCCustomBuildTool"
Description="Generating moc_$(InputName).cxx"
- CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx
"
Outputs="moc/moc_$(InputName).cxx"
/>
</FileConfiguration>
<Tool
Name="VCCustomBuildTool"
Description="Generating moc_$(InputName).cxx"
- CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx
"
Outputs="moc/moc_$(InputName).cxx"
/>
</FileConfiguration>
/>
</FileConfiguration>
</File>
+ <File
+ RelativePath=".\HYDROGUI_CopyPasteOp.h"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Generating moc_$(InputName).cxx"
+ CommandLine="$(QTDIR)\bin\moc.exe $(InputPath) -o moc\moc_$(InputName).cxx"
+ Outputs="moc/moc_$(InputName).cxx"
+ />
+ </FileConfiguration>
+ </File>
<File
RelativePath=".\HYDROGUI_DataModel.h"
>
RelativePath=".\moc\moc_HYDROGUI_ColorWidget.cxx"
>
</File>
+ <File
+ RelativePath=".\moc\moc_HYDROGUI_CopyPasteOp.cxx"
+ >
+ </File>
<File
RelativePath=".\moc\moc_HYDROGUI_DeleteOp.cxx"
>
--- /dev/null
+// 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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_CopyPasteOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_UpdateFlags.h"
+
+HYDROGUI_CopyPasteOp::HYDROGUI_CopyPasteOp( HYDROGUI_Module* theModule,
+ const bool theIsPaste )
+: HYDROGUI_Operation( theModule ),
+ myIsPaste( theIsPaste )
+{
+ setName( tr( "COPY_PASTE" ) );
+}
+
+HYDROGUI_CopyPasteOp::~HYDROGUI_CopyPasteOp()
+{
+}
+
+void HYDROGUI_CopyPasteOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROGUI_DataModel* aModel = module()->getDataModel();
+
+ bool anIsOk = false;
+ int aFlags = 0;
+ if( myIsPaste )
+ {
+ startDocOperation();
+
+ anIsOk = aModel->paste();
+ aFlags = UF_Controls | UF_Model;
+
+ if( anIsOk )
+ commitDocOperation();
+ else
+ abortDocOperation();
+ }
+ else
+ {
+ anIsOk = aModel->copy();
+ aFlags = UF_Controls;
+ }
+
+ if( anIsOk )
+ {
+ module()->update( aFlags );
+ commit();
+ }
+ else
+ abort();
+}
--- /dev/null
+// 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
+//
+// 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.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_COPYPASTEOP_H
+#define HYDROGUI_COPYPASTEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_CopyPasteOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_CopyPasteOp( HYDROGUI_Module* theModule, const bool theIsPaste );
+ virtual ~HYDROGUI_CopyPasteOp();
+
+protected:
+ virtual void startOperation();
+
+private:
+ bool myIsPaste;
+};
+
+#endif
#include <QApplication>
#include <QDir>
+static HYDROData_SequenceOfObjects myCopyingObjects;
+
HYDROGUI_DataModel::HYDROGUI_DataModel( CAM_Module* theModule )
: LightApp_DataModel( theModule )
{
return true;
}
+bool HYDROGUI_DataModel::canCopy()
+{
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
+ if( aSeq.Length() != 1 )
+ return false;
+
+ Handle(HYDROData_Object) anObject = aSeq.First();
+ if( anObject.IsNull() )
+ return false;
+
+ ObjectKind aKind = anObject->GetKind();
+ if( aKind == KIND_IMAGE ||
+ aKind == KIND_POLYLINE ||
+ aKind == KIND_CALCULATION )
+ return true;
+
+ return false;
+}
+
+bool HYDROGUI_DataModel::canPaste()
+{
+ for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
+ if( !anObject.IsNull() && !anObject->IsRemoved() )
+ return true;
+ }
+ return false;
+}
+
+bool HYDROGUI_DataModel::copy()
+{
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( (HYDROGUI_Module*)module() );
+ changeCopyingObjects( aSeq );
+ return true;
+}
+
+bool HYDROGUI_DataModel::paste()
+{
+ bool anIsChanged = false;
+ for( int anIndex = 1, aLength = myCopyingObjects.Length(); anIndex <= aLength; anIndex++ )
+ {
+ Handle(HYDROData_Object) anObject = myCopyingObjects.Value( anIndex );
+ if( !anObject.IsNull() && !anObject->IsRemoved() )
+ {
+ ObjectKind aKind = anObject->GetKind();
+ Handle(HYDROData_Object) aClone = getDocument()->CreateObject( aKind );
+ if( !aClone.IsNull() )
+ {
+ anObject->CopyTo( aClone );
+ anIsChanged = true;
+
+ // generate a new unique name for the clone object:
+ // case 1: Image_1 -> Image_2
+ // case 2: ImageObj -> ImageObj_1
+ QString aName = aClone->GetName();
+ QString aPrefix = aName;
+ if( aName.contains( '_' ) ) // case 1
+ {
+ QString aSuffix = aName.section( '_', -1 );
+ bool anIsInteger = false;
+ aSuffix.toInt( &anIsInteger );
+ if( anIsInteger )
+ aPrefix = aName.section( '_', 0, -2 );
+ }
+ else // case 2
+ aPrefix = aName;
+ aName = HYDROGUI_Tool::GenerateObjectName( (HYDROGUI_Module*)module(), aPrefix );
+ aClone->SetName( aName );
+ }
+ }
+ }
+ return anIsChanged;
+}
+
+void HYDROGUI_DataModel::changeCopyingObjects( const HYDROData_SequenceOfObjects& theSeq )
+{
+ myCopyingObjects.Assign( theSeq );
+}
+
Handle(HYDROData_Document) HYDROGUI_DataModel::getDocument() const
{
int aStudyId = module()->application()->activeStudy()->id();
*/
bool redo();
+ /**
+ * Check if it is possible to perform 'copy' operation
+ */
+ bool canCopy();
+
+ /**
+ * Check if it is possible to perform 'paste' operation
+ */
+ bool canPaste();
+
+ /**
+ * Perform the 'copy' operation
+ */
+ bool copy();
+
+ /**
+ * Perform the 'paste' operation
+ */
+ bool paste();
+
+ /**
+ * Update the sequence of the objects to be copied
+ */
+ static void changeCopyingObjects( const HYDROData_SequenceOfObjects& );
+
protected:
/**
* Returns the document for the current study
LightApp_Application* anApp = getApp();
SUIT_Desktop* aDesktop = anApp->desktop();
+ getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
+
setMenuShown( true );
setToolShown( true );
myObjectStateMap.clear();
+ // clear the data model's list of copying objects
+ HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
+
setMenuShown( false );
setToolShown( false );
+ getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
+
return LightApp_Module::deactivateModule( theStudy );
}
{
if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
{
- if( dynamic_cast<ImageComposer_FuseOperator*>( anOperator ) )
+ QString anOperatorName = anOperator->name();
+ if( anOperatorName == ImageComposer_FuseOperator::Type() )
anIsFusedImage = true;
- else if( dynamic_cast<ImageComposer_CutOperator*>( anOperator ) )
+ else if( anOperatorName == ImageComposer_CutOperator::Type() )
anIsCutImage = true;
- else if( dynamic_cast<ImageComposer_CropOperator*>( anOperator ) )
+ else if( anOperatorName == ImageComposer_CropOperator::Type() )
anIsSplittedImage = true;
}
}
updateUndoRedoControls();
- // to do
- //action( ... )->setEnabled( ... );
+ action( CopyId )->setEnabled( getDataModel()->canCopy() );
+ action( PasteId )->setEnabled( getDataModel()->canPaste() );
+}
+
+void HYDROGUI_Module::selectionChanged()
+{
+ LightApp_Module::selectionChanged();
+ updateCommandsStatus();
}
HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
virtual void update( const int );
virtual void updateCommandsStatus();
+ virtual void selectionChanged();
+
HYDROGUI_DataModel* getDataModel() const;
HYDROGUI_Displayer* getDisplayer() const;
#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_CopyPasteOp.h"
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_DeleteOp.h"
#include "HYDROGUI_ExportImageOp.h"
createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
+ createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
+ createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
+
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE" );
createAction( ObserveImageId, "OBSERVE_IMAGE" );
int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
createMenu( UndoId, anEditMenu );
createMenu( RedoId, anEditMenu );
+ createMenu( separator(), anEditMenu );
+ createMenu( CopyId, anEditMenu );
+ createMenu( PasteId, anEditMenu );
int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
case LoadVisualStateId:
anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
break;
+ case CopyId:
+ case PasteId:
+ anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
+ break;
case ImportImageId:
case EditImportedImageId:
anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
UndoId,
RedoId,
+ CopyId,
+ PasteId,
+
ImportImageId,
EditImportedImageId,
ObserveImageId,
<source>INPUT_VALID_DATA</source>
<translation>Please enter valid data and try again.</translation>
</message>
+ <message>
+ <source>LOAD_ERROR</source>
+ <translation>Study could not be loaded</translation>
+ </message>
<message>
<source>OBJECT_EXISTS_IN_DOCUMENT</source>
<translation>Object with name '%1' already exists in the document.</translation>
</message>
+ <message>
+ <source>SAVE_ERROR</source>
+ <translation>Study could not be saved</translation>
+ </message>
</context>
<context>
<translation>Edit calculation Case</translation>
</message>
</context>
-
+
<context>
- <name>HYDROGUI_DataModel</name>
+ <name>HYDROGUI_CopyPasteOp</name>
<message>
- <source>LOAD_ERROR</source>
- <translation>Study could not be loaded</translation>
- </message>
- <message>
- <source>SAVE_ERROR</source>
- <translation>Study could not be saved</translation>
+ <source>COPY_PASTE</source>
+ <translation>Copy/paste</translation>
</message>
</context>
-
+
<context>
<name>HYDROGUI_DeleteOp</name>
<message>
<source>DSK_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>DSK_COPY</source>
+ <translation>Copy</translation>
+ </message>
<message>
<source>DSK_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>DSK_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
</message>
+ <message>
+ <source>DSK_PASTE</source>
+ <translation>Paste</translation>
+ </message>
<message>
<source>DSK_REDO</source>
<translation>Redo</translation>
<source>MEN_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>MEN_COPY</source>
+ <translation>Copy</translation>
+ </message>
<message>
<source>MEN_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>MEN_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
</message>
+ <message>
+ <source>MEN_PASTE</source>
+ <translation>Paste</translation>
+ </message>
<message>
<source>MEN_REDO</source>
<translation>Redo</translation>
<source>STB_CREATE_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>STB_COPY</source>
+ <translation>Copy</translation>
+ </message>
<message>
<source>STB_CUT_IMAGES</source>
<translation>Cut images</translation>
<source>STB_OBSERVE_IMAGE</source>
<translation>Observe image</translation>
</message>
+ <message>
+ <source>STB_PASTE</source>
+ <translation>Paste</translation>
+ </message>
<message>
<source>STB_REDO</source>
<translation>Redo</translation>