2) Code optimization.
HYDROGUI_DataObject.h
HYDROGUI_DeleteOp.h
HYDROGUI_Displayer.h
+ HYDROGUI_ExportImageDlg.h
HYDROGUI_GVSelector.h
HYDROGUI_ImportImageDlg.h
HYDROGUI_ImportImageOp.h
HYDROGUI_DataObject.cxx
HYDROGUI_DeleteOp.cxx
HYDROGUI_Displayer.cxx
+ HYDROGUI_ExportImageDlg.cxx
HYDROGUI_GVSelector.cxx
HYDROGUI_ImportImageDlg.cxx
HYDROGUI_ImportImageOp.cxx
#include "HYDROGUI_DeleteOp.h"
-#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
-#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
-#include <HYDROData_Iterator.h>
#include <HYDROData_Object.h>
#include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
-#include <SUIT_SelectionMgr.h>
HYDROGUI_DeleteOp::HYDROGUI_DeleteOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
{
HYDROGUI_Operation::startOperation();
- HYDROGUI_DataModel* aModel = module()->getDataModel();
-
- SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
- SUIT_DataOwnerPtrList anOwners;
- aSelectionMgr->selected( anOwners );
-
- if( !anOwners.isEmpty() )
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
+ if( !aSeq.IsEmpty() )
{
int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(),
tr( "DELETE_OBJECTS" ),
}
}
- foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
- if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
- {
- Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
- if( !anObject.IsNull() )
- anObject->Remove();
- }
+ Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
+ anObject->Remove();
}
module()->update( UF_Model | UF_Viewer );
--- /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_ExportImageOp.h"
+
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+
+#include <HYDROData_Image.h>
+
+#include <LightApp_Application.h>
+
+#include <SUIT_Desktop.h>
+
+#include <QFileDialog>
+
+HYDROGUI_ExportImageOp::HYDROGUI_ExportImageOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+ setName( tr( "EXPORT_IMAGE" ) );
+}
+
+HYDROGUI_ExportImageOp::~HYDROGUI_ExportImageOp()
+{
+}
+
+void HYDROGUI_ExportImageOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ Handle(HYDROData_Image) anImageObj =
+ Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
+ if( !anImageObj.IsNull() )
+ {
+ QImage anImage = anImageObj->Image();
+ QTransform aTransform = anImageObj->Trsf();
+
+ anImage = anImage.transformed( aTransform, Qt::SmoothTransformation );
+
+ QString aFilter( tr( "IMAGE_FILTER" ) );
+ QString aFileName = QFileDialog::getSaveFileName( module()->getApp()->desktop(),
+ tr( "BROWSE_IMAGE_FILE" ), "", aFilter );
+ if( !aFileName.isEmpty() )
+ anImage.save( aFileName );
+ }
+
+ abort(); // do not commit the document command
+}
--- /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_EXPORTIMAGEOP_H
+#define HYDROGUI_EXPORTIMAGEOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_ExportImageOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ExportImageOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ExportImageOp();
+
+protected:
+ virtual void startOperation();
+};
+
+#endif
void HYDROGUI_ImportImageDlg::onBrowse()
{
QString aFilter( tr( "IMAGE_FILTER" ) );
- QString aFileName = QFileDialog::getOpenFileName( this, tr( "BROWSE_IMAGE_FILE" ), "", aFilter );
+ QString aFileName = QFileDialog::getOpenFileName( this, tr( "IMPORT_IMAGE_FROM_FILE" ), "", aFilter );
//QString aFileName = "W:/Work/HYDRO/doc/samples/1.bmp";
if( !aFileName.isEmpty() )
{
#include <GraphicsView_Viewer.h>
#include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
{
HYDROGUI_DataModel* aModel = getDataModel();
- LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
- if( !aSelectionMgr )
- return;
-
- SUIT_DataOwnerPtrList anOwners;
- aSelectionMgr->selected( anOwners );
-
bool anIsSelection = false;
bool anIsVisibleInSelection = false;
bool anIsHiddenInSelection = false;
bool anIsImage = false;
bool anIsPolyline = false;
- foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
- if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+ Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
{
- Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
- if( !anObject.IsNull() )
- {
- anIsSelection = true;
+ anIsSelection = true;
- bool aVisibility = anObject->GetVisibility();
- anIsVisibleInSelection |= aVisibility;
- anIsHiddenInSelection |= !aVisibility;
+ bool aVisibility = anObject->GetVisibility();
+ anIsVisibleInSelection |= aVisibility;
+ anIsHiddenInSelection |= !aVisibility;
- if( anObject->GetKind() == KIND_IMAGE )
- anIsImage = true;
+ if( anObject->GetKind() == KIND_IMAGE )
+ anIsImage = true;
- if( anObject->GetKind() == KIND_POLYLINE )
- anIsPolyline = true;
- }
+ if( anObject->GetKind() == KIND_POLYLINE )
+ anIsPolyline = true;
}
}
- if( anOwners.count() == 1 && anIsImage )
- {
- theMenu->addAction( action( EditImageId ) );
- theMenu->addSeparator();
- }
-
- if( anOwners.count() == 1 && anIsPolyline )
+ if( aSeq.Length() == 1 )
{
- theMenu->addAction( action( EditPolylineId ) );
- theMenu->addSeparator();
+ if( anIsImage )
+ {
+ theMenu->addAction( action( EditImageId ) );
+ theMenu->addAction( action( ExportImageId ) );
+ theMenu->addSeparator();
+ }
+ else if( anIsPolyline )
+ {
+ theMenu->addAction( action( EditPolylineId ) );
+ theMenu->addSeparator();
+ }
}
if( anIsSelection )
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
#include <GraphicsView_Object.h>
#include <LightApp_Application.h>
-#include <LightApp_DataOwner.h>
#include <LightApp_GVSelector.h>
#include <LightApp_SelectionMgr.h>
if( !myBtn->isChecked() )
return;
- SUIT_SelectionMgr* aSelMgr = myModule->getApp()->selectionMgr();
- SUIT_DataOwnerPtrList anOwners;
- aSelMgr->selected( anOwners );
-
- HYDROGUI_DataModel* aModel = myModule->getDataModel();
-
QString anObjName;
- foreach( SUIT_DataOwner* anOwner, anOwners )
- {
- LightApp_DataOwner* aGrDOwner = dynamic_cast<LightApp_DataOwner*>( anOwner );
- if( aGrDOwner )
- {
- QString anEntry = aGrDOwner->entry();
- Handle(HYDROData_Object) anObject = aModel->objectByEntry( anEntry, KIND_IMAGE );
- if( !anObject.IsNull() )
- {
- anObjName = anObject->GetName();
- break;
- }
- }
- }
+ Handle(HYDROData_Object) anObject = HYDROGUI_Tool::GetSelectedObject( myModule );
+ if( !anObject.IsNull() )
+ anObjName = anObject->GetName();
+
myObjName->setText( anObjName );
}
#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_DeleteOp.h"
+#include "HYDROGUI_ExportImageOp.h"
#include "HYDROGUI_ImportImageOp.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_PolylineOp.h"
{
createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I );
createAction( EditImageId, "EDIT_IMAGE" );
+ createAction( ExportImageId, "EXPORT_IMAGE" );
createAction( CreatePolylineId, "CREATE_POLYLINE" );
createAction( EditPolylineId, "EDIT_POLYLINE" );
case EditImageId:
anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImageId );
break;
+ case ExportImageId:
+ anOp = new HYDROGUI_ExportImageOp( aModule );
+ break;
case CreatePolylineId:
case EditPolylineId:
anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
RedoId,
ImportImageId,
EditImageId,
+ ExportImageId,
CreatePolylineId,
EditPolylineId,
FuseId,
#include "HYDROGUI_ShowHideOp.h"
-#include "HYDROGUI_DataModel.h"
#include "HYDROGUI_Module.h"
#include "HYDROGUI_Operations.h"
+#include "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
#include <HYDROData_Iterator.h>
#include <HYDROData_Object.h>
-#include <LightApp_DataOwner.h>
-
-#include <SUIT_SelectionMgr.h>
-
HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId )
: HYDROGUI_Operation( theModule ),
myId( theId )
{
HYDROGUI_Operation::startOperation();
- HYDROGUI_DataModel* aModel = module()->getDataModel();
-
// for all objects
if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId )
{
// for selected objects
if( myId == ShowId || myId == ShowOnlyId || myId == HideId )
{
- SUIT_SelectionMgr* aSelectionMgr = selectionMgr();
- SUIT_DataOwnerPtrList anOwners;
- aSelectionMgr->selected( anOwners );
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
bool aVisibility = myId == ShowId || myId == ShowOnlyId;
- foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+ for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
- if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
- {
- Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() );
- if( !anObject.IsNull() )
- anObject->SetVisibility( aVisibility ? true : false );
- }
+ Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
+ if( !anObject.IsNull() )
+ anObject->SetVisibility( aVisibility ? true : false );
}
}
<TS version="1.1" >
<context>
<name>@default</name>
+ <message>
+ <source>IMAGE_FILTER</source>
+ <translation>Image files (*.bmp *.jpg *.jpeg *.png);;All files (*.* *)</translation>
+ </message>
<message>
<source>INSUFFICIENT_INPUT_DATA</source>
<translation>Insufficient input data</translation>
<translation>Do you really want to delete the selected object(s)?</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_ExportImageOp</name>
+ <message>
+ <source>EXPORT_IMAGE</source>
+ <translation>Export image</translation>
+ </message>
+ <message>
+ <source>EXPORT_IMAGE_TO_FILE</source>
+ <translation>Export image to file</translation>
+ </message>
+ </context>
<context>
<name>HYDROGUI_InputPanel</name>
<message>
<source>ACTIVATE_POINT_C_SELECTION</source>
<translation>Activate point C selection</translation>
</message>
- <message>
- <source>BROWSE_IMAGE_FILE</source>
- <translation>Browse image file</translation>
- </message>
<message>
<source>FILE_NAME</source>
<translation>File name</translation>
</message>
- <message>
- <source>IMAGE_FILTER</source>
- <translation>Image files (*.bmp *.jpg *.jpeg *.png);;All files (*.* *)</translation>
- </message>
<message>
<source>IMAGE_NAME</source>
<translation>Image name</translation>
<source>DSK_EDIT_POLYLINE</source>
<translation>Edit polyline</translation>
</message>
+ <message>
+ <source>DSK_EXPORT_IMAGE</source>
+ <translation>Export image</translation>
+ </message>
<message>
<source>DSK_FUSE_IMAGES</source>
<translation>Fuse images</translation>
<source>MEN_EDIT_POLYLINE</source>
<translation>Create polyline</translation>
</message>
+ <message>
+ <source>MEN_EXPORT_IMAGE</source>
+ <translation>Export image</translation>
+ </message>
<message>
<source>MEN_FUSE_IMAGES</source>
<translation>Fuse images</translation>
<source>STB_EDIT_POLYLINE</source>
<translation>Edit polyline</translation>
</message>
+ <message>
+ <source>STB_EXPORT_IMAGE</source>
+ <translation>Export image</translation>
+ </message>
<message>
<source>STB_FUSE_IMAGES</source>
<translation>Fuse images</translation>