* ./hurricane/src/hurricane :

- New feature: support for breakpoints with a selectable stop level.
        See Breakpoint.h. Graphical popup automatically when Graphics is
        enabled.
          User can select what to do when a breakpoint is reached and valid
        through a callback mechanism.
          A disabled example is avalaible in GraphicKatabaticEngine.cpp.
    - Ergonomy : reverse the zooming direction of the mouse weel (some said
        it's like in MS Word...).
    - Bug: accept zoom when bottom right is below lower left (absolute value).
This commit is contained in:
Jean-Paul Chaput 2009-01-09 15:18:26 +00:00
parent ddc3e541f1
commit 529594618e
12 changed files with 456 additions and 79 deletions

View File

@ -0,0 +1,131 @@
// -*- 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@lip6.fr |
// | =============================================================== |
// | C++ Module : "./Breakpoint.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# include "hurricane/Breakpoint.h"
namespace {
using namespace std;
using namespace Hurricane;
bool simpleStopCb ( const string& message )
{
cerr << "[STOP] " << message << endl;
char answer = '?';
while ( answer == '?' ) {
cerr << " Type <y> to continue, <n> to abort: (y) ";
cerr.flush ();
cin >> answer;
switch ( answer ) {
case 'Y':
case 'y': answer = 'y'; break;
case 'N':
case 'n': answer = 'n'; break;
default: answer = '?';
}
}
return (answer == 'y');
}
} // End of anonymous namespace.
namespace Hurricane {
// -------------------------------------------------------------------
// Class : "Hurricane::Breakpoint".
Breakpoint* Breakpoint::_singleton = NULL;
Breakpoint::StopCb_t* Breakpoint::_stopCb = NULL;
unsigned int Breakpoint::_stopLevel = 0;
Breakpoint::Breakpoint ()
{ }
Breakpoint::~Breakpoint ()
{
delete _singleton;
}
Breakpoint* Breakpoint::get ()
{
if ( !_singleton ) {
_singleton = new Breakpoint ();
if ( !_stopCb )
_singleton->setStopCb ( simpleStopCb );
}
return _singleton;
}
void Breakpoint::setStopCb ( Breakpoint::StopCb_t* cb )
{
cerr << "Breakpoint::setStopCb() - " << (void*)cb << endl;
_stopCb = cb;
}
bool Breakpoint::stop ( unsigned int level, const string message )
{
return get()->_stop ( level, message );
}
void Breakpoint::setStopLevel ( unsigned int level )
{
_stopLevel = level;
}
unsigned int Breakpoint::getStopLevel ()
{
return _stopLevel;
}
bool Breakpoint::_stop ( unsigned int level, const string& message )
{
if ( _stopCb && ( level <= _stopLevel ) )
return _stopCb ( message );
return false;
}
} // End of Hurricane namespace.

View File

@ -23,6 +23,7 @@
hurricane/Bug.h
hurricane/Error.h
hurricane/Exception.h
hurricane/Breakpoint.h
hurricane/Filter.h
hurricane/Go.h hurricane/Gos.h
hurricane/ExtensionGo.h hurricane/ExtensionGos.h
@ -88,6 +89,7 @@
Exception.cpp
Bug.cpp
Error.cpp
Breakpoint.cpp
DRCError.cpp
Warning.cpp
Interruption.cpp

View File

@ -0,0 +1,65 @@
// -*- 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@lip6.fr |
// | =============================================================== |
// | C++ Header : "./Breakpoint.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
# ifndef __HURRICANE_BREAKPOINT__
# define __HURRICANE_BREAKPOINT__
#include "hurricane/Commons.h"
namespace Hurricane {
class Breakpoint {
public:
typedef bool ( StopCb_t )( const string& );
public:
static Breakpoint* get ();
static void setStopCb ( StopCb_t* );
static bool stop ( unsigned int, const string );
static void setStopLevel ( unsigned int );
static unsigned int getStopLevel ();
protected:
bool _stop ( unsigned int, const string& );
protected:
static Breakpoint* _singleton;
static StopCb_t* _stopCb;
static unsigned int _stopLevel;
protected:
Breakpoint ();
Breakpoint ( const Breakpoint& );
Breakpoint& operator= ( const Breakpoint& );
~Breakpoint ();
};
} // End of Hurricane namespace.
# endif // __HURRICANE_BREAKPOINT__

View File

@ -0,0 +1,101 @@
// -*- 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 : "./BreakpointWidget.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#include <QLabel>
#include <QPushButton>
#include <QSpinBox>
#include <QGridLayout>
#include <QFrame>
#include "hurricane/Breakpoint.h"
#include "hurricane/viewer/BreakpointWidget.h"
namespace Hurricane {
BreakpointWidget::BreakpointWidget ( QWidget* parent )
: QDialog (parent)
, _message (new QLabel())
, _stopLevel(new QSpinBox())
{
setModal ( true );
setWindowTitle ( "Breakpoint" );
setToolTip ( "Crush the Mush to continue..." );
_message->setTextFormat ( Qt::RichText );
_message->setText ( "<b>No Message Yet</b>" );
QLabel* stopLabel = new QLabel ();
stopLabel->setText ( "Adjust Stop Level:" );
QPushButton* ok = new QPushButton ();
ok->setIcon ( QIcon(":/images/gnome-gmush.png") );
ok->setFlat ( true );
ok->setIconSize ( QSize(48,48) );
QFrame* vLine = new QFrame ();
vLine->setFrameShape ( QFrame::VLine );
vLine->setFrameShadow ( QFrame::Sunken );
QGridLayout* layout = new QGridLayout ();
layout->addWidget ( ok , 0, 0, 2, 1, Qt::AlignVCenter );
layout->addWidget ( vLine , 0, 1, 2, 1 );
layout->addWidget ( _message , 0, 2 );
layout->addWidget ( stopLabel , 1, 2 );
layout->addWidget ( _stopLevel, 1, 3 );
setLayout ( layout );
connect ( ok , SIGNAL(clicked()) , this, SLOT(accept()) );
connect ( _stopLevel, SIGNAL(valueChanged(int)), this, SLOT(updateStopLevel(int)) );
}
void BreakpointWidget::setMessage ( const QString& message )
{
_message->setText ( message );
}
void BreakpointWidget::setStopLevel ( int level )
{
_stopLevel->setValue ( level );
}
int BreakpointWidget::getStopLevel () const
{
return _stopLevel->value ();
}
void BreakpointWidget::updateStopLevel ( int value )
{
unsigned int stopLevel = (value<0) ? 0 : value;
Breakpoint::setStopLevel ( stopLevel );
}
} // End of Hurricane Namespace.

View File

@ -10,6 +10,7 @@
hurricane/viewer/PaletteExtensionGoItem.h
hurricane/viewer/PaletteWidget.h
hurricane/viewer/GraphicsWidget.h
hurricane/viewer/BreakpointWidget.h
hurricane/viewer/DynamicLabel.h
hurricane/viewer/MousePositionWidget.h
hurricane/viewer/SelectCommand.h
@ -31,6 +32,7 @@
hurricane/viewer/ColorScale.h
hurricane/viewer/Graphics.h
hurricane/viewer/GraphicsWidget.h
hurricane/viewer/BreakpointWidget.h
hurricane/viewer/Selector.h
hurricane/viewer/Command.h
hurricane/viewer/AreaCommand.h
@ -56,6 +58,7 @@
ColorScale.cpp
Graphics.cpp
GraphicsWidget.cpp
BreakpointWidget.cpp
PaletteItem.cpp
PaletteNamedItem.cpp
PaletteLayerItem.cpp

View File

@ -9,5 +9,6 @@
<file>images/gtk-go-forward-rtl.png</file>
<file>images/gtk-go-forward-ltr.png</file>
<file>images/swiss-knife.png</file>
<file>images/gnome-gmush.png</file>
</qresource>
</RCC>

View File

@ -541,7 +541,7 @@ namespace Hurricane {
, _cellWidget(widget)
, _drawExtensionGo(NULL)
, _goCount(0)
, _goExtensionCount(0)
, _extensionGoCount(0)
, _instanceCount(0)
{ }
@ -633,7 +633,7 @@ namespace Hurricane {
)
{
if ( _drawExtensionGo ) {
_goExtensionCount++;
_extensionGoCount++;
_drawExtensionGo ( widget, go, basicLayer, area, transformation );
}
}
@ -1029,7 +1029,7 @@ namespace Hurricane {
Box redrawBox = displayToDbuBox ( redrawArea );
_drawingQuery.resetGoCount ();
_drawingQuery.resetGoExtensionCount();
_drawingQuery.resetExtensionGoCount();
_drawingQuery.resetInstanceCount();
_drawingQuery.setExtensionMask ( 0 );
_drawingQuery.setArea ( redrawBox );
@ -1129,9 +1129,9 @@ namespace Hurricane {
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoCount()) << " s/go)";
else
cerr << " 0 Gos";
if ( _drawingQuery.getGoExtensionCount() )
cerr << " " << _drawingQuery.getGoExtensionCount()
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getGoExtensionCount()) << " s/ego)";
if ( _drawingQuery.getExtensionGoCount() )
cerr << " " << _drawingQuery.getExtensionGoCount()
<< " (" << setprecision(3) << (timer.getCombTime()/_drawingQuery.getExtensionGoCount()) << " s/ego)";
else
cerr << " 0 eGos";
if ( _drawingQuery.getInstanceCount() )
@ -1751,23 +1751,21 @@ namespace Hurricane {
QRect CellWidget::dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint ) const
{
int width, height;
if ( usePoint ) {
int width = dbuToDisplayX(x2) - dbuToDisplayX(x1);
int height = dbuToDisplayY(y1) - dbuToDisplayY(y2);
return QRect ( dbuToDisplayX(x1)
, dbuToDisplayY(y2)
, width?width:1
, height?height:1
);
width = dbuToDisplayX(x2) - dbuToDisplayX(x1);
height = dbuToDisplayY(y1) - dbuToDisplayY(y2);
} else {
int width = dbuToDisplayLength ( x2 - x1 );
int height = dbuToDisplayLength ( y2 - y1 );
return QRect ( dbuToDisplayX(x1)
, dbuToDisplayY(y2)
, width?width:1
, height?height:1
);
width = dbuToDisplayLength ( x2 - x1 );
height = dbuToDisplayLength ( y2 - y1 );
}
return QRect ( dbuToDisplayX(x1)
, dbuToDisplayY(y2)
, width ? width : 1
, height ? height : 1
);
}

View File

@ -2,7 +2,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2008, All Rights Reserved
// Copyright (c) UPMC/LIP6 2008-2009, All Rights Reserved
//
// ===================================================================
//
@ -25,15 +25,15 @@
# include <assert.h>
# include <Qt>
# include <QBrush>
# include <QPen>
# include <QApplication>
#include <Qt>
#include <QBrush>
#include <QPen>
#include <QApplication>
# include "hurricane/Name.h"
#include "hurricane/Name.h"
# include "hurricane/viewer/DisplayStyle.h"
# include "hurricane/viewer/Graphics.h"
#include "hurricane/viewer/DisplayStyle.h"
#include "hurricane/viewer/Graphics.h"
@ -104,6 +104,8 @@ namespace Hurricane {
_styles[si]->qtAllocate ();
_fireColorScale.qtAllocate ();
Breakpoint::setStopCb ( Graphics::breakpointStopCb );
}
@ -271,6 +273,18 @@ namespace Hurricane {
}
bool Graphics::breakpointStopCb ( const string& message )
{
static BreakpointWidget* bpw = NULL;
if ( !bpw )
bpw = new BreakpointWidget ();
bpw->setMessage ( message.c_str() );
return ( bpw->exec() == QDialog::Accepted );
}
} // End of Hurricane namespace.

View File

@ -60,8 +60,8 @@ namespace Hurricane {
bool ZoomCommand::keyPressEvent ( CellWidget* widget, QKeyEvent* event )
{
switch ( event->key() ) {
case Qt::Key_Z: widget->setScale ( widget->getScale()*2.0 ); return true;
case Qt::Key_M: widget->setScale ( widget->getScale()/2.0 ); return true;
case Qt::Key_Z: widget->setScale ( widget->getScale()/2.0 ); return true;
case Qt::Key_M: widget->setScale ( widget->getScale()*2.0 ); return true;
}
return false;
}
@ -89,7 +89,7 @@ namespace Hurricane {
setDrawingEnabled ( false );
QRect zoomArea = QRect ( _startPoint, _stopPoint );
if ( ( zoomArea.width() > 10 ) && ( zoomArea.height() > 10 ) )
if ( ( abs(zoomArea.width()) > 10 ) && ( abs(zoomArea.height()) > 10 ) )
widget->reframe ( widget->screenToDbuBox(zoomArea) );
else {
cerr << Warning("Rejecting too small zoom request.") << endl;

View File

@ -0,0 +1,59 @@
// -*- 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 : "./BreakpointWidget.h" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
#ifndef __HURRICANE_BREAKPOINT_WIDGET__
#define __HURRICANE_BREAKPOINT_WIDGET__
#include <QDialog>
class QLabel;
class QSpinBox;
namespace Hurricane {
class BreakpointWidget : public QDialog {
Q_OBJECT;
public:
BreakpointWidget ( QWidget* parent=NULL);
void setMessage ( const QString& );
int getStopLevel () const;
void setStopLevel ( int );
public slots:
void updateStopLevel ( int );
private:
QLabel* _message;
QSpinBox* _stopLevel;
};
} // End of Hurricane namespace.
#endif // __HURRICANE_BREAKPOINT_WIDGET__

View File

@ -386,10 +386,10 @@ namespace Hurricane {
, const Transformation& transformation
);
inline unsigned int getGoCount () const;
inline unsigned int getGoExtensionCount () const;
inline unsigned int getExtensionGoCount () const;
inline unsigned int getInstanceCount () const;
inline void resetGoCount ();
inline void resetGoExtensionCount ();
inline void resetExtensionGoCount ();
inline void resetInstanceCount ();
protected:
@ -398,7 +398,7 @@ namespace Hurricane {
map<Name,pair<InitExtensionGo_t*,DrawExtensionGo_t*> >
_drawExtensionGos;
unsigned int _goCount;
unsigned int _goExtensionCount;
unsigned int _extensionGoCount;
unsigned int _instanceCount;
};
@ -511,8 +511,8 @@ namespace Hurricane {
{ _goCount = 0; }
inline void CellWidget::DrawingQuery::resetGoExtensionCount ()
{ _goExtensionCount = 0; }
inline void CellWidget::DrawingQuery::resetExtensionGoCount ()
{ _extensionGoCount = 0; }
inline void CellWidget::DrawingQuery::resetInstanceCount ()
@ -523,8 +523,8 @@ namespace Hurricane {
{ return _goCount; }
inline unsigned int CellWidget::DrawingQuery::getGoExtensionCount () const
{ return _goExtensionCount; }
inline unsigned int CellWidget::DrawingQuery::getExtensionGoCount () const
{ return _extensionGoCount; }
inline unsigned int CellWidget::DrawingQuery::getInstanceCount () const

View File

@ -30,8 +30,10 @@
#include <string>
#include <vector>
#include "hurricane/Breakpoint.h"
#include "hurricane/viewer/DisplayStyle.h"
#include "hurricane/viewer/ColorScale.h"
#include "hurricane/viewer/BreakpointWidget.h"
#include <QFont>
@ -52,27 +54,28 @@ namespace Hurricane {
public:
// Accessors.
static Graphics* getGraphics ();
static bool isEnabled ();
static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false );
static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false );
static const Name& getGroup ( const Name& key );
static QColor getColor ( const Name& key, int darkening=100 );
static QPen getPen ( const Name& key, int darkening=100 );
static QBrush getBrush ( const Name& key, int darkening=100 );
static const string& getPattern ( const Name& key );
static float getThreshold ( const Name& key );
static int getDarkening ();
static const ColorScale& getColorScale ( ColorScale::ScaleType );
static Graphics* getGraphics ();
static bool isEnabled ();
static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false );
static const QFont getNormalFont ( bool bold=false, bool italic=false, bool underline=false );
static const Name& getGroup ( const Name& key );
static QColor getColor ( const Name& key, int darkening=100 );
static QPen getPen ( const Name& key, int darkening=100 );
static QBrush getBrush ( const Name& key, int darkening=100 );
static const string& getPattern ( const Name& key );
static float getThreshold ( const Name& key );
static int getDarkening ();
static const ColorScale& getColorScale ( ColorScale::ScaleType );
static bool breakpointStopCb ( const string& message );
// Modifiers.
static void addStyle ( DisplayStyle* displayStyle );
static void setStyle ( const Name& key );
static void setStyle ( size_t id );
static DisplayStyle* getStyle ( const Name& key );
static DisplayStyle* getStyle ();
static const vector<DisplayStyle*>& getStyles ();
static void enable ();
static void addStyle ( DisplayStyle* displayStyle );
static void setStyle ( const Name& key );
static void setStyle ( size_t id );
static DisplayStyle* getStyle ( const Name& key );
static DisplayStyle* getStyle ();
static const vector<DisplayStyle*>& getStyles ();
static void enable ();
// Internals - Attributes.
protected:
@ -83,28 +86,28 @@ namespace Hurricane {
bool _qtEnabled;
// Internals - Constructors & Destructors.
Graphics ();
Graphics ( const Graphics& );
Graphics& operator= ( const Graphics& );
~Graphics ();
// Internals - Methods.
size_t _findStyle ( const Name& key ) const;
void _addStyle ( DisplayStyle* displayStyle );
void _setStyle ( const Name& key );
void _setStyle ( size_t id );
DisplayStyle* _getStyle ( const Name& key );
DisplayStyle* _getStyle () const;
inline const vector<DisplayStyle*>& _getStyles () const;
inline const Name& _getGroup ( const Name& key ) const;
inline QColor _getColor ( const Name& key, int darkening ) const;
inline QPen _getPen ( const Name& key, int darkening ) const;
inline QBrush _getBrush ( const Name& key, int darkening ) const;
inline const string& _getPattern ( const Name& key ) const;
inline float _getThreshold ( const Name& key ) const;
inline int _getDarkening () const;
inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
inline void _enable ();
Graphics ();
Graphics ( const Graphics& );
Graphics& operator= ( const Graphics& );
~Graphics ();
// Internals - Methods.
size_t _findStyle ( const Name& key ) const;
void _addStyle ( DisplayStyle* displayStyle );
void _setStyle ( const Name& key );
void _setStyle ( size_t id );
DisplayStyle* _getStyle ( const Name& key );
DisplayStyle* _getStyle () const;
inline const vector<DisplayStyle*>& _getStyles () const;
inline const Name& _getGroup ( const Name& key ) const;
inline QColor _getColor ( const Name& key, int darkening ) const;
inline QPen _getPen ( const Name& key, int darkening ) const;
inline QBrush _getBrush ( const Name& key, int darkening ) const;
inline const string& _getPattern ( const Name& key ) const;
inline float _getThreshold ( const Name& key ) const;
inline int _getDarkening () const;
inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const;
inline void _enable ();
};