From: ouv Date: Thu, 8 Aug 2013 10:18:40 +0000 (+0000) Subject: 1) Show/Hide, Delete operations X-Git-Tag: BR_hydro_v_0_1~127 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=94f079c9197f9655e023e5047feffea452b4a1fe;p=modules%2Fhydro.git 1) Show/Hide, Delete operations 2) Raw development 3) Fixing compilation errors in HYDROData --- diff --git a/src/HYDROData/HYDROData_Iterator.h b/src/HYDROData/HYDROData_Iterator.h index b24ee4b2..617d54d4 100644 --- a/src/HYDROData/HYDROData_Iterator.h +++ b/src/HYDROData/HYDROData_Iterator.h @@ -21,7 +21,8 @@ public: * \param theDoc document to iterate * \param theKind kind of the iterated object, can be UNKNOWN: to iterate all objects */ - HYDRODATA_EXPORT HYDROData_Iterator(Handle(HYDROData_Document) theDoc, ObjectKind theKind); + HYDRODATA_EXPORT HYDROData_Iterator(Handle(HYDROData_Document) theDoc, + ObjectKind theKind = KIND_UNKNOWN); /** * Iterates to the next object diff --git a/src/HYDROData/HYDROData_Object.cxx b/src/HYDROData/HYDROData_Object.cxx index 46b4acc4..fe71e385 100644 --- a/src/HYDROData/HYDROData_Object.cxx +++ b/src/HYDROData/HYDROData_Object.cxx @@ -2,8 +2,11 @@ #include #include +#include #include +static const Standard_GUID GUID_VISIBILITY("d6a715c5-9c86-4adc-8a6c-13188f3ad94b"); + IMPLEMENT_STANDARD_HANDLE(HYDROData_Object,MMgt_TShared) IMPLEMENT_STANDARD_RTTIEXT(HYDROData_Object,MMgt_TShared) @@ -28,6 +31,20 @@ void HYDROData_Object::SetName(const QString& theName) TDataStd_Name::Set(myLab, TCollection_ExtendedString(theName.toLatin1().constData())); } +bool HYDROData_Object::GetVisibility() const +{ + return myLab.IsAttribute(GUID_VISIBILITY); +} + +void HYDROData_Object::SetVisibility(bool theState) +{ + if (theState) { + TDataStd_UAttribute::Set(myLab, GUID_VISIBILITY); + } else { + myLab.ForgetAttribute(GUID_VISIBILITY); + } +} + bool HYDROData_Object::IsRemoved() const { return !myLab.HasAttribute(); diff --git a/src/HYDROData/HYDROData_Object.h b/src/HYDROData/HYDROData_Object.h index f448d70a..f4b30d70 100644 --- a/src/HYDROData/HYDROData_Object.h +++ b/src/HYDROData/HYDROData_Object.h @@ -43,6 +43,18 @@ public: */ HYDRODATA_EXPORT void SetName(const QString& theName); + /** + * Returns the object visibility state. + * \returns visibility state + */ + HYDRODATA_EXPORT bool GetVisibility() const; + + /** + * Sets the object visibility state. + * \param theState visibility state + */ + HYDRODATA_EXPORT void SetVisibility(bool theState); + /** * Checks is object exists in the data structure. * \returns true is object is not exists in the data model diff --git a/src/HYDROData/HYDROData_Polyline.cxx b/src/HYDROData/HYDROData_Polyline.cxx index a0ec4f2d..8b01e076 100755 --- a/src/HYDROData/HYDROData_Polyline.cxx +++ b/src/HYDROData/HYDROData_Polyline.cxx @@ -40,14 +40,14 @@ void HYDROData_Polyline::addPoint( const QPointF& thePoint ) setPoints( aPointsArray ); } -bool HYDROData_Polyline::insertPoint( int theIndex, const QPointF& thePoint) +void HYDROData_Polyline::insertPoint( int theIndex, const QPointF& thePoint) { QList aPointsArray = points(); aPointsArray.insert( theIndex, thePoint ); setPoints( aPointsArray ); } -bool HYDROData_Polyline::removePoint( int theIndex ) +void HYDROData_Polyline::removePoint( int theIndex ) { QList aPointsArray = points(); aPointsArray.removeAt( theIndex ); diff --git a/src/HYDROData/HYDROData_Polyline.h b/src/HYDROData/HYDROData_Polyline.h index 61a22bbc..641ade90 100755 --- a/src/HYDROData/HYDROData_Polyline.h +++ b/src/HYDROData/HYDROData_Polyline.h @@ -41,13 +41,13 @@ public: * Add point to the point list at the specified position * \param theIndex the index of the list the point will insert after */ - HYDRODATA_EXPORT bool insertPoint( int theIndex, const QPointF& thePoint); + HYDRODATA_EXPORT void insertPoint( int theIndex, const QPointF& thePoint); /** * Remove point from polyline * \param theIndex the point index */ - HYDRODATA_EXPORT bool removePoint( int theIndex ); + HYDRODATA_EXPORT void removePoint( int theIndex ); /** * Remove all points from polyline diff --git a/src/HYDROGUI/HYDROGUI_DataModel.h b/src/HYDROGUI/HYDROGUI_DataModel.h index 9b08ac8d..eb6f374f 100644 --- a/src/HYDROGUI/HYDROGUI_DataModel.h +++ b/src/HYDROGUI/HYDROGUI_DataModel.h @@ -140,7 +140,7 @@ public: * Find a data object by the specified entry and kind */ Handle(HYDROData_Object) objectByEntry( const QString& theEntry, - const ObjectKind theObjectKind ); + const ObjectKind theObjectKind = KIND_UNKNOWN ); /** * Check if it is possible to perform 'undo' operation diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.cxx b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx new file mode 100644 index 00000000..83372230 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DeleteOp.cxx @@ -0,0 +1,86 @@ +// 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_DeleteOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Operations.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include + +#include +#include + +#include +#include +#include + +HYDROGUI_DeleteOp::HYDROGUI_DeleteOp( HYDROGUI_Module* theModule ) +: HYDROGUI_Operation( theModule ) +{ + setName( tr( "DELETE" ) ); +} + +HYDROGUI_DeleteOp::~HYDROGUI_DeleteOp() +{ +} + +void HYDROGUI_DeleteOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_DataModel* aModel = module()->getDataModel(); + + SUIT_SelectionMgr* aSelectionMgr = selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelectionMgr->selected( anOwners ); + + if( !anOwners.isEmpty() ) + { + int anAnswer = SUIT_MessageBox::question( module()->getApp()->desktop(), + tr( "DELETE_OBJECTS" ), + tr( "CONFIRM_DELETION" ), + QMessageBox::Yes | QMessageBox::No, + QMessageBox::No ); + if( anAnswer == QMessageBox::No ) + { + abort(); + return; + } + } + + foreach( SUIT_DataOwner* aSUITOwner, anOwners ) + { + if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + { + Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); + if( !anObject.IsNull() ) + anObject->Remove(); + } + } + + module()->update( UF_Model | UF_Viewer ); + commit(); +} diff --git a/src/HYDROGUI/HYDROGUI_DeleteOp.h b/src/HYDROGUI/HYDROGUI_DeleteOp.h new file mode 100644 index 00000000..ca7a538b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_DeleteOp.h @@ -0,0 +1,40 @@ +// 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_DELETEOP_H +#define HYDROGUI_DELETEOP_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_DeleteOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_DeleteOp( HYDROGUI_Module* theModule ); + virtual ~HYDROGUI_DeleteOp(); + +protected: + virtual void startOperation(); +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Displayer.cxx b/src/HYDROGUI/HYDROGUI_Displayer.cxx index 66cb4c11..2947e10a 100644 --- a/src/HYDROGUI/HYDROGUI_Displayer.cxx +++ b/src/HYDROGUI/HYDROGUI_Displayer.cxx @@ -82,13 +82,13 @@ void HYDROGUI_Displayer::EraseAll( const int theViewerId ) if( !aViewPort ) return; - GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) ); while( anIter.hasNext() ) { if( GraphicsView_Object* anObject = anIter.next() ) { aViewPort->removeItem( anObject ); - //delete anObject; // ouv: to do + delete anObject; } } } @@ -144,7 +144,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs, HYDROGUI_DataModel* aModel = (HYDROGUI_DataModel*)myModule->dataModel(); if( aModel ) { - GraphicsView_ObjectList anObjectList = aViewPort->getObjects(); + GraphicsView_ObjectList anObjectList = HYDROGUI_Tool::GetPrsList( aViewPort ); for( int i = 1, n = theObjs.Length(); i <= n; i++ ) { // the object may be null or dead @@ -152,7 +152,7 @@ void HYDROGUI_Displayer::Erase( const HYDROData_SequenceOfObjects& theObjs, if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( anObj, anObjectList ) ) { aViewPort->removeItem( aPrs ); - //delete aPrs; // ouv: to do + delete aPrs; } } } @@ -192,8 +192,8 @@ void HYDROGUI_Displayer::Display( const HYDROData_SequenceOfObjects& theObjs, if( aPrs ) { - bool isVisible = true; // anObj->IsVisible() - aPrs->setVisible( true ); + bool anIsVisible = anObj->GetVisibility(); + aPrs->setVisible( anIsVisible ); } } @@ -210,17 +210,16 @@ void HYDROGUI_Displayer::purgeObjects( const int theViewerId ) if( !aViewPort ) return; - GraphicsView_ObjectListIterator anIter( aViewPort->getObjects() ); + GraphicsView_ObjectListIterator anIter( HYDROGUI_Tool::GetPrsList( aViewPort ) ); while( anIter.hasNext() ) { - GraphicsView_Object* tmp = anIter.next(); - if( HYDROGUI_Prs* aPrs = dynamic_cast( tmp ) ) + if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) { Handle(HYDROData_Object) anObject = aPrs->getObject(); - if( anObject.IsNull() ) + if( !anObject.IsNull() && anObject->IsRemoved() ) { aViewPort->removeItem( aPrs ); - //delete aPrs; // ouv: to do + delete aPrs; } } } diff --git a/src/HYDROGUI/HYDROGUI_GVSelector.cxx b/src/HYDROGUI/HYDROGUI_GVSelector.cxx index 6f0266fa..95f72cdc 100644 --- a/src/HYDROGUI/HYDROGUI_GVSelector.cxx +++ b/src/HYDROGUI/HYDROGUI_GVSelector.cxx @@ -76,7 +76,7 @@ void HYDROGUI_GVSelector::setSelection( const SUIT_DataOwnerPtrList& theList ) if ( anOwner ) { QString anEntry = anOwner->entry(); - Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry, KIND_IMAGE ); + Handle(HYDROData_Object) aModelObject = aModel->objectByEntry( anEntry ); if( !aModelObject.IsNull() ) { if( HYDROGUI_Prs* aPrs = HYDROGUI_Tool::GetPresentation( aModelObject, anObjectList ) ) diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index bcc97ca1..21ab2da2 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -116,6 +116,7 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags ) anImageObj->SetImage( anImage ); anImageObj->SetTrsf( aTransform ); + anImageObj->SetVisibility( true ); theUpdateFlags = UF_Model | UF_Viewer; return true; diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index 3993bfc4..aaefcdfb 100644 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -38,14 +38,19 @@ #include #include +#include #include #include #include +#include + #include #include +#include #include +#include extern "C" HYDRO_EXPORT CAM_Module* createModule() { @@ -92,6 +97,8 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) setMenuShown( true ); setToolShown( true ); + update( UF_All ); + updateCommandsStatus(); return aRes; @@ -117,6 +124,58 @@ void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const theTypesList << GraphicsView_Viewer::Type(); } +void HYDROGUI_Module::contextMenuPopup( const QString& theClient, + QMenu* theMenu, + QString& theTitle ) +{ + 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; + + foreach( SUIT_DataOwner* aSUITOwner, anOwners ) + { + if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + { + Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); + if( !anObject.IsNull() ) + { + bool aVisibility = anObject->GetVisibility(); + anIsVisibleInSelection |= aVisibility; + anIsHiddenInSelection |= !aVisibility; + anIsSelection = true; + } + } + } + + if( anIsSelection ) + { + theMenu->addAction( action( DeleteId ) ); + theMenu->addSeparator(); + } + + if( anIsSelection ) + { + if( anIsHiddenInSelection ) + theMenu->addAction( action( ShowId ) ); + theMenu->addAction( action( ShowOnlyId ) ); + if( anIsVisibleInSelection ) + theMenu->addAction( action( HideId ) ); + theMenu->addSeparator(); + } + theMenu->addAction( action( ShowAllId ) ); + theMenu->addAction( action( HideAllId ) ); + theMenu->addSeparator(); +} + void HYDROGUI_Module::update( const int flags ) { if( !isUpdateEnabled() ) @@ -193,6 +252,46 @@ CAM_DataModel* HYDROGUI_Module::createDataModel() return new HYDROGUI_DataModel( this ); } +void HYDROGUI_Module::customEvent( QEvent* e ) +{ + int aType = e->type(); + if ( aType == NewViewEvent ) + { + SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e; + if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() ) + { + if( GraphicsView_Viewer* aViewer = dynamic_cast( aViewFrame->getViewer() ) ) + { + update( UF_Viewer | UF_GV_Forced ); + aViewer->activateTransform( GraphicsView_Viewer::FitAll ); + + if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() ) + { + aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect ); + aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu ); + aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection ); + } + } + } + } +} + +bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent ) +{ + QEvent::Type aType = theEvent->type(); + if( theObj->inherits( "GraphicsView_ViewFrame" ) ) + { + if( aType == QEvent::Show ) + { + SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent ); + e->setData( theObj ); + QApplication::postEvent( this, e ); + theObj->removeEventFilter( this ); + } + } + return LightApp_Module::eventFilter( theObj, theEvent ); +} + void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) { LightApp_Module::onViewManagerAdded( theViewManager ); @@ -213,8 +312,15 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) createSelector( theViewManager ); // replace the default selector } -void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theWnd ) +void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow ) { + if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) ) + { + if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast( theViewWindow ) ) + { + aViewFrame->installEventFilter( this ); + } + } } void HYDROGUI_Module::updateGV( const bool theIsInit, diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index fdb8d03e..e35a9fb3 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -25,6 +25,8 @@ #include +#include + class GraphicsView_Viewer; class SUIT_ViewWindow; @@ -39,6 +41,8 @@ class HYDROGUI_Module : public LightApp_Module { Q_OBJECT + enum CustomEvent { NewViewEvent = QEvent::User + 100 }; + public: HYDROGUI_Module(); virtual ~HYDROGUI_Module(); @@ -52,6 +56,8 @@ public: virtual void windows( QMap& ) const; virtual void viewManagers( QStringList& ) const; + virtual void contextMenuPopup( const QString&, QMenu*, QString& ); + virtual void update( const int ); virtual void updateCommandsStatus(); @@ -70,6 +76,9 @@ public slots: protected: virtual LightApp_Operation* createOperation( const int ) const; + virtual void customEvent( QEvent* ); + virtual bool eventFilter( QObject*, QEvent* ); + protected slots: void onOperation(); diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 35705791..b19684ab 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -86,8 +86,8 @@ void HYDROGUI_Operation::startOperation() if( inputPanel() ) { - inputPanel()->show(); myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() ); + inputPanel()->show(); } } @@ -111,6 +111,11 @@ void HYDROGUI_Operation::commitOperation() inputPanel()->hide(); } +HYDROGUI_InputPanel* HYDROGUI_Operation::createInputPanel() const +{ + return NULL; +} + bool HYDROGUI_Operation::processApply( int& theUpdateFlags ) { return false; @@ -126,7 +131,7 @@ Handle_HYDROData_Document HYDROGUI_Operation::doc() const return HYDROData_Document::Document( aStudyId ); } -Handle_HYDROData_Object HYDROGUI_Operation::FindObjectByName( const QString& theName, int theKind ) const +Handle_HYDROData_Object HYDROGUI_Operation::findObjectByName( const QString& theName, int theKind ) const { HYDROData_Iterator anIt( doc(), theKind ); for( ; anIt.More(); anIt.Next() ) diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index dd7bcaee..1f3ae1d5 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -51,13 +51,13 @@ protected: virtual void abortOperation(); virtual void commitOperation(); - virtual HYDROGUI_InputPanel* createInputPanel() const = 0; + virtual HYDROGUI_InputPanel* createInputPanel() const; virtual bool processApply( int& theUpdateFlags ); virtual void processCancel(); Handle_HYDROData_Document doc() const; - Handle_HYDROData_Object FindObjectByName( const QString& theName, int theKind ) const; + Handle_HYDROData_Object findObjectByName( const QString& theName, int theKind ) const; protected slots: virtual void onApply(); diff --git a/src/HYDROGUI/HYDROGUI_Operations.cxx b/src/HYDROGUI/HYDROGUI_Operations.cxx index f17376e2..b0714ecc 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.cxx +++ b/src/HYDROGUI/HYDROGUI_Operations.cxx @@ -23,8 +23,10 @@ #include "HYDROGUI_Operations.h" #include "HYDROGUI_DataModel.h" +#include "HYDROGUI_DeleteOp.h" #include "HYDROGUI_ImportImageOp.h" #include "HYDROGUI_Module.h" +#include "HYDROGUI_ShowHideOp.h" #include "HYDROGUI_TwoImagesOp.h" #include "HYDROGUI_UpdateFlags.h" @@ -62,6 +64,14 @@ void HYDROGUI_Module::createActions() createAction( ImportImageId, "IMPORT_IMAGE", "", Qt::CTRL + Qt::Key_I ); createAction( FuseId, "FUSE_IMAGES" ); createAction( CutId, "CUT_IMAGES" ); + + createAction( DeleteId, "DELETE", "", Qt::Key_Delete ); + + createAction( ShowId, "SHOW" ); + createAction( ShowOnlyId, "SHOW_ONLY" ); + createAction( ShowAllId, "SHOW_ALL" ); + createAction( HideId, "HIDE" ); + createAction( HideAllId, "HIDE_ALL" ); } void HYDROGUI_Module::createMenus() @@ -196,6 +206,16 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const case CutId: anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut ); break; + case DeleteId: + anOp = new HYDROGUI_DeleteOp( aModule ); + break; + case ShowId: + case ShowOnlyId: + case ShowAllId: + case HideId: + case HideAllId: + anOp = new HYDROGUI_ShowHideOp( aModule, theId ); + break; } if( !anOp ) diff --git a/src/HYDROGUI/HYDROGUI_Operations.h b/src/HYDROGUI/HYDROGUI_Operations.h index 2200cb61..972bcfb5 100644 --- a/src/HYDROGUI/HYDROGUI_Operations.h +++ b/src/HYDROGUI/HYDROGUI_Operations.h @@ -25,7 +25,7 @@ enum OperationId { - FirstId, + FirstId = 0, UndoId, RedoId, @@ -33,6 +33,14 @@ enum OperationId ImportImageId, FuseId, CutId, + + DeleteId, + + ShowId, + ShowOnlyId, + ShowAllId, + HideId, + HideAllId, }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx new file mode 100644 index 00000000..47e0a2b6 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.cxx @@ -0,0 +1,98 @@ +// 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_ShowHideOp.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Operations.h" +#include "HYDROGUI_UpdateFlags.h" + +#include +#include + +#include + +#include + +HYDROGUI_ShowHideOp::HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId ) +: HYDROGUI_Operation( theModule ), + myId( theId ) +{ + QString aName; + switch( myId ) + { + case ShowId: aName = tr( "SHOW" ); break; + case ShowOnlyId: aName = tr( "SHOW_ONLY" ); break; + case ShowAllId: aName = tr( "SHOW_ALL" ); break; + case HideId: aName = tr( "HIDE" ); break; + case HideAllId: aName = tr( "HIDE_ALL" ); break; + default: break; + } + setName( aName ); +} + +HYDROGUI_ShowHideOp::~HYDROGUI_ShowHideOp() +{ +} + +void HYDROGUI_ShowHideOp::startOperation() +{ + HYDROGUI_Operation::startOperation(); + + HYDROGUI_DataModel* aModel = module()->getDataModel(); + + // for all objects + if( myId == ShowOnlyId || myId == ShowAllId || myId == HideAllId ) + { + bool aVisibility = myId == ShowAllId; + HYDROData_Iterator anIterator( doc() ); + for( ; anIterator.More(); anIterator.Next() ) + { + Handle(HYDROData_Object) anObject = anIterator.Current(); + if( !anObject.IsNull() ) + anObject->SetVisibility( aVisibility ); + } + } + + // for selected objects + if( myId == ShowId || myId == ShowOnlyId || myId == HideId ) + { + SUIT_SelectionMgr* aSelectionMgr = selectionMgr(); + SUIT_DataOwnerPtrList anOwners; + aSelectionMgr->selected( anOwners ); + + bool aVisibility = myId == ShowId || myId == ShowOnlyId; + foreach( SUIT_DataOwner* aSUITOwner, anOwners ) + { + if( LightApp_DataOwner* anOwner = dynamic_cast( aSUITOwner ) ) + { + Handle(HYDROData_Object) anObject = aModel->objectByEntry( anOwner->entry() ); + if( !anObject.IsNull() ) + anObject->SetVisibility( aVisibility ? true : false ); + } + } + } + + module()->update( UF_Viewer ); + commit(); +} diff --git a/src/HYDROGUI/HYDROGUI_ShowHideOp.h b/src/HYDROGUI/HYDROGUI_ShowHideOp.h new file mode 100644 index 00000000..dbd0d79b --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ShowHideOp.h @@ -0,0 +1,43 @@ +// 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_SHOWHIDEOP_H +#define HYDROGUI_SHOWHIDEOP_H + +#include "HYDROGUI_Operation.h" + +class HYDROGUI_ShowHideOp : public HYDROGUI_Operation +{ + Q_OBJECT + +public: + HYDROGUI_ShowHideOp( HYDROGUI_Module* theModule, int theId ); + virtual ~HYDROGUI_ShowHideOp(); + +protected: + virtual void startOperation(); + +private: + int myId; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_Tool.cxx b/src/HYDROGUI/HYDROGUI_Tool.cxx index edcf41b3..28072d7c 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.cxx +++ b/src/HYDROGUI/HYDROGUI_Tool.cxx @@ -162,10 +162,31 @@ void HYDROGUI_Tool::GetPrsSubObjects( const HYDROGUI_DataModel* theModel, HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Object)& theObj, const GraphicsView_ObjectList& theObjects ) { - GraphicsView_ObjectListIterator anIter( theObjects ); - while( anIter.hasNext() ) - if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) - if( aPrs->getObject()->Label() == theObj->Label() ) - return aPrs; + if( !theObj.IsNull() ) + { + GraphicsView_ObjectListIterator anIter( theObjects ); + while( anIter.hasNext() ) + { + if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) + { + Handle(HYDROData_Object) anObj = aPrs->getObject(); + if( !anObj.IsNull() && anObj->Label() == theObj->Label() ) + return aPrs; + } + } + } return NULL; } + +GraphicsView_ObjectList HYDROGUI_Tool::GetPrsList( GraphicsView_ViewPort* theViewPort ) +{ + GraphicsView_ObjectList aList; + if( theViewPort ) + { + GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() ); + while( anIter.hasNext() ) + if( HYDROGUI_Prs* aPrs = dynamic_cast( anIter.next() ) ) + aList.append( aPrs ); + } + return aList; +} diff --git a/src/HYDROGUI/HYDROGUI_Tool.h b/src/HYDROGUI/HYDROGUI_Tool.h index a419734c..41d7fe2f 100644 --- a/src/HYDROGUI/HYDROGUI_Tool.h +++ b/src/HYDROGUI/HYDROGUI_Tool.h @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -111,6 +112,13 @@ public: */ static HYDROGUI_Prs* GetPresentation( const Handle(HYDROData_Object)& theObj, const GraphicsView_ObjectList& theObjects ); + + /** + * \brief Get list of HYDRO presentations from the specified viewport + * \param theViewPort viewport + * \return list of HYDRO presentations + */ + static GraphicsView_ObjectList GetPrsList( GraphicsView_ViewPort* theViewPort ); }; #endif diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 748da501..a91d4734 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -70,9 +70,9 @@ bool HYDROGUI_TwoImagesOp::processApply( int& theUpdateFlags ) return false; Handle(HYDROData_Image) anImage1 = Handle(HYDROData_Image)::DownCast( - FindObjectByName( aName1, KIND_IMAGE ) ); + findObjectByName( aName1, KIND_IMAGE ) ); Handle(HYDROData_Image) anImage2 = Handle(HYDROData_Image)::DownCast( - FindObjectByName( aName2, KIND_IMAGE ) ); + findObjectByName( aName2, KIND_IMAGE ) ); if( anImage1.IsNull() || anImage2.IsNull() ) return false; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 5ef51a55..b9ee02a2 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -22,6 +22,21 @@ Study could not be saved + + HYDROGUI_DeleteOp + + DELETE + Delete + + + DELETE_OBJECTS + Delete objects + + + CONFIRM_DELETION + Do you really want to delete the selected object(s)? + + HYDROGUI_InputPanel @@ -89,10 +104,22 @@ DSK_CUT_IMAGES Cut images + + DSK_DELETE + Delete + DSK_FUSE_IMAGES Fuse images + + DSK_HIDE + Hide + + + DSK_HIDE_ALL + Hide all + DSK_IMPORT_IMAGE Import image @@ -101,6 +128,18 @@ DSK_REDO Redo + + DSK_SHOW + Show + + + DSK_SHOW_ALL + Show all + + + DSK_SHOW_ONLY + Show only + DSK_UNDO Undo @@ -114,13 +153,25 @@ Cut images - MEN_FUSE_IMAGES - Fuse images + MEN_DELETE + Delete MEN_DESK_HYDRO HYDRO + + MEN_FUSE_IMAGES + Fuse images + + + MEN_HIDE + Hide + + + MEN_HIDE_ALL + Hide all + MEN_IMPORT_IMAGE Import image @@ -129,6 +180,18 @@ MEN_REDO Redo + + MEN_SHOW + Show + + + MEN_SHOW_ALL + Show all + + + MEN_SHOW_ONLY + Show only + MEN_UNDO Undo @@ -137,10 +200,22 @@ STB_CUT_IMAGES Cut images + + STB_DELETE + Delete + STB_FUSE_IMAGES Fuse images + + STB_HIDE + Hide + + + STB_HIDE_ALL + Hide all + STB_IMPORT_IMAGE Import image @@ -149,11 +224,46 @@ STB_REDO Redo + + STB_SHOW + Show + + + STB_SHOW_ALL + Show all + + + STB_SHOW_ONLY + Show only + STB_UNDO Undo + + HYDROGUI_ShowHideOp + + SHOW + Show + + + SHOW_ALL + Show all + + + SHOW_ONLY + Show only + + + HIDE + Hide + + + HIDE_ALL + Hide all + + HYDROGUI_TwoImagesDlg