From dcf39378c5cb19eebccab423eddc14c7c0734cfb Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Thu, 3 Dec 2009 11:19:54 +0000 Subject: [PATCH] * ./hurricane/src/hviewer : - Change: In RulerCommand, key & mouse now mimic Cadence behavior. --- hurricane/src/hviewer/CellViewer.cpp | 2 +- hurricane/src/hviewer/RulerCommand.cpp | 47 +++++++++++-------- .../hviewer/hurricane/viewer/RulerCommand.h | 3 +- 3 files changed, 31 insertions(+), 21 deletions(-) diff --git a/hurricane/src/hviewer/CellViewer.cpp b/hurricane/src/hviewer/CellViewer.cpp index ac7f183e..48d9485b 100644 --- a/hurricane/src/hviewer/CellViewer.cpp +++ b/hurricane/src/hviewer/CellViewer.cpp @@ -185,7 +185,7 @@ namespace Hurricane { _clearRulersAction = new QAction ( tr("Clear Rulers"), this ); _clearRulersAction->setObjectName ( "viewer.menuBar.view.clearRulers" ); _clearRulersAction->setStatusTip ( tr("Remove all rulers") ); - _clearRulersAction->setShortcut ( QKeySequence(tr("CTRL+R")) ); + //_clearRulersAction->setShortcut ( QKeySequence(tr("K")) ); _controllerAction = new QAction ( tr("Controller"), this ); _controllerAction->setObjectName ( "viewer.menuBar.tools.controller" ); diff --git a/hurricane/src/hviewer/RulerCommand.cpp b/hurricane/src/hviewer/RulerCommand.cpp index 1a358043..dbe0d006 100644 --- a/hurricane/src/hviewer/RulerCommand.cpp +++ b/hurricane/src/hviewer/RulerCommand.cpp @@ -41,8 +41,9 @@ namespace Hurricane { RulerCommand::RulerCommand () - : Command() - , _ruler () + : Command () + , _ruler () + , _drawing(false) { } @@ -56,7 +57,7 @@ namespace Hurricane { void RulerCommand::mouseMoveEvent ( QMouseEvent* event ) { - if ( !isActive() ) return; + if ( not isActive() or not _drawing ) return; _ruler->setExtremity ( _cellWidget->_onCursorGrid(_cellWidget->screenToDbuPoint(event->pos())) ); _cellWidget->update (); @@ -65,38 +66,46 @@ namespace Hurricane { void RulerCommand::mousePressEvent ( QMouseEvent* event ) { - if ( (event->modifiers() & Qt::ShiftModifier ) - and (event->button() == Qt::LeftButton ) ) { - setActive ( true ); - _ruler.reset ( new Ruler - (_cellWidget->_onCursorGrid(_cellWidget->screenToDbuPoint(_cellWidget->getMousePosition())) ) ); - return; - } + if ( not isActive() ) return; - if ( isActive() ) { - if ( event->button() != Qt::RightButton ) + if ( event->button() == Qt::LeftButton ) { + if ( not _drawing ) { + _drawing = true; + _ruler.reset ( new Ruler + (_cellWidget->_onCursorGrid(_cellWidget->screenToDbuPoint(_cellWidget->getMousePosition())) ) ); + } else { + setActive ( false ); + _drawing = false; _cellWidget->addRuler ( _ruler ); - - setActive ( false ); - _ruler.reset (); + _ruler.reset (); + } } } void RulerCommand::keyPressEvent ( QKeyEvent* event ) { - if ( !isActive() ) return; - - if ( event->key() == Qt::Key_Escape ) { + if ( isActive() and (event->key() == Qt::Key_Escape) ) { setActive ( false ); + _drawing = false; _ruler.reset (); + return; } + + if ( event->key() != Qt::Key_K ) return; + + if ( event->modifiers() & Qt::ShiftModifier ) { + _cellWidget->clearRulers (); + return; + } + + setActive ( true ); } void RulerCommand::draw () { - if ( !isActive() ) return; + if ( not _drawing ) return; _cellWidget->drawRuler ( _ruler ); } diff --git a/hurricane/src/hviewer/hurricane/viewer/RulerCommand.h b/hurricane/src/hviewer/hurricane/viewer/RulerCommand.h index e1798d89..a7d55bbf 100644 --- a/hurricane/src/hviewer/hurricane/viewer/RulerCommand.h +++ b/hurricane/src/hviewer/hurricane/viewer/RulerCommand.h @@ -47,9 +47,10 @@ namespace Hurricane { private: RulerCommand ( const RulerCommand& ); RulerCommand& operator= ( const RulerCommand& ); - protected: + private: static string _name; std::tr1::shared_ptr _ruler; + bool _drawing; };