From 214bb4dda4a3b75bcac7be764bb091c3bbc7e594 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Sun, 9 Jan 2011 18:19:21 +0000 Subject: [PATCH] Add the ability to get a command by it's name. --- hurricane/src/viewer/CellWidget.cpp | 9 +++++++++ hurricane/src/viewer/SelectCommand.cpp | 4 ++++ hurricane/src/viewer/hurricane/viewer/CellWidget.h | 1 + hurricane/src/viewer/hurricane/viewer/SelectCommand.h | 1 + 4 files changed, 15 insertions(+) diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index c06e0343..5ebd2dad 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1268,6 +1268,15 @@ namespace Hurricane { } + Command* CellWidget::getCommand ( const string& name ) const + { + for ( size_t i=0 ; i<_commands.size() ; ++i ) { + if ( _commands[i]->getName() == name ) return _commands[i]; + } + return NULL; + } + + void CellWidget::pushCursor ( Qt::CursorShape cursor ) { setCursor ( cursor ); diff --git a/hurricane/src/viewer/SelectCommand.cpp b/hurricane/src/viewer/SelectCommand.cpp index a160d460..3e4179f1 100644 --- a/hurricane/src/viewer/SelectCommand.cpp +++ b/hurricane/src/viewer/SelectCommand.cpp @@ -199,6 +199,10 @@ namespace Hurricane { string SelectCommand::_name = "SelectCommand"; + const string& SelectCommand::getStaticName () + { return _name; } + + SelectCommand::SelectCommand () : AreaCommand () , _selectionPopup(NULL) diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index d3928ca3..281600c9 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -146,6 +146,7 @@ namespace Hurricane { void unbindCommand ( Command* ); inline void setActiveCommand ( Command* ); inline Command* getActiveCommand () const; + Command* getCommand ( const std::string& ) const; inline void resetActiveCommand (); inline void setCursorStep ( DbU::Unit ); inline void setRealSnapGridStep ( DbU::Unit step ); diff --git a/hurricane/src/viewer/hurricane/viewer/SelectCommand.h b/hurricane/src/viewer/hurricane/viewer/SelectCommand.h index 51819861..385a8e94 100644 --- a/hurricane/src/viewer/hurricane/viewer/SelectCommand.h +++ b/hurricane/src/viewer/hurricane/viewer/SelectCommand.h @@ -54,6 +54,7 @@ namespace Hurricane { public: enum SelectMode { AllMode=0, NetMode=1, NoAnonNetMode=2 }; public: + static const string& getStaticName (); SelectCommand (); virtual ~SelectCommand (); virtual const string& getName () const;