* ./hurricane/src/hurricane:

- New: In DbU, extend the StringMode/getValueString() to support the physical
        unit in addition of lambda & foundry grid. "setStringMode()" has now a
        second parameter "UnitPower", only used when the mode is DbU::Physical.

  * ./hurricane/src/hviewer:
    - New: In CellWidget, the fitToContents now adds a margin of 5% to get border
        clear of the bounding box.
    - New: In CellWidget, ability to display lengths in nanometers & micrometers
        in complement of symbolic and foundry grid. DisplayFilterWidget modificated
        accordingly. New members:
          void           setPhysicalMode ( DbU::UnitPower );
          bool           physicalMode    () const;
          DbU::UnitPower getUnitPower    () const;
        In addition to:
          bool           gridMode        () const;
          bool           symbolicMode    () const;
          void           setGridMode     ();
          void           setSymbolicMode ();
This commit is contained in:
Jean-Paul Chaput 2010-01-26 12:58:36 +00:00
parent 0c88f99622
commit faceb1f169
6 changed files with 184 additions and 49 deletions

View File

@ -57,6 +57,7 @@ namespace Hurricane {
double DbU::_gridsPerLambda = 10.0;
double DbU::_physicalsPerGrid = 1.0;
unsigned int DbU::_stringMode = DbU::Symbolic;
DbU::UnitPower DbU::_stringModeUnitPower = DbU::Nano;
DbU::Unit DbU::_symbolicSnapGridStep = DbU::lambda(1.0);
DbU::Unit DbU::_realSnapGridStep = DbU::grid (10.0);
const DbU::Unit DbU::Min = std::numeric_limits<long>::min();
@ -245,6 +246,13 @@ namespace Hurricane {
}
void DbU::setStringMode ( unsigned int mode, UnitPower p )
{
_stringMode = mode;
if ( _stringMode == Physical ) _stringModeUnitPower = p;
}
string DbU::getValueString ( DbU::Unit u, int mode )
{
char buffer[1024];
@ -256,6 +264,17 @@ namespace Hurricane {
} else if ( _stringMode == Symbolic ) {
unitSymbol = 'l';
snprintf ( buffer, 1024, "%.1f", getLambda(u) );
} else if ( _stringMode == Physical ) {
switch ( _stringModeUnitPower ) {
case Pico: unitSymbol = 'p'; break;
case Nano: unitSymbol = 'n'; break;
case Micro: unitSymbol = 'm'; break;
case Milli: unitSymbol = 'M'; break;
case Unity: unitSymbol = 'U'; break;
case Kilo: unitSymbol = 'k'; break;
default: unitSymbol = '?'; break;
}
snprintf ( buffer, 1024, "%.1f", getPhysical(u,_stringModeUnitPower) );
} else {
if ( _stringMode != Db )
cerr << "[ERROR] Unknown Unit representation mode: " << _stringMode << endl;

View File

@ -62,10 +62,11 @@ namespace Hurricane {
public:
typedef long Unit;
public:
enum StringMode { Db = 1
, Grid = 2
, Symbolic = 4
, SmartTruncate = 8
enum StringMode { Db = (1<<0)
, Grid = (1<<1)
, Symbolic = (1<<2)
, Physical = (1<<3)
, SmartTruncate = (1<<4)
};
enum SnapMode { Inferior = 1
, Superior = 2
@ -107,7 +108,7 @@ namespace Hurricane {
static string getValueString ( Unit u, int mode=SmartTruncate );
static Record* getValueRecord ( const Unit* u );
static Slot* getValueSlot ( const string& name, const Unit* u );
static inline void setStringMode ( unsigned int mode );
static void setStringMode ( unsigned int mode, UnitPower p=Nano );
public:
// Static Attributes: constants.
@ -121,6 +122,7 @@ namespace Hurricane {
static double _gridsPerLambda;
static double _physicalsPerGrid;
static unsigned int _stringMode;
static DbU::UnitPower _stringModeUnitPower;
static DbU::Unit _realSnapGridStep;
static DbU::Unit _symbolicSnapGridStep;
};
@ -134,7 +136,6 @@ namespace Hurricane {
inline double DbU::getGrid ( DbU::Unit u ) { return _resolution*(double)u; }
inline double DbU::getLambda ( DbU::Unit u ) { return getGrid(u)/_gridsPerLambda; }
inline double DbU::getPhysical ( DbU::Unit u, UnitPower p ) { return (_physicalsPerGrid*_resolution*(double)u)/getUnitPower(p); }
inline void DbU::setStringMode ( unsigned int mode ) { _stringMode = mode; }
inline void DbU::setRealSnapGridStep ( DbU::Unit step ) { _realSnapGridStep = step; }
inline void DbU::setSymbolicSnapGridStep ( DbU::Unit step ) { _symbolicSnapGridStep = step; }
inline DbU::Unit DbU::getOnPhysicalGrid ( DbU::Unit u, SnapMode mode ) { return getOnCustomGrid(u, grid(1), mode); }

View File

@ -1243,17 +1243,20 @@ namespace Hurricane {
void CellWidget::changeLayoutMode ()
{
if ( symbolicMode() )
if ( symbolicMode() ) {
setSymbolicMode ();
else
setRealMode ();
} else if ( gridMode() ) {
setGridMode ();
} else {
setPhysicalMode(_state->getUnitPower());
}
}
void CellWidget::setRealMode ()
void CellWidget::setGridMode ()
{
if ( !realMode() ) {
_state->setRealMode ();
if ( not gridMode() ) {
_state->setGridMode ();
DbU::setStringMode ( DbU::Grid );
updateMousePosition ();
@ -1266,7 +1269,7 @@ namespace Hurricane {
void CellWidget::setSymbolicMode ()
{
if ( !symbolicMode() ) {
if ( not symbolicMode() ) {
_state->setSymbolicMode ();
DbU::setStringMode ( DbU::Symbolic );
@ -1278,6 +1281,20 @@ namespace Hurricane {
}
void CellWidget::setPhysicalMode ( DbU::UnitPower p )
{
if ( not physicalMode() or (_state->getUnitPower() != p) ) {
_state->setPhysicalMode ( p );
DbU::setStringMode ( DbU::Physical, p );
updateMousePosition ();
refresh ();
emit layoutModeChanged ();
}
}
void CellWidget::setShowSelection ( bool state )
{
if ( state != _state->showSelection() ) {
@ -1816,7 +1833,7 @@ namespace Hurricane {
{
QFont font = Graphics::getNormalFont();
QFontMetrics metrics = QFontMetrics(font);
int tickLength = metrics.width ( "+00000" );
int tickLength = metrics.width ( "+00000u" );
Point origin = ruler->getOrigin ();
Point extremity = ruler->getExtremity ();
Point angle = ruler->getAngle ();
@ -1887,7 +1904,7 @@ namespace Hurricane {
// if ( !tick ) continue;
textGrad = DbU::getValueString( gradStep*tick );
textGrad = DbU::getValueString( gradStep*tick, (symbolicMode()) ? DbU::Symbolic : DbU::Grid );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint ( pxGrad - 1, pxOrigin.y() + tickLength )
@ -1902,7 +1919,8 @@ namespace Hurricane {
_drawingPlanes.painter().drawLine ( pxAngle.x(), pxAngle.y()
, pxAngle.x(), pxAngle.y()+tickLength );
textGrad = DbU::getValueString ( angle.getX() - origin.getX() );
textGrad = DbU::getValueString ( angle.getX() - origin.getX()
, (symbolicMode()) ? DbU::Symbolic : DbU::Grid );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint ( pxAngle.x() - 1,pxAngle.y() + tickLength )
@ -1945,7 +1963,7 @@ namespace Hurricane {
// if ( !tick ) continue;
textGrad = DbU::getValueString( gradStep*tick );
textGrad = DbU::getValueString( gradStep*tick, (symbolicMode()) ? DbU::Symbolic : DbU::Grid );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxOrigin.x() - tickLength,pyGrad + 1)
@ -1960,7 +1978,8 @@ namespace Hurricane {
_drawingPlanes.painter().drawLine ( pxOrigin.x() , pxAngle.y()
, pxOrigin.x()-tickLength, pxAngle.y() );
textGrad = DbU::getValueString( angle.getY() - origin.getY() );
textGrad = DbU::getValueString( angle.getY() - origin.getY()
, (symbolicMode()) ? DbU::Symbolic : DbU::Grid );
textGrad.resize ( textGrad.size()-1 );
drawDisplayText ( QPoint(pxOrigin.x() - tickLength,pxAngle.y() + 1)
@ -2142,7 +2161,15 @@ namespace Hurricane {
);
if ( getCell() ) boundingBox = getCell()->getBoundingBox();
reframe ( boundingBox, historyEnable );
DbU::Unit expand;
if ( boundingBox.getWidth() < boundingBox.getHeight() ) {
expand = DbU::grid( DbU::getGrid(boundingBox.getWidth()) * 0.05 );
} else {
expand = DbU::grid( DbU::getGrid(boundingBox.getHeight()) * 0.05 );
}
reframe ( boundingBox.inflate(expand), historyEnable );
}

View File

@ -56,7 +56,9 @@ namespace Hurricane {
, _centric (new QRadioButton())
, _barycentric (new QRadioButton())
, _symbolicMode (new QRadioButton())
, _realMode (new QRadioButton())
, _gridMode (new QRadioButton())
, _nanoMode (new QRadioButton())
, _microMode (new QRadioButton())
, _updateState (ExternalEmit)
{
setAttribute ( Qt::WA_QuitOnClose, false );
@ -154,11 +156,23 @@ namespace Hurricane {
group->addButton ( _symbolicMode );
hLayout->addWidget ( _symbolicMode );
_realMode->setText ( tr("Real (foundry grid)") );
_realMode->setFont ( Graphics::getNormalFont() );
group->setId ( _realMode, 0 );
group->addButton ( _realMode );
hLayout->addWidget ( _realMode );
_gridMode->setText ( tr("Real (foundry grid)") );
_gridMode->setFont ( Graphics::getNormalFont() );
group->setId ( _gridMode, 0 );
group->addButton ( _gridMode );
hLayout->addWidget ( _gridMode );
_nanoMode->setText ( tr("nanometer") );
_nanoMode->setFont ( Graphics::getNormalFont() );
group->setId ( _nanoMode, 0 );
group->addButton ( _nanoMode );
hLayout->addWidget ( _nanoMode );
_microMode->setText ( tr("micrometer") );
_microMode->setFont ( Graphics::getNormalFont() );
group->setId ( _microMode, 0 );
group->addButton ( _microMode );
hLayout->addWidget ( _microMode );
groupBox->setLayout ( hLayout );
wLayout->addWidget ( groupBox );
@ -172,7 +186,9 @@ namespace Hurricane {
connect ( _centric , SIGNAL(clicked()) , this, SLOT(setRubberCentric()) );
connect ( _barycentric , SIGNAL(clicked()) , this, SLOT(setRubberBarycentric()) );
connect ( _symbolicMode, SIGNAL(clicked()) , this, SLOT(setSymbolicMode()) );
connect ( _realMode , SIGNAL(clicked()) , this, SLOT(setRealMode()) );
connect ( _gridMode , SIGNAL(clicked()) , this, SLOT(setGridMode()) );
connect ( _nanoMode , SIGNAL(clicked()) , this, SLOT(setNanoMode()) );
connect ( _microMode , SIGNAL(clicked()) , this, SLOT(setMicroMode()) );
}
@ -212,8 +228,14 @@ namespace Hurricane {
if ( _cellWidget->symbolicMode() )
_symbolicMode->setChecked(true);
else
_realMode->setChecked(true);
else if ( _cellWidget->gridMode() )
_gridMode->setChecked(true);
else if ( _cellWidget->physicalMode() ) {
switch ( _cellWidget->getUnitPower() ) {
case DbU::Nano: _nanoMode->setChecked(true); break;
case DbU::Micro: _microMode->setChecked(true); break;
}
}
blockAllSignals ( false );
}
@ -264,7 +286,9 @@ namespace Hurricane {
_centric ->blockSignals ( state );
_barycentric ->blockSignals ( state );
_symbolicMode ->blockSignals ( state );
_realMode ->blockSignals ( state );
_gridMode ->blockSignals ( state );
_nanoMode ->blockSignals ( state );
_microMode ->blockSignals ( state );
}
@ -382,12 +406,34 @@ namespace Hurricane {
}
void DisplayFilterWidget::setRealMode ()
void DisplayFilterWidget::setGridMode ()
{
if ( _cellWidget ) {
if ( !_cellWidget->realMode() ) {
if ( !_cellWidget->gridMode() ) {
_updateState = InternalEmit;
_cellWidget->setRealMode ();
_cellWidget->setGridMode ();
}
}
}
void DisplayFilterWidget::setNanoMode ()
{
if ( _cellWidget ) {
if ( not _cellWidget->physicalMode() or (_cellWidget->getUnitPower() != DbU::Nano) ) {
_updateState = InternalEmit;
_cellWidget->setPhysicalMode ( DbU::Nano );
}
}
}
void DisplayFilterWidget::setMicroMode ()
{
if ( _cellWidget ) {
if ( not _cellWidget->physicalMode() or (_cellWidget->getUnitPower() != DbU::Micro) ) {
_updateState = InternalEmit;
_cellWidget->setPhysicalMode ( DbU::Micro );
}
}
}

View File

@ -146,8 +146,10 @@ namespace Hurricane {
inline void resetActiveCommand ();
inline void setCursorStep ( DbU::Unit );
inline void setRealSnapGridStep ( DbU::Unit step );
inline bool realMode () const;
inline bool gridMode () const;
inline bool symbolicMode () const;
inline bool physicalMode () const;
inline DbU::UnitPower getUnitPower () const;
inline bool showBoundaries () const;
inline bool showSelection () const;
inline bool cumulativeSelection () const;
@ -292,8 +294,9 @@ namespace Hurricane {
void setScale ( float );
void scaleHistoryUp ();
void scaleHistoryDown ();
void setRealMode ();
void setGridMode ();
void setSymbolicMode ();
void setPhysicalMode ( DbU::UnitPower );
void setShowBoundaries ( bool state );
void reframe ();
void reframe ( const Box& box, bool historyEnable=true );
@ -540,8 +543,10 @@ namespace Hurricane {
inline void setCellWidget ( CellWidget* );
inline void setCursorStep ( DbU::Unit );
inline DbU::Unit getCursorStep () const;
inline void setRealMode ();
inline DbU::UnitPower getUnitPower () const;
inline void setGridMode ();
inline void setSymbolicMode ();
inline void setPhysicalMode ( DbU::UnitPower );
inline void setShowBoundaries ( bool );
inline void setShowSelection ( bool );
inline void setCumulativeSelection ( bool );
@ -560,8 +565,11 @@ namespace Hurricane {
inline SelectorCriterions& getSelection ();
inline RulerSet& getRulers ();
inline DbU::Unit cursorStep () const;
inline bool realMode () const;
inline bool gridMode () const;
inline bool symbolicMode () const;
inline bool physicalMode () const;
inline bool nanoMode () const;
inline bool microMode () const;
inline bool showBoundaries () const;
inline bool showSelection () const;
inline bool cumulativeSelection () const;
@ -589,7 +597,8 @@ namespace Hurricane {
SelectorCriterions _selection;
RulerSet _rulers;
DbU::Unit _cursorStep;
bool _symbolicMode;
unsigned int _displayMode;
DbU::UnitPower _unitPower;
bool _showBoundaries;
bool _showSelection;
Query::Mask _queryFilter;
@ -877,7 +886,8 @@ namespace Hurricane {
, _selection ()
, _rulers ()
, _cursorStep (DbU::lambda(0.5))
, _symbolicMode (true)
, _displayMode (DbU::Symbolic)
, _unitPower (DbU::Nano)
, _showBoundaries (true)
, _showSelection (false)
, _queryFilter (~Query::DoTerminalCells)
@ -894,7 +904,15 @@ namespace Hurricane {
inline bool CellWidget::State::symbolicMode () const
{ return _symbolicMode; }
{ return (_displayMode == DbU::Symbolic); }
inline bool CellWidget::State::gridMode () const
{ return (_displayMode == DbU::Grid); }
inline bool CellWidget::State::physicalMode () const
{ return (_displayMode == DbU::Physical); }
inline void CellWidget::State::setCell ( Cell* cell )
@ -915,20 +933,32 @@ namespace Hurricane {
{ return _cursorStep; }
inline void CellWidget::State::setRealMode ()
inline DbU::UnitPower CellWidget::State::getUnitPower () const
{ return _unitPower; }
inline void CellWidget::State::setGridMode ()
{
_symbolicMode = false;
_displayMode = DbU::Grid;
_cursorStep = DbU::grid ( 1.0 );
}
inline void CellWidget::State::setSymbolicMode ()
{
_symbolicMode = true;
_displayMode = DbU::Symbolic;
_cursorStep = DbU::lambda ( 0.5 );
}
inline void CellWidget::State::setPhysicalMode ( DbU::UnitPower p )
{
_displayMode = DbU::Physical;
_cursorStep = DbU::grid ( 1.0 );
_unitPower = p;
}
inline void CellWidget::State::setShowBoundaries ( bool state )
{ _showBoundaries = state; }
@ -1238,14 +1268,22 @@ namespace Hurricane {
{ return _state->cursorStep(); }
inline bool CellWidget::realMode () const
{ return !_state->symbolicMode(); }
inline bool CellWidget::gridMode () const
{ return _state->gridMode(); }
inline bool CellWidget::symbolicMode () const
{ return _state->symbolicMode(); }
inline bool CellWidget::physicalMode () const
{ return _state->physicalMode(); }
inline DbU::UnitPower CellWidget::getUnitPower () const
{ return _state->getUnitPower(); }
inline bool CellWidget::showBoundaries () const
{ return _state->showBoundaries(); }

View File

@ -60,7 +60,9 @@ namespace Hurricane {
void setRubberCentric ();
void setRubberBarycentric ();
void setSymbolicMode ();
void setRealMode ();
void setGridMode ();
void setNanoMode ();
void setMicroMode ();
protected:
void blockAllSignals ( bool state );
@ -75,7 +77,9 @@ namespace Hurricane {
QRadioButton* _centric;
QRadioButton* _barycentric;
QRadioButton* _symbolicMode;
QRadioButton* _realMode;
QRadioButton* _gridMode;
QRadioButton* _nanoMode;
QRadioButton* _microMode;
UpdateState _updateState;
};