* ./hurricane/src/viewer :

- Change: Consistent encapsulation of "_active" in Command and all it's derived
        classes.
    - New: support for Rulers. Start drawing by pressing Shift+L.Button, finish
        by pressing it again. To cancel a Ruler press Shift+R.Button.
          Drawing style support also added : "text.ruler". Rulers are always
        visibles (display threshold sets to zero), only the numbers of graduations
        displayeds changes (at least 5 pixels between two graduations).
This commit is contained in:
Jean-Paul Chaput 2009-04-15 16:09:18 +00:00
parent a404498be5
commit ee828cb19f
14 changed files with 678 additions and 124 deletions

View File

@ -42,6 +42,7 @@
hurricane/viewer/AreaCommand.h
hurricane/viewer/MoveCommand.h
hurricane/viewer/ZoomCommand.h
hurricane/viewer/RulerCommand.h
hurricane/viewer/SelectCommand.h
hurricane/viewer/HierarchyCommand.h
hurricane/viewer/SelectorCriterion.h
@ -53,6 +54,7 @@
hurricane/viewer/SelectionPopup.h
hurricane/viewer/SelectionModel.h
hurricane/viewer/SelectionWidget.h
hurricane/viewer/Ruler.h
hurricane/viewer/NetInformations.h
hurricane/viewer/NetlistWidget.h
hurricane/viewer/DisplayFilterWidget.h
@ -79,6 +81,7 @@
AreaCommand.cpp
MoveCommand.cpp
ZoomCommand.cpp
RulerCommand.cpp
SelectCommand.cpp
HierarchyCommand.cpp
SelectorCriterion.cpp
@ -90,6 +93,7 @@
SelectionPopup.cpp
SelectionModel.cpp
SelectionWidget.cpp
Ruler.cpp
NetInformations.cpp
NetlistModel.cpp
NetlistWidget.cpp

View File

@ -59,6 +59,7 @@ namespace Hurricane {
, _fitToContentsAction(NULL)
, _showSelectionAction(NULL)
, _rubberChangeAction(NULL)
, _clearRulersAction(NULL)
, _controllerAction(NULL)
, _fileMenu(NULL)
, _viewMenu(NULL)
@ -71,6 +72,7 @@ namespace Hurricane {
, _cellWidget(NULL)
, _moveCommand()
, _zoomCommand()
, _rulerCommand()
, _selectCommand()
, _hierarchyCommand()
, _cellHistory()
@ -161,6 +163,11 @@ namespace Hurricane {
_rubberChangeAction->setStatusTip ( tr("Cycle through all avalaibles rubber drawing styles") );
_rubberChangeAction->setShortcut ( Qt::Key_Asterisk );
_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")) );
_controllerAction = new QAction ( tr("Controller"), this );
_controllerAction->setObjectName ( "viewer.menuBar.tools.controller" );
_controllerAction->setStatusTip ( tr("Fine Tune && Inspect DataBase") );
@ -197,6 +204,7 @@ namespace Hurricane {
_viewMenu->addAction ( _fitToContentsAction );
_viewMenu->addAction ( _showSelectionAction );
_viewMenu->addAction ( _rubberChangeAction );
_viewMenu->addAction ( _clearRulersAction );
_toolsMenu = menuBar()->addMenu ( tr("Tools") );
_toolsMenu->setObjectName ( "viewer.menuBar.tools" );
@ -224,6 +232,7 @@ namespace Hurricane {
_cellWidget->bindCommand ( &_moveCommand );
_cellWidget->bindCommand ( &_zoomCommand );
_cellWidget->bindCommand ( &_rulerCommand );
_cellWidget->bindCommand ( &_selectCommand );
_cellWidget->bindCommand ( &_hierarchyCommand );
_controller->setCellWidget ( _cellWidget );
@ -253,6 +262,7 @@ namespace Hurricane {
connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) );
connect ( _showSelectionAction , SIGNAL(toggled(bool)) , this , SLOT(setShowSelection(bool)) );
connect ( _rubberChangeAction , SIGNAL(triggered()) , _cellWidget, SLOT(rubberChange()) );
connect ( _clearRulersAction , SIGNAL(triggered()) , _cellWidget, SLOT(clearRulers()) );
connect ( _controllerAction , SIGNAL(triggered()) , this , SLOT(showController()) );
connect ( _cellWidget , SIGNAL(mousePositionChanged(const Point&))

View File

@ -25,6 +25,7 @@
#include <sys/resource.h>
#include <ctime>
#include <cmath>
#include <QApplication>
#include <QMouseEvent>
@ -129,7 +130,6 @@ namespace Hurricane {
}
// -------------------------------------------------------------------
// Class : "Hurricane::CellWidget::Spot".
@ -372,34 +372,28 @@ namespace Hurricane {
_linePen.setStyle ( Qt::SolidLine );
_linePen.setWidth ( 1 );
if ( _lineMode ) {
_painters[0].setPen ( _linePen );
_painters[1].setPen ( _linePen );
} else {
_painters[0].setPen ( _normalPen );
_painters[1].setPen ( _normalPen );
}
if ( _lineMode ) painter().setPen ( _linePen );
else painter().setPen ( _normalPen );
}
void CellWidget::DrawingPlanes::setBrush ( const QBrush& brush )
{
_painters[PlaneId::Normal ].setBrush ( brush );
_painters[PlaneId::Selection].setBrush ( brush );
painter().setBrush ( brush );
}
void CellWidget::DrawingPlanes::setBackground ( const QBrush& brush )
{
_painters[PlaneId::Normal ].setBackground ( brush );
_painters[PlaneId::Selection].setBackground ( brush );
painter().setBackground ( brush );
painter().setBackground ( brush );
}
void CellWidget::DrawingPlanes::setBackgroundMode ( Qt::BGMode mode )
{
_painters[PlaneId::Normal ].setBackgroundMode ( mode );
_painters[PlaneId::Selection].setBackgroundMode ( mode );
painter().setBackgroundMode ( mode );
painter().setBackgroundMode ( mode );
}
@ -429,49 +423,49 @@ namespace Hurricane {
void CellWidget::DrawingPlanes::shiftLeft ( int dx )
{
paintersBegin ();
buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( dx, 0, *_planes[PlaneId::Normal ], 0, 0, width()-dx, height() );
_painters[PlaneId::Selection].drawPixmap ( dx, 0, *_planes[PlaneId::Selection], 0, 0, width()-dx, height() );
paintersEnd ();
buffersEnd ();
}
void CellWidget::DrawingPlanes::shiftRight ( int dx )
{
paintersBegin ();
buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( 0, 0, *_planes[PlaneId::Normal ], dx, 0, width()-dx, height() );
_painters[PlaneId::Selection].drawPixmap ( 0, 0, *_planes[PlaneId::Selection], dx, 0, width()-dx, height() );
paintersEnd ();
buffersEnd ();
}
void CellWidget::DrawingPlanes::shiftUp ( int dy )
{
paintersBegin ();
buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( 0, dy, *_planes[PlaneId::Normal ], 0, 0, width(), height()-dy );
_painters[PlaneId::Selection].drawPixmap ( 0, dy, *_planes[PlaneId::Selection], 0, 0, width(), height()-dy );
paintersEnd ();
buffersEnd ();
}
void CellWidget::DrawingPlanes::shiftDown ( int dy )
{
paintersBegin ();
buffersBegin ();
_painters[PlaneId::Normal ].drawPixmap ( 0, 0, *_planes[PlaneId::Normal ], 0, dy, width(), height()-dy );
_painters[PlaneId::Selection].drawPixmap ( 0, 0, *_planes[PlaneId::Selection], 0, dy, width(), height()-dy );
paintersEnd ();
buffersEnd ();
}
void CellWidget::DrawingPlanes::copyToSelect ( int sx, int sy, int w, int h )
{
painterBegin ( PlaneId::Selection );
begin ( PlaneId::Selection );
_painters[PlaneId::Selection].setPen ( Qt::NoPen );
_painters[PlaneId::Selection].setBackground ( Graphics::getBrush("background") );
_painters[PlaneId::Selection].eraseRect ( sx, sy, w, h );
//_painters[PlaneId::Selection].setOpacity ( 0.5 );
_painters[PlaneId::Selection].drawPixmap ( sx, sy, *_planes[PlaneId::Normal], sx, sy, w, h );
painterEnd ( PlaneId::Selection );
end ( PlaneId::Selection );
}
@ -506,7 +500,7 @@ namespace Hurricane {
}
_printer = printer;
painterBegin ( PlaneId::Printer );
begin ( PlaneId::Printer );
if ( !imageOnly ) {
QFont font ( "Bitstream Vera Sans", 12 );
@ -556,7 +550,7 @@ namespace Hurricane {
_painters[PlaneId::Printer].drawRect ( ximage-2, 98, w+4, h+4 );
}
painterEnd ( PlaneId::Printer );
end ( PlaneId::Printer );
_printer = NULL;
}
@ -569,7 +563,7 @@ namespace Hurricane {
if ( !image ) return;
_image = image;
painterBegin ( PlaneId::Image );
begin ( PlaneId::Image );
_painters[PlaneId::Image].setRenderHint ( QPainter::Antialiasing, false );
_painters[PlaneId::Image].drawPixmap
@ -597,7 +591,7 @@ namespace Hurricane {
}
}
painterEnd ( PlaneId::Image );
end ( PlaneId::Image );
_image = NULL;
}
@ -785,7 +779,8 @@ namespace Hurricane {
Box bbox = getTransformation().getBox(getMasterCell()->getAbutmentBox());
if ( getDepth() == 2 )
_cellWidget->drawText ( Point(bbox.getXMin(),bbox.getYMin())
, getInstance()->getName()
, getString(getInstance()->getName()).c_str()
, false
, -90
, true
);
@ -1199,8 +1194,7 @@ namespace Hurricane {
_spot.setRestore ( false );
//_drawingPlanes.copyToSelect ( redrawArea );
_drawingPlanes.select ( PlaneId::Normal );
_drawingPlanes.paintersBegin ();
_drawingPlanes.begin ();
_drawingPlanes.painter().setPen ( Qt::NoPen );
_drawingPlanes.painter().setBackground ( Graphics::getBrush("background") );
_drawingPlanes.painter().setClipRect ( redrawArea );
@ -1282,20 +1276,21 @@ namespace Hurricane {
_drawingQuery.doQuery ();
}
}
repaint ();
}
_drawingPlanes.paintersEnd ();
_drawingPlanes.end ();
_cellModificated = false;
}
if ( isDrawable("grid") ) drawGrid ( redrawArea );
if ( isDrawable("text.ruler") ) drawRulers ( redrawArea );
setDarkening ( 100 );
if ( _state->showSelection() )
redrawSelection ( redrawArea );
popCursor ();
repaint ();
// timer.stop ();
// cerr << "CellWidget::redraw() - " << _redrawRectCount
@ -1329,7 +1324,7 @@ namespace Hurricane {
);
_drawingPlanes.select ( PlaneId::Selection );
_drawingPlanes.paintersBegin ();
_drawingPlanes.begin ();
_drawingPlanes.painter().setPen ( Qt::NoPen );
_drawingPlanes.painter().setBackground ( Graphics::getBrush("background") );
_drawingPlanes.painter().setClipRect ( redrawArea );
@ -1398,11 +1393,9 @@ namespace Hurricane {
if ( isDrawable(extensionName) )
_drawingQuery.drawExtensionGo ( this, eGo, NULL, redrawBox, transformation );
}
repaint ();
}
_drawingPlanes.paintersEnd ();
_drawingPlanes.end ();
_selectionHasChanged = false;
}
@ -1477,16 +1470,24 @@ namespace Hurricane {
}
void CellWidget::drawText ( const Point& point, const Name& text, int angle, bool reverse )
void CellWidget::drawText ( const Point& point, const char* text, bool bold, int angle, bool reverse )
{
drawDisplayText ( dbuToDisplayPoint(point), text, bold, angle, reverse );
}
void CellWidget::drawDisplayText ( const QPoint& point, const char* text, bool bold, int angle, bool reverse )
{
_drawingPlanes.painter().save();
if ( reverse ) {
_drawingPlanes.painter().setPen ( Graphics::getPen ("background") );
_drawingPlanes.painter().setBackgroundMode ( Qt::OpaqueMode );
}
_drawingPlanes.painter().translate( dbuToDisplayPoint(point) );
_drawingPlanes.painter().setFont ( Graphics::getNormalFont(bold) );
_drawingPlanes.painter().translate ( point );
_drawingPlanes.painter().rotate ( angle );
_drawingPlanes.painter().drawText ( 0, _textFontHeight, getString(text).c_str() );
_drawingPlanes.painter().drawText ( 0, _textFontHeight, text );
_drawingPlanes.painter().restore ();
}
@ -1551,9 +1552,9 @@ namespace Hurricane {
void CellWidget::drawGrid ( QRect redrawArea )
{
_drawingPlanes.select ( PlaneId::Normal );
_drawingPlanes.painterBegin ();
_drawingPlanes.begin ();
_drawingPlanes.painter ().setClipRect ( redrawArea );
_drawingPlanes.painter ( PlaneId::Normal ).setPen ( Graphics::getPen("grid") );
_drawingPlanes.painter ().setPen ( Graphics::getPen("grid") );
Box redrawBox = displayToDbuBox ( redrawArea ).inflate ( DbU::lambda(1.0) );
@ -1576,22 +1577,196 @@ namespace Hurricane {
center = dbuToDisplayPoint(xGrid,yGrid);
if ( (xGrid % superGridStep) || (yGrid % superGridStep) ) {
if ( detailedGrid ) {
_drawingPlanes.painter(PlaneId::Normal).drawPoint ( center );
_drawingPlanes.painter().drawPoint ( center );
}
} else {
if ( detailedGrid ) {
_drawingPlanes.painter(PlaneId::Normal).drawLine ( center.x()-3, center.y() , center.x()+3, center.y() );
_drawingPlanes.painter(PlaneId::Normal).drawLine ( center.x() , center.y()-3, center.x() , center.y()+3 );
_drawingPlanes.painter().drawLine ( center.x()-3, center.y() , center.x()+3, center.y() );
_drawingPlanes.painter().drawLine ( center.x() , center.y()-3, center.x() , center.y()+3 );
} else {
_drawingPlanes.painter(PlaneId::Normal).drawPoint ( center );
_drawingPlanes.painter().drawPoint ( center );
}
}
}
}
_drawingPlanes.copyToSelect ( redrawArea );
_drawingPlanes.painterEnd ();
repaint ();
_drawingPlanes.end ();
}
void CellWidget::drawRulers ( QRect redrawArea )
{
_drawingPlanes.select ( PlaneId::Normal );
_drawingPlanes.begin ();
_drawingPlanes.painter ().setClipRect ( redrawArea );
redrawArea.adjust ( -50, -50, 50, 50 );
Box redrawBox = displayToDbuBox ( redrawArea );
RulerSet::iterator iruler = _state->getRulers().begin();
RulerSet::iterator end = _state->getRulers().end();
for ( ; iruler != end ; iruler++ ) {
if ( !(*iruler)->intersect(redrawBox) ) continue;
drawRuler ( *iruler );
}
_drawingPlanes.copyToSelect ( redrawArea );
_drawingPlanes.end ();
}
void CellWidget::drawRuler ( shared_ptr<Ruler> ruler )
{
QFont font = Graphics::getNormalFont();
QFontMetrics metrics = QFontMetrics(font);
int tickLength = metrics.width ( "+00000" );
Point origin = ruler->getOrigin ();
Point extremity = ruler->getExtremity ();
Point angle = ruler->getAngle ();
DbU::Unit graduation;
DbU::Unit gradStep;
QPoint pxOrigin;
QPoint pxExtremity;
QPoint pxAngle;
bool onScreen = ( _drawingPlanes.getWorkingPlane() > PlaneId::Selection );
// Never less than 5 pixels between two graduations ticks.
if ( symbolicMode() )
gradStep = DbU::lambda(pow(10.0,ceil(log10(DbU::getLambda(displayToDbuLength(50))))))/10;
else
gradStep = DbU::grid(pow(10.0,ceil(log10(DbU::getGrid(displayToDbuLength(50))))))/10;
if ( onScreen ) {
pxOrigin = dbuToScreenPoint ( origin );
pxExtremity = dbuToScreenPoint ( extremity );
pxAngle = dbuToScreenPoint ( angle );
} else {
pxOrigin = dbuToDisplayPoint ( origin );
pxExtremity = dbuToDisplayPoint ( extremity );
pxAngle = dbuToDisplayPoint ( angle );
}
int pxGrad;
int pyGrad;
string textGrad;
int tick;
_drawingPlanes.painter().setPen ( Graphics::getPen("text.ruler") );
// The horizontal ruler.
bool increase = ( origin.getX() < extremity.getX() );
if ( !increase )
gradStep = -gradStep;
if ( abs(pxAngle.x() - pxOrigin.x()) > 20 ) {
// The horizontal ruler axis.
_drawingPlanes.painter().drawLine ( pxOrigin, pxAngle );
// The horizontal ruler ticks.
for ( graduation=origin.getX(), tick=0 ; true ; graduation+=gradStep, tick++ ) {
if ( increase ) {
if ( graduation >= angle.getX() ) break;
} else
if ( graduation <= angle.getX() ) break;
if ( onScreen ) pxGrad = dbuToScreenX ( graduation );
else pxGrad = dbuToDisplayX ( graduation );
if ( tick % 10 ) {
_drawingPlanes.painter().drawLine ( pxGrad, pxOrigin.y()
, pxGrad, pxOrigin.y()+((tick%2)?5:10) );
} else {
_drawingPlanes.painter().drawLine ( pxGrad, pxOrigin.y()
, pxGrad, pxOrigin.y()+tickLength );
if ( !tick ) continue;
textGrad = DbU::getValueString( gradStep*tick );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxGrad - _textFontHeight - 1
,pxOrigin.y() + tickLength)
, textGrad.c_str()
, true
, -90
, false
);
}
}
// The last horizontal tick.
_drawingPlanes.painter().drawLine ( pxAngle.x(), pxAngle.y()
, pxAngle.x(), pxAngle.y()+tickLength );
textGrad = DbU::getValueString ( angle.getX() - origin.getX() );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxAngle.x() - _textFontHeight - 1
,pxAngle.y() + tickLength)
, textGrad.c_str()
, true
, -90
, false
);
}
if ( abs(pxExtremity.y() - pxAngle.y()) > 20 ) {
// The vertical ruler.
increase = ( angle.getY() < extremity.getY() );
if ( increase xor ( gradStep > 0 ) )
gradStep = -gradStep;
// The vertical ruler axis.
_drawingPlanes.painter().drawLine ( pxAngle, pxExtremity );
// The vertical ruler ticks.
for ( graduation=angle.getY(), tick=0 ; true ; graduation+=gradStep, tick++ ) {
if ( increase ) {
if ( graduation >= extremity.getY() ) break;
} else
if ( graduation <= extremity.getY() ) break;
if ( onScreen ) pyGrad = dbuToScreenY ( graduation );
else pyGrad = dbuToDisplayY ( graduation );
if ( tick % 10 ) {
_drawingPlanes.painter().drawLine ( pxAngle.x() , pyGrad
, pxAngle.x()-((tick%2)?5:10), pyGrad );
} else {
_drawingPlanes.painter().drawLine ( pxAngle.x() , pyGrad
, pxAngle.x()-tickLength, pyGrad );
if ( !tick ) continue;
textGrad = DbU::getValueString( gradStep*tick );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxAngle.x() - tickLength
,pyGrad + 1)
, textGrad.c_str()
, true
, 0
, false
);
}
}
// The last vertical tick.
_drawingPlanes.painter().drawLine ( pxAngle.x() , pxExtremity.y()
, pxAngle.x()-tickLength, pxExtremity.y() );
textGrad = DbU::getValueString( extremity.getY() - angle.getY() );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxAngle.x() - tickLength
,pxExtremity.y() + 1)
, textGrad.c_str()
, true
, 0
, false
);
}
}
@ -1921,13 +2096,16 @@ namespace Hurricane {
// static time_t currTime = 0;
// timer.start ();
_drawingPlanes.painterBegin ( PlaneId::Widget );
_drawingPlanes.pushWorkingPlane ();
_drawingPlanes.select ( PlaneId::Widget );
_drawingPlanes.begin ();
_drawingPlanes.copyToScreen ();
for ( size_t i=0 ; i<_commands.size() ; i++ )
_commands[i]->draw ( this );
if ( isDrawable("spot") ) _spot.moveTo ( _mousePosition );
_drawingPlanes.painterEnd ( PlaneId::Widget );
_drawingPlanes.end ();
_drawingPlanes.popWorkingPlane ();
// timer.stop ();
// time ( &currTime );

View File

@ -49,6 +49,7 @@ namespace Hurricane {
const Name DisplayStyle::Grid = "grid";
const Name DisplayStyle::Spot = "spot";
const Name DisplayStyle::Ghost = "ghost";
const Name DisplayStyle::TextRuler = "text.ruler";
const Name DisplayStyle::TextCell = "text.cell";
const Name DisplayStyle::TextInstance = "text.instance";
const Name DisplayStyle::Undef = "undef";
@ -263,6 +264,7 @@ namespace Hurricane {
addDrawingStyle ( Viewer, Grid , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 8.0 );
addDrawingStyle ( Viewer, Spot , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 8.0 );
addDrawingStyle ( Viewer, Ghost , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
addDrawingStyle ( Viewer, TextRuler , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 0.0 );
addDrawingStyle ( Viewer, TextCell , "8822441188224411", 255, 255, 255, 0, 1.0 );
addDrawingStyle ( Viewer, TextInstance , "8822441188224411", 255, 255, 255, 0, 1.0 );
addDrawingStyle ( Viewer, Undef , "2244118822441188", 238, 130, 238, 0, 1.0 );

View File

@ -39,7 +39,6 @@ namespace Hurricane {
MoveCommand::MoveCommand ()
: Command ()
, _active (false)
, _firstEvent (true)
, _lastPosition()
{ }
@ -60,8 +59,8 @@ namespace Hurricane {
case Qt::Key_Left: widget->goLeft (); return true;
case Qt::Key_Right: widget->goRight (); return true;
case Qt::Key_Space:
if ( !_active ) {
_active = true;
if ( !isActive() ) {
setActive ( true );
_firstEvent = true;
//_lastPosition = widget->getMousePosition();
widget->pushCursor ( Qt::ClosedHandCursor );
@ -76,8 +75,8 @@ namespace Hurricane {
{
switch ( event->key() ) {
case Qt::Key_Space:
if ( _active && !event->isAutoRepeat() ) {
_active = false;
if ( isActive() && !event->isAutoRepeat() ) {
setActive ( false );
widget->popCursor ();
return true;
}
@ -89,7 +88,7 @@ namespace Hurricane {
bool MoveCommand::mouseMoveEvent ( CellWidget* widget, QMouseEvent* event )
{
if ( !_active ) return false;
if ( !isActive() ) return false;
QPoint eventPosition = event->pos();
if ( _firstEvent ) { _firstEvent = false; _lastPosition = eventPosition; }
@ -113,13 +112,13 @@ namespace Hurricane {
bool MoveCommand::mousePressEvent ( CellWidget* widget, QMouseEvent* event )
{
return _active;
return isActive();
}
bool MoveCommand::mouseReleaseEvent ( CellWidget* widget, QMouseEvent* event )
{
return _active;
return isActive();
}

View File

@ -0,0 +1,55 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./Ruler.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include "hurricane/viewer/Ruler.h"
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::Ruler".
Ruler::Ruler ( const Point& origin )
: _origin (origin)
, _extremity(origin)
{ }
Ruler::Ruler ( const Point& origin, const Point& extremity )
: _origin (origin)
, _extremity(extremity)
{ }
bool Ruler::intersect ( const Box& area ) const
{
Point angle = getAngle ();
return area.intersect(Box(_origin,angle)) || area.intersect(Box(angle,_extremity));
}
} // End of Hurricane namespace.

View File

@ -0,0 +1,109 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./RulerCommand.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include <QMouseEvent>
# include <QKeyEvent>
# include <hurricane/viewer/CellWidget.h>
# include <hurricane/viewer/RulerCommand.h>
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "RulerCommand".
RulerCommand::RulerCommand ()
: Command ()
, _ruler ()
{ }
RulerCommand::~RulerCommand ()
{ }
bool RulerCommand::keyPressEvent ( CellWidget* widget, QKeyEvent* event )
{
return false;
}
bool RulerCommand::keyReleaseEvent ( CellWidget* widget, QKeyEvent* event )
{
return false;
}
bool RulerCommand::mouseMoveEvent ( CellWidget* widget, QMouseEvent* event )
{
if ( !isActive() ) return false;
_ruler->setExtremity ( widget->_onSnapGrid(widget->screenToDbuPoint(event->pos())) );
widget->update ();
return true;
}
bool RulerCommand::mousePressEvent ( CellWidget* widget, QMouseEvent* event )
{
if ( event->modifiers() & Qt::ShiftModifier ) {
if ( event->button() == Qt::LeftButton ) {
if ( !isActive() ) {
setActive ( true );
_ruler.reset ( new Ruler
(widget->_onSnapGrid(widget->screenToDbuPoint(widget->getMousePosition())) ) );
return true;
} else {
widget->addRuler ( _ruler );
setActive ( false );
_ruler.reset ();
}
} else if ( event->button() == Qt::RightButton ){
if ( isActive() ) {
setActive ( false );
_ruler.reset ();
}
}
}
return isActive();
}
bool RulerCommand::mouseReleaseEvent ( CellWidget* widget, QMouseEvent* event )
{ return false; }
void RulerCommand::draw ( CellWidget* widget )
{
if ( !isActive() ) return;
widget->drawRuler ( _ruler );
}
} // End of Hurricane namespace.

View File

@ -44,6 +44,7 @@ class QMenu;
#include "hurricane/viewer/MoveCommand.h"
#include "hurricane/viewer/ZoomCommand.h"
#include "hurricane/viewer/RulerCommand.h"
#include "hurricane/viewer/SelectCommand.h"
#include "hurricane/viewer/HierarchyCommand.h"
#include "hurricane/viewer/CellWidget.h"
@ -105,6 +106,7 @@ namespace Hurricane {
QAction* _fitToContentsAction;
QAction* _showSelectionAction;
QAction* _rubberChangeAction;
QAction* _clearRulersAction;
QAction* _controllerAction;
QMenu* _fileMenu;
QMenu* _viewMenu;
@ -117,6 +119,7 @@ namespace Hurricane {
CellWidget* _cellWidget;
MoveCommand _moveCommand;
ZoomCommand _zoomCommand;
RulerCommand _rulerCommand;
SelectCommand _selectCommand;
HierarchyCommand _hierarchyCommand;
list< shared_ptr<CellWidget::State> >

View File

@ -60,6 +60,7 @@ class QAction;
#include "hurricane/viewer/CellWidgets.h"
#include "hurricane/viewer/Selector.h"
#include "hurricane/viewer/SelectorCriterion.h"
#include "hurricane/viewer/Ruler.h"
@ -92,6 +93,10 @@ namespace Hurricane {
};
// -------------------------------------------------------------------
// Class : "Hurricane::CellWidget".
class CellWidget : public QWidget {
Q_OBJECT;
@ -123,6 +128,7 @@ namespace Hurricane {
inline Occurrences getOccurrencesUnder ( const QRect& ) const;
Occurrences getOccurrencesUnder ( const Box& ) const;
inline SelectorSet& getSelectorSet ();
inline RulerSet& getRulerSet ();
inline RubberShape getRubberShape () const;
inline int getStartLevel () const;
inline int getStopLevel () const;
@ -163,9 +169,12 @@ namespace Hurricane {
void drawBox ( const Box& );
void drawLine ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit, bool mode=true );
void drawLine ( const Point&, const Point&, bool mode=true );
void drawText ( const Point&, const Name&, int angle=0, bool reverse=false );
void drawText ( const Point&, const char*, bool bold=false, int angle=0, bool reverse=false );
void drawGrid ( QRect );
void drawSpot ();
void drawRuler ( shared_ptr<Ruler> );
void drawRulers ( QRect );
void drawDisplayText ( const QPoint&, const char*, bool bold=false, int angle=0, bool reverse=false );
void drawScreenLine ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working, bool mode=true );
void drawScreenRect ( const QPoint&, const QPoint&, size_t plane=PlaneId::Working );
void drawScreenRect ( const QRect& , size_t plane=PlaneId::Working );
@ -190,6 +199,7 @@ namespace Hurricane {
inline DbU::Unit screenToDbuY ( int y ) const;
inline Point screenToDbuPoint ( const QPoint& point ) const;
inline Box screenToDbuBox ( const QRect& rect ) const;
inline Box& pixelInflate ( Box&, int pixels ) const;
inline Point getTopLeft () const;
Box computeVisibleArea ( float scale ) const;
Box computeVisibleArea ( float scale, const Point& topLeft ) const;
@ -197,6 +207,7 @@ namespace Hurricane {
inline bool _underDetailedGridThreshold() const;
inline DbU::Unit _snapGridStep () const;
inline DbU::Unit _onSnapGrid ( DbU::Unit ) const;
inline Point _onSnapGrid ( const Point& ) const;
// Qt QWidget Functions Overloads.
void pushCursor ( Qt::CursorShape cursor );
void popCursor ();
@ -245,6 +256,9 @@ namespace Hurricane {
void _unselect ( const Net* );
void _selectOccurrencesUnder ( Box selectArea );
void _unselectAll ();
inline void addRuler ( const Point&, const Point& );
inline void addRuler ( shared_ptr<Ruler> );
inline void clearRulers ();
void changeQueryFilter ();
void rubberChange ();
void changeLayoutMode ();
@ -355,15 +369,18 @@ namespace Hurricane {
DrawingPlanes ( const QSize& size, CellWidget* cw );
~DrawingPlanes ();
inline bool getLineMode () const;
inline size_t getWorkingPlane () const;
inline void pushWorkingPlane ();
inline void popWorkingPlane ();
inline int width () const;
inline int height () const;
inline QSize size () const;
inline void select ( size_t i );
inline QPainter& painter ( size_t i=PlaneId::Working );
inline void painterBegin ( size_t i=PlaneId::Working );
inline void paintersBegin ();
inline void painterEnd ( size_t i=PlaneId::Working );
inline void paintersEnd ();
inline void begin ( size_t i=PlaneId::Working );
inline void end ( size_t i=PlaneId::Working );
inline void buffersBegin ();
inline void buffersEnd ();
void setLineMode ( bool mode );
void setPen ( const QPen& pen );
void setBrush ( const QBrush& brush );
@ -392,6 +409,7 @@ namespace Hurricane {
QPen _normalPen;
QPen _linePen;
size_t _workingPlane;
size_t _pushWorkingPlane;
bool _lineMode;
private:
DrawingPlanes ( const DrawingPlanes& );
@ -514,6 +532,7 @@ namespace Hurricane {
inline Cell* getCell () const;
const Name& getName () const;
inline SelectorCriterions& getSelection ();
inline RulerSet& getRulers ();
inline bool realMode () const;
inline bool symbolicMode () const;
inline bool showBoundaries () const;
@ -541,6 +560,7 @@ namespace Hurricane {
Cell* _cell;
CellWidget* _cellWidget;
SelectorCriterions _selection;
RulerSet _rulers;
bool _symbolicMode;
bool _showBoundaries;
bool _showSelection;
@ -708,6 +728,18 @@ namespace Hurricane {
{ return _lineMode; }
inline size_t CellWidget::DrawingPlanes::getWorkingPlane () const
{ return _workingPlane; }
inline void CellWidget::DrawingPlanes::pushWorkingPlane ()
{ _pushWorkingPlane = _workingPlane; }
inline void CellWidget::DrawingPlanes::popWorkingPlane ()
{ _workingPlane = _pushWorkingPlane; }
inline int CellWidget::DrawingPlanes::width () const
{ return _planes[PlaneId::Normal]->width(); }
@ -728,34 +760,36 @@ namespace Hurricane {
{ return _painters[ (i>=PlaneId::Working) ? _workingPlane : i ]; }
inline void CellWidget::DrawingPlanes::painterBegin ( size_t i )
inline void CellWidget::DrawingPlanes::begin ( size_t i )
{
switch ( i ) {
case PlaneId::Working: i = _workingPlane;
size_t wp = (i>=PlaneId::Working) ? _workingPlane : i;
switch ( wp ) {
case PlaneId::Normal:
case PlaneId::Selection: _painters[i].begin ( _planes[i] ); break;
case PlaneId::Selection: _painters[wp].begin ( _planes[wp] ); break;
case PlaneId::Widget: _painters[ 2].begin ( _cellWidget ); break;
case PlaneId::Printer: _painters[ 3].begin ( _printer ); break;
case PlaneId::Image: _painters[ 4].begin ( _image ); break;
default:
cerr << "[BUG] Bad plane selection." << endl;
}
}
inline void CellWidget::DrawingPlanes::paintersBegin ()
{
painterBegin ( PlaneId::Normal );
painterBegin ( PlaneId::Selection );
}
inline void CellWidget::DrawingPlanes::painterEnd ( size_t i )
inline void CellWidget::DrawingPlanes::end ( size_t i )
{ _painters[(i>=PlaneId::Working)?_workingPlane:i].end (); }
inline void CellWidget::DrawingPlanes::paintersEnd ()
inline void CellWidget::DrawingPlanes::buffersBegin ()
{
painterEnd ( PlaneId::Normal );
painterEnd ( PlaneId::Selection );
begin ( PlaneId::Normal );
begin ( PlaneId::Selection );
}
inline void CellWidget::DrawingPlanes::buffersEnd ()
{
end ( PlaneId::Normal );
end ( PlaneId::Selection );
}
@ -811,6 +845,7 @@ namespace Hurricane {
: _cell (cell)
, _cellWidget (NULL)
, _selection ()
, _rulers ()
, _symbolicMode (true)
, _showBoundaries (true)
, _showSelection (false)
@ -901,6 +936,10 @@ namespace Hurricane {
{ return _selection; }
inline RulerSet& CellWidget::State::getRulers ()
{ return _rulers; }
inline bool CellWidget::State::showBoundaries () const
{ return _showBoundaries; }
@ -1009,6 +1048,24 @@ namespace Hurricane {
{ return _offsetVA; }
inline void CellWidget::addRuler ( const Point& origin, const Point& extremity )
{
_state->getRulers().insert ( shared_ptr<Ruler>( new Ruler(origin,extremity) ) );
refresh ();
}
inline void CellWidget::addRuler ( shared_ptr<Ruler> ruler )
{
_state->getRulers().insert ( ruler );
refresh ();
}
inline void CellWidget::clearRulers ()
{ _state->getRulers().clear (); refresh(); }
inline void CellWidget::refresh ()
{ _redrawManager.refresh(); }
@ -1093,6 +1150,10 @@ namespace Hurricane {
}
inline Box& CellWidget::pixelInflate ( Box& box, int pixels ) const
{ return box.inflate(displayToDbuLength(pixels)); }
inline Point CellWidget::getTopLeft () const
{ return Point(_visibleArea.getXMin(),_visibleArea.getYMax()); }
@ -1144,9 +1205,7 @@ namespace Hurricane {
inline void CellWidget::updateMousePosition ()
{
Point mousePoint = screenToDbuPoint ( _mousePosition );
emit mousePositionChanged ( Point ( _onSnapGrid(mousePoint.getX())
, _onSnapGrid(mousePoint.getY())
) );
emit mousePositionChanged ( _onSnapGrid(mousePoint) );
}
@ -1200,6 +1259,10 @@ namespace Hurricane {
{ return symbolicMode() ? DbU::getOnSymbolicSnapGrid(u) : DbU::getOnRealSnapGrid(u); }
inline Point CellWidget::_onSnapGrid ( const Point& p ) const
{ return Point(_onSnapGrid(p.getX()),_onSnapGrid(p.getY())); }
} // End of Hurricane namespace.

View File

@ -57,7 +57,7 @@ namespace Hurricane {
virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* );
virtual void draw ( CellWidget* );
inline set<CellWidget*>& getCellWidgets ();
protected:
private:
set<CellWidget*> _cellWidgets;
bool _active;
private:

View File

@ -153,6 +153,7 @@ namespace Hurricane {
static const Name Grid;
static const Name Spot;
static const Name Ghost;
static const Name TextRuler;
static const Name TextCell;
static const Name TextInstance;
static const Name Undef;

View File

@ -43,8 +43,7 @@ namespace Hurricane {
virtual bool mouseMoveEvent ( CellWidget*, QMouseEvent* );
virtual bool mousePressEvent ( CellWidget*, QMouseEvent* );
virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* );
protected:
bool _active;
private:
bool _firstEvent;
QPoint _lastPosition;
private:

View File

@ -0,0 +1,71 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | C O R I O L I S |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Header : "./Ruler.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_RULER__
#define __HURRICANE_RULER__
#include <tr1/memory>
#include <set>
#include "hurricane/Point.h"
#include "hurricane/Box.h"
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::Ruler".
class Ruler {
public:
Ruler ( const Point& origin );
Ruler ( const Point& origin, const Point& extremity );
inline const Point& getOrigin () const;
inline const Point& getExtremity () const;
inline Point getAngle () const;
inline Box getBoundingBox () const;
inline void setExtremity ( const Point& );
bool intersect ( const Box& ) const;
private:
Point _origin;
Point _extremity;
};
// Inline Functions.
inline const Point& Ruler::getOrigin () const { return _origin; }
inline const Point& Ruler::getExtremity () const { return _extremity; }
inline Point Ruler::getAngle () const { return Point(_extremity.getX(),_origin.getY()); }
inline Box Ruler::getBoundingBox () const { return Box(_origin,_extremity); }
inline void Ruler::setExtremity ( const Point& extremity ) { _extremity = extremity; }
typedef std::set< std::tr1::shared_ptr<Ruler> > RulerSet;
} // End of Hurricane namespace.
#endif // __HURRICANE_RULER__

View File

@ -0,0 +1,60 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// | H U R R I C A N E |
// | V L S I B a c k e n d D a t a - B a s e |
// | |
// | Author : Jean-Paul CHAPUT |
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Header : "./RulerCommand.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_RULER_COMMAND__
#define __HURRICANE_RULER_COMMAND__
#include <QPoint>
#include "hurricane/viewer/Command.h"
#include "hurricane/viewer/Ruler.h"
namespace Hurricane {
class RulerCommand : public Command {
public:
RulerCommand ();
virtual ~RulerCommand ();
virtual bool keyPressEvent ( CellWidget*, QKeyEvent* );
virtual bool keyReleaseEvent ( CellWidget*, QKeyEvent* );
virtual bool mouseMoveEvent ( CellWidget*, QMouseEvent* );
virtual bool mousePressEvent ( CellWidget*, QMouseEvent* );
virtual bool mouseReleaseEvent ( CellWidget*, QMouseEvent* );
virtual void draw ( CellWidget* );
protected:
bool _active;
std::tr1::shared_ptr<Ruler> _ruler;
private:
RulerCommand ( const RulerCommand& );
RulerCommand& operator= ( const RulerCommand& );
};
}
#endif