From f7721dd75442df980a252ec7e02f86d908640ae6 Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Thu, 30 Dec 2010 18:38:43 +0000 Subject: [PATCH] * ./hurricane/src/hurricane: - Change: In RoutingPad, uses my C++ style. Normalize constructors calls. Allow to select (trough flags) the way the "best component" is choosen. Currently: Biggest Area or Lowest Layer or Highest Layer. * ./hurricane/src/viewer: - New: In DisplayStyle, darkening is now expressed as a ratio over the HSV components of a color. Introduce a new DisplayStyle::HSVr type. Allow a more readable darkening effect. All object modicated accordingly. - Change: In NetlistWidget, the "Net" section now correctly dimension itself on the widest net name. Must suppress all the size Hints in the header & data models. --- hurricane/src/hurricane/Cell.cpp | 4 +- hurricane/src/hurricane/DeepNet.cpp | 2 +- hurricane/src/hurricane/RoutingPad.cpp | 539 +++++++++--------- .../src/hurricane/hurricane/RoutingPad.h | 189 +++--- hurricane/src/viewer/CellWidget.cpp | 4 +- hurricane/src/viewer/ColorScale.cpp | 4 +- hurricane/src/viewer/ControllerWidget.cpp | 6 +- hurricane/src/viewer/DisplayStyle.cpp | 63 +- hurricane/src/viewer/Graphics.cpp | 14 +- hurricane/src/viewer/NetlistModel.cpp | 9 +- hurricane/src/viewer/NetlistWidget.cpp | 1 - .../src/viewer/hurricane/viewer/CellWidget.h | 382 ++++++------- .../src/viewer/hurricane/viewer/ColorScale.h | 3 +- .../viewer/hurricane/viewer/DisplayStyle.h | 162 +++--- .../src/viewer/hurricane/viewer/Graphics.h | 25 +- 15 files changed, 706 insertions(+), 701 deletions(-) diff --git a/hurricane/src/hurricane/Cell.cpp b/hurricane/src/hurricane/Cell.cpp index ed1e6ccf..807f4272 100644 --- a/hurricane/src/hurricane/Cell.cpp +++ b/hurricane/src/hurricane/Cell.cpp @@ -215,7 +215,7 @@ void Cell::flattenNets(bool buildRings) } forEach ( Occurrence, iplugOccurrence, hyperNet.getLeafPlugOccurrences() ) { - currentRP = createRoutingPad ( net, *iplugOccurrence ); + currentRP = RoutingPad::create ( net, *iplugOccurrence, RoutingPad::BiggestArea ); currentRP->materialize (); if ( buildRings ) { if ( previousRP ) { @@ -233,7 +233,7 @@ void Cell::flattenNets(bool buildRings) forEach ( Component*, icomponent, net->getComponents() ) { Pin* pin = dynamic_cast( *icomponent ); if ( pin ) { - currentRP = createRoutingPad ( pin ); + currentRP = RoutingPad::create ( pin ); if ( buildRings ) { if ( previousRP ) { currentRP->getBodyHook()->attach ( previousRP->getBodyHook() ); diff --git a/hurricane/src/hurricane/DeepNet.cpp b/hurricane/src/hurricane/DeepNet.cpp index 9ac9b4d2..8e70242a 100644 --- a/hurricane/src/hurricane/DeepNet.cpp +++ b/hurricane/src/hurricane/DeepNet.cpp @@ -145,7 +145,7 @@ size_t DeepNet::_createRoutingPads ( bool buildRings ) for_each_occurrence ( plugOccurrence, hyperNet.getLeafPlugOccurrences() ) { nbRoutingPads++; - currentRP = createRoutingPad ( this, plugOccurrence ); + currentRP = RoutingPad::create ( this, plugOccurrence, RoutingPad::BiggestArea ); if ( buildRings ) { if ( previousRP ) { currentRP->getBodyHook()->attach ( previousRP->getBodyHook() ); diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp index 2c56f61f..b50905e4 100644 --- a/hurricane/src/hurricane/RoutingPad.cpp +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -1,23 +1,43 @@ -// **************************************************************************************************** -// File: ./RoutingPad.cpp -// Authors: H.Clement, M.Sroka -// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved + +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved // // This file is part of Hurricane. // -// Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU -// Lesser General Public License as published by the Free Software Foundation, either version 3 of the +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // -// Hurricane is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU // General Public License for more details. // -// You should have received a copy of the Lesser GNU General Public License along with Hurricane. If -// not, see . -// **************************************************************************************************** +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// =================================================================== +// +// $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 | +// | | +// | Authors : Hugo Clement & Marek Sroka | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./RoutingPad.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x + -#include "hurricane/RoutingPad.h" #include "hurricane/Net.h" #include "hurricane/NetExternalComponents.h" #include "hurricane/Layer.h" @@ -29,36 +49,29 @@ #include "hurricane/Cell.h" #include "hurricane/Instance.h" #include "hurricane/Error.h" +#include "hurricane/RoutingPad.h" + namespace Hurricane { -// **************************************************************************************************** -// RoutingPad implementation -// **************************************************************************************************** -RoutingPad::RoutingPad(Net* net, const Point& p, Occurrence occurrence ) -// ********************************************************************************** -: Inherit(net), - _x(p.getX()), - _y(p.getY()), - _occurrence(occurrence) -{ -} + RoutingPad::RoutingPad ( Net* net, const Point& p, Occurrence occurrence ) + : Inherit (net) + , _x (p.getX()) + , _y (p.getY()) + , _occurrence(occurrence) + { } -RoutingPad* RoutingPad::create(Net* net, Occurrence occurrence) -// *********************************************************** -{ - if (!net) - throw Error ("Can't create RoutingPad : NULL net"); - if (!occurrence.isValid()) - throw Error ("Can't create RoutingPag : Invalid occurrence"); + RoutingPad* RoutingPad::create ( Net* net, Occurrence occurrence, unsigned int flags ) + { + if ( not net ) throw Error ("Can't create RoutingPad : NULL net"); + if ( not occurrence.isValid() ) throw Error ("Can't create RoutingPag : Invalid occurrence"); - //TODO Gerer une contruction avec un composant externe, mais ce n'est pas prioritaire Plug* plug = NULL; Pin* pin = NULL; Contact* contact = NULL; - Point position; + Point position; if ( (plug = dynamic_cast(occurrence.getEntity()) ) ) { position = occurrence.getPath().getTransformation().getPoint( plug->getPosition() ); @@ -68,236 +81,203 @@ RoutingPad* RoutingPad::create(Net* net, Occurrence occurrence) position = occurrence.getPath().getTransformation().getPoint( contact->getPosition() ); } - if ( !plug && !pin && !contact ) - throw Error ("Can't create RoutingPad : plug or pin occurrence *required*"); + if ( (not plug) and (not pin) and (not contact) ) + throw Error ("Can't create RoutingPad : Plug Pin, or Contact Occurrence *required*"); RoutingPad* routingPad = new RoutingPad(net, position, occurrence); - routingPad->_postCreate(); + if ( plug and (flags & ComponentSelection) ) routingPad->setOnBestComponent(flags); + return routingPad; -} - -void RoutingPad::_postCreate() -// **************************** -{ - Inherit::_postCreate(); - - if (!_occurrence.getPath().isEmpty()) - _occurrence.getMasterCell()->_addSlaveEntity(_occurrence.getEntity(),this); -} - -DbU::Unit RoutingPad::getX() const -// *********************** -{ - return _x; -} - -DbU::Unit RoutingPad::getY() const -// *********************** -{ - return _y; -} - -Box RoutingPad::getBoundingBox() const -// ******************************** -{ - Component* component = _getEntityAsComponent(); - if ( component ) { - return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox() ); } - return Box(getPosition()); -} -Box RoutingPad::getBoundingBox(const BasicLayer* basicLayer) const -// ****************************************************** -{ - Component* component = _getEntityAsComponent(); - if ( component ) - return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox(basicLayer) ); + void RoutingPad::_postCreate () + { + Inherit::_postCreate(); - return Box(getPosition()); -} - -const Layer* RoutingPad::getLayer() const -// ****************************************************** -{ - Component* component = _getEntityAsComponent(); - if ( component ) return component->getLayer (); - - return NULL; -} - -Point RoutingPad::getSourcePosition() const -// **************************************** -{ - Segment* segment = _getEntityAsSegment(); - if ( segment ) - return _occurrence.getPath().getTransformation().getPoint ( segment->getSourcePosition() ); - - return getPosition(); -} - -Point RoutingPad::getTargetPosition() const -// **************************************** -{ - Segment* segment = _getEntityAsSegment(); - if ( segment ) - return _occurrence.getPath().getTransformation().getPoint ( segment->getTargetPosition() ); - - return getPosition(); -} - -DbU::Unit RoutingPad::getSourceX() const -// ******************************** -{ - return getSourcePosition().getX(); -} - -DbU::Unit RoutingPad::getSourceY() const -// ******************************** -{ - return getSourcePosition().getY(); -} - -DbU::Unit RoutingPad::getTargetX() const -// ******************************** -{ - return getTargetPosition().getX(); -} - -DbU::Unit RoutingPad::getTargetY() const -// ******************************** -{ - return getTargetPosition().getY(); -} - -Point RoutingPad::getCenter() const -// **************************************** -{ - Segment* segment = _getEntityAsSegment(); - if ( segment ) - return _occurrence.getPath().getTransformation().getPoint ( segment->getCenter() ); - - return getPosition(); -} + if ( not _occurrence.getPath().isEmpty() ) + _occurrence.getMasterCell()->_addSlaveEntity(_occurrence.getEntity(),this); + } -void RoutingPad::translate(const DbU::Unit& dx, const DbU::Unit& dy) -// **************************************************** -{ - if ((dx != 0) || (dy != 0)) { - invalidate(true); - _x += dx; - _y += dy; + RoutingPad* RoutingPad::create ( Pin* pin ) + { + Occurrence pinOccurrence ( pin, Path() ); + +#if 0 + forEach ( RoutingPad*, irp, pin->getNet()->getRoutingPads() ) { + if ( (*irp)->getOccurrence() == pinOccurrence ) + return (*irp); } -} +#endif -void RoutingPad::setX(const DbU::Unit& x) -// ****************************** -{ - setPosition(x, getY()); -} + return RoutingPad::create ( pin->getNet(), pinOccurrence ); + } -void RoutingPad::setY(const DbU::Unit& y) -// ****************************** -{ - setPosition(getX(), y); -} -void RoutingPad::setPosition(const DbU::Unit& x, const DbU::Unit& y) -// **************************************************** -{ - setOffset(x, y); -} + DbU::Unit RoutingPad::getX () const { return _x; } + DbU::Unit RoutingPad::getY () const { return _y; } + DbU::Unit RoutingPad::getSourceX () const { return getSourcePosition().getX(); } + DbU::Unit RoutingPad::getSourceY () const { return getSourcePosition().getY(); } + DbU::Unit RoutingPad::getTargetX () const { return getTargetPosition().getX(); } + DbU::Unit RoutingPad::getTargetY () const { return getTargetPosition().getY(); } -void RoutingPad::setPosition(const Point& position) -// ********************************************* -{ - setPosition(position.getX(), position.getY()); -} -void RoutingPad::setOffset(const DbU::Unit& x, const DbU::Unit& y) -// **************************************************** -{ + Box RoutingPad::getBoundingBox () const + { + Component* component = _getEntityAsComponent(); + if ( component ) + return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox() ); + + return Box(getPosition()); + } + + + Box RoutingPad::getBoundingBox ( const BasicLayer* basicLayer ) const + { + Component* component = _getEntityAsComponent(); + if ( component ) + return _occurrence.getPath().getTransformation().getBox ( component->getBoundingBox(basicLayer) ); + + return Box(getPosition()); + } + + + const Layer* RoutingPad::getLayer () const + { + Component* component = _getEntityAsComponent(); + if ( component ) return component->getLayer (); + + return NULL; + } + + + Point RoutingPad::getSourcePosition () const + { + Segment* segment = _getEntityAsSegment(); + if ( segment ) + return _occurrence.getPath().getTransformation().getPoint ( segment->getSourcePosition() ); + + return getPosition(); + } + + + Point RoutingPad::getTargetPosition() const + { + Segment* segment = _getEntityAsSegment(); + if ( segment ) + return _occurrence.getPath().getTransformation().getPoint ( segment->getTargetPosition() ); + + return getPosition(); + } + + + Point RoutingPad::getCenter() const + { + Segment* segment = _getEntityAsSegment(); + if ( segment ) + return _occurrence.getPath().getTransformation().getPoint ( segment->getCenter() ); + + return getPosition(); + } + + + void RoutingPad::translate(const DbU::Unit& dx, const DbU::Unit& dy) + { + if ( (dx != 0) or (dy != 0) ) { + invalidate(true); + _x += dx; + _y += dy; + } + } + + + void RoutingPad::setX ( const DbU::Unit& x ) { setPosition(x, getY()); } + void RoutingPad::setY ( const DbU::Unit& y ) { setPosition(getX(), y); } + void RoutingPad::setPosition ( const DbU::Unit& x, const DbU::Unit& y ) { setOffset(x, y); } + void RoutingPad::setPosition ( const Point& position) { setPosition(position.getX(), position.getY()); } + + + void RoutingPad::setOffset ( const DbU::Unit& x, const DbU::Unit& y ) + { invalidate(true); _x = x; _y = y; -} - -void RoutingPad::_preDestroy() -// *********************** -{ -// trace << "entering RoutingPad::preDestroy: " << this << endl; -// trace_in(); + } - if (!_occurrence.getPath().isEmpty()) - _occurrence.getMasterCell()->_removeSlaveEntity(_occurrence.getEntity(),this); - Inherit::_preDestroy(); + void RoutingPad::_preDestroy () + { + // trace << "entering RoutingPad::preDestroy: " << this << endl; + // trace_in(); -// trace << "exiting RoutingPad::preDestroy:" << endl; -// trace_out(); -} + if ( not _occurrence.getPath().isEmpty() ) + _occurrence.getMasterCell()->_removeSlaveEntity(_occurrence.getEntity(),this); + Inherit::_preDestroy(); -string RoutingPad::_getString() const -// ******************************* -{ + // trace << "exiting RoutingPad::preDestroy:" << endl; + // trace_out(); + } + + + string RoutingPad::_getString () const + { string s = Inherit::_getString(); s.insert(s.length() - 1, " [" + DbU::getValueString(getX())); s.insert(s.length() - 1, " " + DbU::getValueString(getY())); s.insert(s.length() - 1, "] "); s.insert(s.length() - 1, getString(_occurrence)); return s; -} + } -Record* RoutingPad::_getRecord() const -// ************************** -{ + + Record* RoutingPad::_getRecord () const + { Record* record = Inherit::_getRecord(); - if (record) { - record->add(getSlot("X", &_x)); - record->add(getSlot("Y", &_y)); - record->add(getSlot("Occurrence",_occurrence)); + if ( record ) { + record->add(getSlot("_x" , &_x )); + record->add(getSlot("_y" , &_y )); + record->add(getSlot("_occurrence",_occurrence)); } return record; -} + } -Component* RoutingPad::_getEntityAsComponent () const -// *************************************************** -{ - if ( _occurrence.isValid() ) - return dynamic_cast( _occurrence.getEntity() ); - return NULL; -} + Component* RoutingPad::_getEntityAsComponent () const + { + if ( _occurrence.isValid() ) + return dynamic_cast( _occurrence.getEntity() ); -Segment* RoutingPad::_getEntityAsSegment () const -// *********************************************** -{ - if ( _occurrence.isValid() ) - return dynamic_cast( _occurrence.getEntity() ); + return NULL; + } - return NULL; -} -void RoutingPad::setExternalComponent(Component* component) -// ******************************************************** -{ - if (isMaterialized()) invalidate(false); + Segment* RoutingPad::_getEntityAsSegment () const + { + if ( _occurrence.isValid() ) + return dynamic_cast( _occurrence.getEntity() ); + + return NULL; + } + + + void RoutingPad::setExternalComponent ( Component* component ) + { + if ( isMaterialized() ) invalidate(false); Occurrence plugOccurrence = getPlugOccurrence(); - Plug* plug= static_cast(plugOccurrence.getEntity()); - if (plug->getMasterNet() != component->getNet()) - throw Error("Cannot Set External Component to Routing Pad : Inconsistant Net"); + Plug* plug = static_cast(plugOccurrence.getEntity()); + if ( plug->getMasterNet() != component->getNet() ) + throw Error("Cannot Set External Component to Routing Pad : Inconsistant Net"); _occurrence.getMasterCell()->_removeSlaveEntity(_occurrence.getEntity(),this); _occurrence = Occurrence(component,Path(plugOccurrence.getPath(),plug->getInstance())); - Point position = _occurrence.getPath().getTransformation().getPoint ( component->getPosition() ); - + Point position = _occurrence.getPath().getTransformation().getPoint ( component->getPosition() ); Horizontal* horizontal = dynamic_cast(component); + if ( horizontal ) { setX ( 0 ); setY ( position.getY() ); @@ -312,85 +292,76 @@ void RoutingPad::setExternalComponent(Component* component) _occurrence.getMasterCell()->_addSlaveEntity(_occurrence.getEntity(),this); - if (!isMaterialized()) { - materialize(); - } -} + if (!isMaterialized()) materialize(); + } -Occurrence RoutingPad::getPlugOccurrence() -// *************************************** -{ + Occurrence RoutingPad::getPlugOccurrence () + { if (dynamic_cast(_occurrence.getEntity())) - return _occurrence; - Component* component= static_cast(_occurrence.getEntity()); - Net* net=component->getNet(); - Path path=_occurrence.getPath(); - if (path.isEmpty()) - throw Error("Empty Path => not in an instance"); - Instance* instance=path.getTailInstance(); - Plug* plug=instance->getPlug(net); + return _occurrence; + + Component* component = static_cast(_occurrence.getEntity()); + Net* net = component->getNet(); + Path path = _occurrence.getPath(); + + if ( path.isEmpty() ) + throw Error("Empty Path => not in an instance"); + + Instance* instance = path.getTailInstance(); + Plug* plug = instance->getPlug(net); + return Occurrence(plug,path.getHeadPath()); -} + } -void RoutingPad::restorePlugOccurrence() -// ************************************* -{ + void RoutingPad::restorePlugOccurrence () + { if (isMaterialized()) unmaterialize(); _occurrence=getPlugOccurrence(); setPosition ( _occurrence.getPath().getTransformation().getPoint - ( dynamic_cast(_occurrence.getEntity())->getPosition() ) ); -} - -RoutingPad* createRoutingPad ( Net* net, Occurrence plugOccurrence ) -// ***************************************************************** -{ - Component* bestComponent = NULL; - Plug* plug = static_cast(plugOccurrence.getEntity()); - - for_each_component (component, NetExternalComponents::get(plug->getMasterNet()) ) { - if ( !bestComponent ) { bestComponent = component; continue; } - if ( /* IsOnTop(component->getLayer(),bestComponent->getLayer()) - ||*/ ( getArea(component) > getArea(bestComponent) ) ) { - bestComponent = component; - } - end_for - } - - if ( !bestComponent ) { - string message = "CreateRoutingPad(): Cannot find external component of "; - message += getString(plug->getMasterNet()) + " in "; - message += getString(plug->getInstance()) + ".\n" ; - throw Error ( message ); - } - - RoutingPad* rp = RoutingPad::create ( net, plugOccurrence ); - rp->setExternalComponent ( bestComponent ); - - return rp; -} - -RoutingPad* createRoutingPad ( Pin* pin ) -// ************************************** -{ - Occurrence pinOccurrence ( pin, Path() ); - -# if 0 - for_each_routing_pad ( routingPad, pin->getNet()->getRoutingPads() ) { - if ( routingPad->getOccurrence() == pinOccurrence ) - return routingPad; - end_for + ( dynamic_cast(_occurrence.getEntity())->getPosition() ) ); } -# endif - - return RoutingPad::create ( pin->getNet(), pinOccurrence ); -} -} // End of Hurricane namespace. + Component* RoutingPad::setOnBestComponent ( unsigned int flags ) + { + restorePlugOccurrence (); -// **************************************************************************************************** -// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved -// **************************************************************************************************** + Component* bestComponent = NULL; + Plug* plug = static_cast(_occurrence.getEntity()); + + forEach ( Component*, icomponent, NetExternalComponents::get(plug->getMasterNet()) ) { + if ( not bestComponent ) { bestComponent = *icomponent; continue; } + + switch ( flags & ComponentSelection ) { + case LowestLayer: + if ( icomponent->getLayer()->below(bestComponent->getLayer()) ) + bestComponent = *icomponent; + break; + case HighestLayer: + if ( icomponent->getLayer()->above(bestComponent->getLayer()) ) + bestComponent = *icomponent; + break; + case BiggestArea: + default: + if ( getArea(*icomponent) > getArea(bestComponent) ) + bestComponent = *icomponent; + break; + } + } + + if ( not bestComponent ) + throw Error ( "RoutingPad::_getBestComponent(): No external components for\n" + " %s of %s." + ,getString(plug->getMasterNet()).c_str() + ,getString(plug->getInstance ()).c_str() ); + + setExternalComponent ( bestComponent ); + + return bestComponent; + } + + +} // End of Hurricane namespace. diff --git a/hurricane/src/hurricane/hurricane/RoutingPad.h b/hurricane/src/hurricane/hurricane/RoutingPad.h index 8810d1e3..f1e9173c 100644 --- a/hurricane/src/hurricane/hurricane/RoutingPad.h +++ b/hurricane/src/hurricane/hurricane/RoutingPad.h @@ -1,113 +1,110 @@ -// **************************************************************************************************** -// File: ./hurricane/RoutingPad.h -// Authors: H.Clement, M.Sroka -// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved + +// -*- C++ -*- +// +// Copyright (c) BULL S.A. 2000-2010, All Rights Reserved // // This file is part of Hurricane. // -// Hurricane is free software: you can redistribute it and/or modify it under the terms of the GNU -// Lesser General Public License as published by the Free Software Foundation, either version 3 of the +// Hurricane is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as +// published by the Free Software Foundation, either version 3 of the // License, or (at your option) any later version. // -// Hurricane is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even -// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU +// Hurricane is distributed in the hope that it will be useful, but +// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- +// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU // General Public License for more details. // -// You should have received a copy of the Lesser GNU General Public License along with Hurricane. If -// not, see . -// **************************************************************************************************** +// You should have received a copy of the Lesser GNU General Public +// License along with Hurricane. If not, see +// . +// +// =================================================================== +// +// $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 | +// | | +// | Authors : Hugo Clement & Marek Sroka | +// | E-mail : Jean-Paul.Chaput@lip6.fr | +// | =============================================================== | +// | C++ Header : "./hurricane/RegularLayer.h" | +// | *************************************************************** | +// | U p d a t e s | +// | | +// x-----------------------------------------------------------------x -#ifndef HURRICANE_ROUTINGPAD -#define HURRICANE_ROUTINGPAD + +#ifndef __HURRICANE_ROUTINGPAD__ +#define __HURRICANE_ROUTINGPAD__ #include "hurricane/Component.h" #include "hurricane/Occurrence.h" #include "hurricane/Pin.h" + namespace Hurricane { - -class Segment; + class Segment; -// **************************************************************************************************** -// RoutingPad declaration -// **************************************************************************************************** - -class RoutingPad : public Component { -// ***************************** - -// Types -// ***** - - public: typedef Component Inherit; - - -// Attributes -// ********** - - private: DbU::Unit _x; - private: DbU::Unit _y; - private: Occurrence _occurrence; - - - -// Constructors -// ************ - - protected: RoutingPad(Net* net, const Point& p, Occurrence occurrence = Occurrence()); - public: static RoutingPad* create(Net* net, Occurrence occurrence); - -// Accessors -// ********* - - //public: virtual Hooks getHooks() const; - public: virtual DbU::Unit getX() const; - public: virtual DbU::Unit getY() const; - public: virtual Box getBoundingBox() const; - public: virtual const Layer* getLayer() const; - public: virtual Box getBoundingBox(const BasicLayer* basicLayer) const; - public: virtual Point getCenter() const; - public: Occurrence getOccurrence() const { return _occurrence; }; - public: Occurrence getPlugOccurrence(); - public: Point getSourcePosition() const; - public: Point getTargetPosition() const; - public: DbU::Unit getSourceX() const; - public: DbU::Unit getSourceY() const; - public: DbU::Unit getTargetX() const; - public: DbU::Unit getTargetY() const; - -// Updators -// ******** - - public: virtual void translate(const DbU::Unit& dx, const DbU::Unit& dy); - - public: void setX(const DbU::Unit& x); - public: void setY(const DbU::Unit& y); - public: void setPosition(const DbU::Unit& x, const DbU::Unit& y); - public: void setPosition(const Point& position); - public: void setOffset(const DbU::Unit& x, const DbU::Unit& y); - public: void setExternalComponent(Component* component); - public: void restorePlugOccurrence(); - -// Others -// ****** - - protected: virtual void _postCreate(); - protected: virtual void _preDestroy(); - - public: virtual string _getTypeName() const {return _TName("RoutingPad");}; - public: virtual string _getString() const; - public: virtual Record* _getRecord() const; - - public: Component* _getEntityAsComponent () const; - public: Segment* _getEntityAsSegment () const; - -}; - - -RoutingPad* createRoutingPad ( Net* net, Occurrence plugOccurrence ); -RoutingPad* createRoutingPad ( Pin* pin ); + class RoutingPad : public Component { + public: + typedef Component Inherit; + enum Flags { BiggestArea =0x1 + , HighestLayer =0x2 + , LowestLayer =0x4 + , ComponentSelection=BiggestArea|HighestLayer|LowestLayer + }; + public: + static RoutingPad* create ( Net*, Occurrence, unsigned int flags=0 ); + static RoutingPad* create ( Pin* ); + public: + // Accessors. + virtual DbU::Unit getX () const; + virtual DbU::Unit getY () const; + virtual Box getBoundingBox () const; + virtual const Layer* getLayer () const; + virtual Box getBoundingBox ( const BasicLayer* ) const; + virtual Point getCenter () const; + inline Occurrence getOccurrence () const { return _occurrence; }; + Occurrence getPlugOccurrence (); + Point getSourcePosition () const; + Point getTargetPosition () const; + DbU::Unit getSourceX () const; + DbU::Unit getSourceY () const; + DbU::Unit getTargetX () const; + DbU::Unit getTargetY () const; + // Mutators. + virtual void translate ( const DbU::Unit& dx, const DbU::Unit& dy ); + void setX ( const DbU::Unit& ); + void setY ( const DbU::Unit& ); + void setPosition ( const DbU::Unit& x, const DbU::Unit& y ); + void setPosition ( const Point& position ); + void setOffset ( const DbU::Unit& dx, const DbU::Unit& dy ); + void setExternalComponent ( Component* ); + Component* setOnBestComponent ( unsigned int flags ); + void restorePlugOccurrence (); + // Miscellaeous. + Component* _getEntityAsComponent () const; + Segment* _getEntityAsSegment () const; + virtual std::string _getTypeName () const {return _TName("RoutingPad");}; + virtual std::string _getString () const; + virtual Record* _getRecord () const; + protected: + virtual void _postCreate (); + virtual void _preDestroy (); + private: + RoutingPad ( Net*, const Point&, Occurrence occurrence=Occurrence() ); + private: + // Attributes. + DbU::Unit _x; + DbU::Unit _y; + Occurrence _occurrence; + }; } // End of Hurricane namespace. @@ -115,8 +112,4 @@ RoutingPad* createRoutingPad ( Pin* pin ); INSPECTOR_P_SUPPORT(Hurricane::RoutingPad); -#endif // HURRICANE_ROUTINGPAD - -// **************************************************************************************************** -// Copyright (c) BULL S.A. 2000-2009, All Rights Reserved -// **************************************************************************************************** +#endif // __HURRICANE_ROUTINGPAD__ diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index 558b83ee..c06e0343 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -1160,7 +1160,7 @@ namespace Hurricane { , _drawingPlanes (QSize(_initialSide+2*_stripWidth,_initialSide+2*_stripWidth),this) , _drawingQuery (this) , _textDrawingQuery (this) - , _darkening (100) + , _darkening (DisplayStyle::HSVr()) , _mousePosition (0,0) , _spot (this) , _state (new State(NULL)) @@ -1384,7 +1384,7 @@ namespace Hurricane { _drawingPlanes.painter().setClipRect ( redrawArea ); _drawingPlanes.painter().eraseRect ( redrawArea ); - setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : 100 ); + setDarkening ( (_state->showSelection()) ? Graphics::getDarkening() : DisplayStyle::HSVr() ); if ( getCell() ) { diff --git a/hurricane/src/viewer/ColorScale.cpp b/hurricane/src/viewer/ColorScale.cpp index 05a94b53..4e0c27a7 100644 --- a/hurricane/src/viewer/ColorScale.cpp +++ b/hurricane/src/viewer/ColorScale.cpp @@ -68,12 +68,12 @@ namespace Hurricane { } - QBrush ColorScale::getBrush ( size_t i, int darkening ) const + QBrush ColorScale::getBrush ( size_t i, const DisplayStyle::HSVr& darkening ) const { assert ( _brush[i] != NULL ); QBrush brush ( *_brush[i] ); - brush.setColor ( _color[i]->darker(darkening) ); + brush.setColor ( DisplayStyle::darken(*_color[i],darkening) ); return brush; } diff --git a/hurricane/src/viewer/ControllerWidget.cpp b/hurricane/src/viewer/ControllerWidget.cpp index fb804da5..84020598 100644 --- a/hurricane/src/viewer/ControllerWidget.cpp +++ b/hurricane/src/viewer/ControllerWidget.cpp @@ -215,7 +215,7 @@ namespace Hurricane { void TabNetlist::setSyncNetlist ( bool state ) { - if ( state && getCellWidget() ) { + if ( state and getCellWidget() ) { _netlistBrowser->setCell ( getCellWidget()->getCell() ); } else { _netlistBrowser->setCell ( NULL ); @@ -225,9 +225,9 @@ namespace Hurricane { void TabNetlist::setSyncSelection ( bool state ) { - if ( state && getCellWidget() && _syncNetlist->isChecked() ) { + if ( state and getCellWidget() and _syncNetlist->isChecked() ) { _cwCumulativeSelection = getCellWidget()->cumulativeSelection(); - if ( !_cwCumulativeSelection ) { + if ( not _cwCumulativeSelection ) { getCellWidget()->openRefreshSession (); getCellWidget()->unselectAll (); getCellWidget()->closeRefreshSession (); diff --git a/hurricane/src/viewer/DisplayStyle.cpp b/hurricane/src/viewer/DisplayStyle.cpp index 12345d4f..c1e72519 100644 --- a/hurricane/src/viewer/DisplayStyle.cpp +++ b/hurricane/src/viewer/DisplayStyle.cpp @@ -32,16 +32,7 @@ namespace { - QColor modifySaturation ( const QColor& color, int darkening ) - { - QColor hsvColor = color.toHsv(); - if ( darkening != 100 ) { - qreal darkSat = color.saturationF(); - qreal darkValue = color.valueF(); - hsvColor.setHsvF ( color.hueF(), darkSat/3.0, darkValue/2.5 ); - } - return hsvColor; - } + using namespace Hurricane; } // End of anonymous namespace. @@ -135,34 +126,34 @@ namespace Hurricane { } - QColor DrawingStyle::getColor ( int darkening ) const + QColor DrawingStyle::getColor ( const DisplayStyle::HSVr& darkening ) const { assert ( _color != NULL ); //return _color->darker ( darkening ); - return modifySaturation(*_color,darkening); + return DisplayStyle::darken(*_color,darkening); } - QPen DrawingStyle::getPen ( int darkening ) const + QPen DrawingStyle::getPen ( const DisplayStyle::HSVr& darkening ) const { assert ( _pen != NULL ); QPen pen ( *_pen ); //pen.setColor ( _color->darker(darkening) ); - pen.setColor ( modifySaturation(*_color,darkening) ); + pen.setColor ( DisplayStyle::darken(*_color,darkening) ); return pen; } - QBrush DrawingStyle::getBrush ( int darkening ) const + QBrush DrawingStyle::getBrush ( const DisplayStyle::HSVr& darkening ) const { assert ( _brush != NULL ); QBrush brush ( *_brush ); //brush.setColor ( _color->darker(darkening) ); - brush.setColor ( modifySaturation(*_color,darkening) ); + brush.setColor ( DisplayStyle::darken(*_color,darkening) ); return brush; } @@ -273,11 +264,29 @@ namespace Hurricane { } + QColor DisplayStyle::darken ( const QColor& color, const DisplayStyle::HSVr& darkening ) + { + QColor hsvColor = color.toHsv(); + if ( not darkening.isId() ) { + qreal darkHue = color.hueF(); + qreal darkSat = color.saturationF(); + qreal darkValue = color.valueF(); + + //hsvColor.setHsvF ( darkHue/darkening.getHue(), darkSat/3.0, darkValue/2.5 ); + hsvColor.setHsvF ( darkHue /darkening.getHue() + , darkSat /darkening.getSaturation() + , darkValue/darkening.getValue() + ); + } + return hsvColor; + } + + DisplayStyle::DisplayStyle ( const Name& name ) : _name(name) , _description("") , _groups() - , _darkening(200) + , _darkening(1.0,3.0,2.5) { addDrawingStyle ( Viewer, Fallback , "FFFFFFFFFFFFFFFF", 0, 0, 0, 1, 1.0 ); addDrawingStyle ( Viewer, Background , "FFFFFFFFFFFFFFFF", 50, 50, 50, 1, 1.0 ); @@ -333,19 +342,19 @@ namespace Hurricane { } - QColor DisplayStyle::getColor ( const Name& key, int darkening ) const + QColor DisplayStyle::getColor ( const Name& key, const DisplayStyle::HSVr& darkening ) const { return find(key)->getColor(darkening); } - QPen DisplayStyle::getPen ( const Name& key, int darkening ) const + QPen DisplayStyle::getPen ( const Name& key, const DisplayStyle::HSVr& darkening ) const { return find(key)->getPen(darkening); } - QBrush DisplayStyle::getBrush ( const Name& key, int darkening ) const + QBrush DisplayStyle::getBrush ( const Name& key, const DisplayStyle::HSVr& darkening ) const { return find(key)->getBrush(darkening); } @@ -403,10 +412,18 @@ namespace Hurricane { } - void DisplayStyle::setDarkening ( int darkening ) + void DisplayStyle::setDarkening ( const DisplayStyle::HSVr& darkening ) { - if ( darkening <= 0 ) { - cerr << "[ERROR] Invalid darkening factor: " << darkening << "." << endl; + if ( darkening.getHue() < 0.1 ) { + cerr << "[ERROR] Invalid hue darkening factor: " << darkening.getHue() << "." << endl; + return; + } + if ( darkening.getSaturation() < 0.1 ) { + cerr << "[ERROR] Invalid saturation darkening factor: " << darkening.getSaturation() << "." << endl; + return; + } + if ( darkening.getValue() < 0.1 ) { + cerr << "[ERROR] Invalid value darkening factor: " << darkening.getValue() << "." << endl; return; } diff --git a/hurricane/src/viewer/Graphics.cpp b/hurricane/src/viewer/Graphics.cpp index 440511ce..ca071f6f 100644 --- a/hurricane/src/viewer/Graphics.cpp +++ b/hurricane/src/viewer/Graphics.cpp @@ -255,19 +255,19 @@ namespace Hurricane { } - QColor Graphics::getColor ( const Name& key, int darkening ) + QColor Graphics::getColor ( const Name& key, const DisplayStyle::HSVr& darkening ) { return getGraphics()->_getColor ( key, darkening ); } - QPen Graphics::getPen ( const Name& key, int darkening ) + QPen Graphics::getPen ( const Name& key, const DisplayStyle::HSVr& darkening ) { return getGraphics()->_getPen ( key, darkening ); } - QBrush Graphics::getBrush ( const Name& key, int darkening ) + QBrush Graphics::getBrush ( const Name& key, const DisplayStyle::HSVr& darkening ) { return getGraphics()->_getBrush ( key, darkening ); } @@ -285,7 +285,7 @@ namespace Hurricane { } - int Graphics::getDarkening () + const DisplayStyle::HSVr& Graphics::getDarkening () { return getGraphics()->_getDarkening (); } @@ -297,6 +297,12 @@ namespace Hurricane { } + QColor Graphics::darken ( const QColor& color ) + { + return DisplayStyle::darken ( color, getDarkening() ); + } + + const TextTranslator& Graphics::getHtmlTranslator () { return getGraphics()->_getHtmlTranslator(); diff --git a/hurricane/src/viewer/NetlistModel.cpp b/hurricane/src/viewer/NetlistModel.cpp index 9641b5a8..46959f6e 100644 --- a/hurricane/src/viewer/NetlistModel.cpp +++ b/hurricane/src/viewer/NetlistModel.cpp @@ -55,13 +55,6 @@ namespace Hurricane { static QFont nameFont = Graphics::getFixedFont ( QFont::Bold ); static QFont valueFont = Graphics::getFixedFont ( QFont::Normal, true ); - if ( role == Qt::SizeHintRole ) { - switch (index.column()) { - case 0: return 200; - default: return -1; - } - } - if ( role == Qt::FontRole ) { if ( index.row() == 0 ) return QVariant(); switch (index.column()) { @@ -71,7 +64,7 @@ namespace Hurricane { return QVariant(); } - if ( !index.isValid() ) return QVariant (); + if ( not index.isValid() ) return QVariant (); if ( role == Qt::DisplayRole ) { int row = index.row (); diff --git a/hurricane/src/viewer/NetlistWidget.cpp b/hurricane/src/viewer/NetlistWidget.cpp index d8df5562..ba3974d6 100644 --- a/hurricane/src/viewer/NetlistWidget.cpp +++ b/hurricane/src/viewer/NetlistWidget.cpp @@ -80,7 +80,6 @@ namespace Hurricane { QHeaderView* horizontalHeader = _view->horizontalHeader (); horizontalHeader->setStretchLastSection ( true ); - horizontalHeader->setMinimumSectionSize ( 200 ); QHeaderView* verticalHeader = _view->verticalHeader (); verticalHeader->setVisible ( false ); diff --git a/hurricane/src/viewer/hurricane/viewer/CellWidget.h b/hurricane/src/viewer/hurricane/viewer/CellWidget.h index 9e69f8d0..d3928ca3 100644 --- a/hurricane/src/viewer/hurricane/viewer/CellWidget.h +++ b/hurricane/src/viewer/hurricane/viewer/CellWidget.h @@ -124,197 +124,197 @@ namespace Hurricane { }; public: // Constructor & Destructor. - CellWidget ( QWidget* parent=NULL ); - virtual ~CellWidget (); - // Accessors. - // MapView* getMapView () { return _mapView; }; - void setCell ( Cell* ); - inline Cell* getCell () const; - inline shared_ptr& getState (); - inline PaletteWidget* getPalette (); - 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; - inline Query::Mask getQueryFilter () const ; - void bindToPalette ( PaletteWidget* ); - void detachFromPalette (); - void bindCommand ( Command* ); - void unbindCommand ( Command* ); - inline void setActiveCommand ( Command* ); - inline Command* getActiveCommand () const; - inline void resetActiveCommand (); - inline void setCursorStep ( DbU::Unit ); - inline void setRealSnapGridStep ( DbU::Unit step ); - inline unsigned int getDbuMode () 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; - inline void setDbuMode ( int ); - inline void setUnitPower ( DbU::UnitPower ); - inline void setRubberShape ( RubberShape ); - inline void setStartLevel ( int ); - inline void setStopLevel ( int ); - inline void setQueryFilter ( Query::Mask ); - inline bool timeout ( const char*, const Timer&, double timeout, bool& timedout ) const; + CellWidget ( QWidget* parent=NULL ); + virtual ~CellWidget (); + // Accessors. + // MapView* getMapView () { return _mapView; }; + void setCell ( Cell* ); + inline Cell* getCell () const; + inline shared_ptr& getState (); + inline PaletteWidget* getPalette (); + 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; + inline Query::Mask getQueryFilter () const ; + void bindToPalette ( PaletteWidget* ); + void detachFromPalette (); + void bindCommand ( Command* ); + void unbindCommand ( Command* ); + inline void setActiveCommand ( Command* ); + inline Command* getActiveCommand () const; + inline void resetActiveCommand (); + inline void setCursorStep ( DbU::Unit ); + inline void setRealSnapGridStep ( DbU::Unit step ); + inline unsigned int getDbuMode () 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; + inline void setDbuMode ( int ); + inline void setUnitPower ( DbU::UnitPower ); + inline void setRubberShape ( RubberShape ); + inline void setStartLevel ( int ); + inline void setStopLevel ( int ); + inline void setQueryFilter ( Query::Mask ); + inline bool timeout ( const char*, const Timer&, double timeout, bool& timedout ) const; // Painter control & Hurricane objects drawing primitives. - inline void setEnableRedrawInterrupt ( bool ); - inline void addDrawExtensionGo ( const Name&, InitExtensionGo_t*, DrawExtensionGo_t* ); - inline QPainter& getPainter ( size_t plane=PlaneId::Working ); - inline int getDarkening () const; - inline void copyToPrinter ( QPrinter*, bool imageOnly = false ); - inline void copyToImage ( QImage*, bool noScale = false ); - inline const float& getScale () const; - inline const QPoint& getMousePosition () const; - inline void updateMousePosition (); - void setLayerVisible ( const Name& layer, bool visible ); - bool isDrawable ( const Name& ); - bool isDrawableLayer ( const Name& ); - bool isDrawableExtension ( const Name& ); - bool isSelectable ( const Name& ) const; - bool isSelectable ( const Layer* ) const; - inline void setDarkening ( int ); - inline void setPen ( const QPen& , size_t plane=PlaneId::Working ); - void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); - 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 char*, unsigned int flags=0, int angle=0 ); - void drawGrid ( QRect ); - void drawSpot (); - void drawRuler ( shared_ptr ); - void drawRulers ( QRect ); - void drawDisplayText ( const QRect& , const char*, unsigned int flags=0 ); - void drawDisplayText ( const QPoint&, const char*, unsigned int flags=0, int angle=0 ); - void drawScreenPolygon ( const QPoint*, int count, size_t plane=PlaneId::Working ); - 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 ); - void drawScreenPolyline ( const QPoint*, int, int, size_t plane=PlaneId::Working ); - // Geometric conversions. - inline DbU::Unit toDbu ( float ) const; - QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint=true ) const; - QRect dbuToDisplayRect ( const Box& box , bool usePoint=true ) const; - QPoint dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const; - QPoint dbuToDisplayPoint ( const Point& point ) const; - inline int dbuToDisplayX ( DbU::Unit x ) const; - inline int dbuToDisplayY ( DbU::Unit y ) const; - inline int dbuToDisplayLength ( DbU::Unit length ) const; - inline int dbuToScreenX ( DbU::Unit x ) const; - inline int dbuToScreenY ( DbU::Unit y ) const; - QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const; - inline QPoint dbuToScreenPoint ( const Point& point ) const; - inline DbU::Unit displayToDbuX ( int x ) const; - inline DbU::Unit displayToDbuY ( int y ) const; - inline DbU::Unit displayToDbuLength ( int length ) const; - inline Box displayToDbuBox ( const QRect& rect ) const; - inline DbU::Unit screenToDbuX ( int x ) const; - 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; - inline Box getVisibleArea () const; - Box computeVisibleArea ( float scale ) const; - Box computeVisibleArea ( float scale, const Point& topLeft ) const; - Box computeVisibleArea ( const Box&, float& scale ) const; - inline DbU::Unit cursorStep () const; - inline bool _underDetailedGridThreshold() const; - inline DbU::Unit _snapGridStep () const; - inline DbU::Unit _onSnapGrid ( DbU::Unit ) const; - inline Point _onSnapGrid ( const Point& ) const; - inline DbU::Unit _onCursorGrid ( DbU::Unit ) const; - inline Point _onCursorGrid ( const Point& ) const; - // Qt QWidget Functions Overloads. - void pushCursor ( Qt::CursorShape cursor ); - void popCursor (); - virtual QSize minimumSizeHint () const; - virtual void showEvent ( QShowEvent* ); - virtual void paintEvent ( QPaintEvent* ); - virtual void resizeEvent ( QResizeEvent* ); - virtual void wheelEvent ( QWheelEvent* ); - virtual void keyPressEvent ( QKeyEvent* ); - virtual void keyReleaseEvent ( QKeyEvent* ); - virtual void mouseMoveEvent ( QMouseEvent* ); - virtual void mousePressEvent ( QMouseEvent* ); - virtual void mouseReleaseEvent ( QMouseEvent* ); - signals: - void cellChanged ( Cell* ); - void cellPreModificated (); - void cellPostModificated (); - void stateChanged ( shared_ptr& ); - void styleChanged (); - void queryFilterChanged (); - void dbuModeChanged ( unsigned int mode, DbU::UnitPower ); - void updatePalette ( Cell* ); - void mousePositionChanged ( const Point& position ); - void selectionModeChanged (); - void selectionChanged ( const SelectorSet& ); - void selectionToggled ( Occurrence ); - void showBoundariesToggled ( bool ); + inline void setEnableRedrawInterrupt ( bool ); + inline void addDrawExtensionGo ( const Name&, InitExtensionGo_t*, DrawExtensionGo_t* ); + inline QPainter& getPainter ( size_t plane=PlaneId::Working ); + inline const DisplayStyle::HSVr& getDarkening () const; + inline void copyToPrinter ( QPrinter*, bool imageOnly = false ); + inline void copyToImage ( QImage*, bool noScale = false ); + inline const float& getScale () const; + inline const QPoint& getMousePosition () const; + inline void updateMousePosition (); + void setLayerVisible ( const Name& layer, bool visible ); + bool isDrawable ( const Name& ); + bool isDrawableLayer ( const Name& ); + bool isDrawableExtension ( const Name& ); + bool isSelectable ( const Name& ) const; + bool isSelectable ( const Layer* ) const; + inline void setDarkening ( const DisplayStyle::HSVr& ); + inline void setPen ( const QPen& , size_t plane=PlaneId::Working ); + void drawBox ( DbU::Unit, DbU::Unit, DbU::Unit, DbU::Unit ); + 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 char*, unsigned int flags=0, int angle=0 ); + void drawGrid ( QRect ); + void drawSpot (); + void drawRuler ( shared_ptr ); + void drawRulers ( QRect ); + void drawDisplayText ( const QRect& , const char*, unsigned int flags=0 ); + void drawDisplayText ( const QPoint&, const char*, unsigned int flags=0, int angle=0 ); + void drawScreenPolygon ( const QPoint*, int count, size_t plane=PlaneId::Working ); + 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 ); + void drawScreenPolyline ( const QPoint*, int, int, size_t plane=PlaneId::Working ); + // Geometric conversions. + inline DbU::Unit toDbu ( float ) const; + QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2, bool usePoint=true ) const; + QRect dbuToDisplayRect ( const Box& box , bool usePoint=true ) const; + QPoint dbuToDisplayPoint ( DbU::Unit x, DbU::Unit y ) const; + QPoint dbuToDisplayPoint ( const Point& point ) const; + inline int dbuToDisplayX ( DbU::Unit x ) const; + inline int dbuToDisplayY ( DbU::Unit y ) const; + inline int dbuToDisplayLength ( DbU::Unit length ) const; + inline int dbuToScreenX ( DbU::Unit x ) const; + inline int dbuToScreenY ( DbU::Unit y ) const; + QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const; + inline QPoint dbuToScreenPoint ( const Point& point ) const; + inline DbU::Unit displayToDbuX ( int x ) const; + inline DbU::Unit displayToDbuY ( int y ) const; + inline DbU::Unit displayToDbuLength ( int length ) const; + inline Box displayToDbuBox ( const QRect& rect ) const; + inline DbU::Unit screenToDbuX ( int x ) const; + 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; + inline Box getVisibleArea () const; + Box computeVisibleArea ( float scale ) const; + Box computeVisibleArea ( float scale, const Point& topLeft ) const; + Box computeVisibleArea ( const Box&, float& scale ) const; + inline DbU::Unit cursorStep () const; + inline bool _underDetailedGridThreshold() const; + inline DbU::Unit _snapGridStep () const; + inline DbU::Unit _onSnapGrid ( DbU::Unit ) const; + inline Point _onSnapGrid ( const Point& ) const; + inline DbU::Unit _onCursorGrid ( DbU::Unit ) const; + inline Point _onCursorGrid ( const Point& ) const; + // Qt QWidget Functions Overloads. + void pushCursor ( Qt::CursorShape cursor ); + void popCursor (); + virtual QSize minimumSizeHint () const; + virtual void showEvent ( QShowEvent* ); + virtual void paintEvent ( QPaintEvent* ); + virtual void resizeEvent ( QResizeEvent* ); + virtual void wheelEvent ( QWheelEvent* ); + virtual void keyPressEvent ( QKeyEvent* ); + virtual void keyReleaseEvent ( QKeyEvent* ); + virtual void mouseMoveEvent ( QMouseEvent* ); + virtual void mousePressEvent ( QMouseEvent* ); + virtual void mouseReleaseEvent ( QMouseEvent* ); + signals: + void cellChanged ( Cell* ); + void cellPreModificated (); + void cellPostModificated (); + void stateChanged ( shared_ptr& ); + void styleChanged (); + void queryFilterChanged (); + void dbuModeChanged ( unsigned int mode, DbU::UnitPower ); + void updatePalette ( Cell* ); + void mousePositionChanged ( const Point& position ); + void selectionModeChanged (); + void selectionChanged ( const SelectorSet& ); + void selectionToggled ( Occurrence ); + void showBoundariesToggled ( bool ); public slots: // Qt QWidget Slots Overload & CellWidget Specifics. - void setState ( shared_ptr& ); - inline void openRefreshSession (); - inline void closeRefreshSession (); - inline DrawingPlanes& getDrawingPlanes (); - inline QPoint& getOffsetVA (); - // void select ( const Net* ); - void select ( Occurrence ); - bool isSelected ( Occurrence ); - void selectOccurrencesUnder ( Box selectArea ); - // void unselect ( const Net* ); - void unselect ( Occurrence ); - void unselectAll (); - void toggleSelection ( Occurrence ); - void setShowSelection ( bool state ); - void setCumulativeSelection ( bool state ); - // void _select ( const Net* ); - // void _unselect ( const Net* ); - // void _selectOccurrencesUnder ( Box selectArea ); - void _unselectAll (); - inline void addRuler ( const Point&, const Point& ); - inline void addRuler ( shared_ptr ); - inline void clearRulers (); - void changeQueryFilter (); - void rubberChange (); - void changeDbuMode ( unsigned int mode, DbU::UnitPower ); - void setStyle ( int id ); - void updatePalette (); - void cellPreModificate (); - void cellPostModificate (); - inline void refresh (); - void _redraw ( QRect redrawArea ); - inline void redrawSelection (); - void redrawSelection ( QRect redrawArea ); - void goLeft ( int dx = 0 ); - void goRight ( int dx = 0 ); - void goUp ( int dy = 0 ); - void goDown ( int dy = 0 ); - void fitToContents ( bool historyEnable=true ); - void fitToNet ( const Net*, bool historyEnable=true ); - void setScale ( float ); - void scaleHistoryUp (); - void scaleHistoryDown (); - // void setGridMode (); - // void setSymbolicMode (); - // void setPhysicalMode ( DbU::UnitPower ); - void setShowBoundaries ( bool state ); - void reframe (); - void reframe ( const Box& box, bool historyEnable=true ); - void displayReframe (); - void _goLeft ( int dx ); - void _goRight ( int dx ); - void _goUp ( int dy ); - void _goDown ( int dy ); - void _refresh (); + void setState ( shared_ptr& ); + inline void openRefreshSession (); + inline void closeRefreshSession (); + inline DrawingPlanes& getDrawingPlanes (); + inline QPoint& getOffsetVA (); + // void select ( const Net* ); + void select ( Occurrence ); + bool isSelected ( Occurrence ); + void selectOccurrencesUnder ( Box selectArea ); + // void unselect ( const Net* ); + void unselect ( Occurrence ); + void unselectAll (); + void toggleSelection ( Occurrence ); + void setShowSelection ( bool state ); + void setCumulativeSelection ( bool state ); + // void _select ( const Net* ); + // void _unselect ( const Net* ); + // void _selectOccurrencesUnder ( Box selectArea ); + void _unselectAll (); + inline void addRuler ( const Point&, const Point& ); + inline void addRuler ( shared_ptr ); + inline void clearRulers (); + void changeQueryFilter (); + void rubberChange (); + void changeDbuMode ( unsigned int mode, DbU::UnitPower ); + void setStyle ( int id ); + void updatePalette (); + void cellPreModificate (); + void cellPostModificate (); + inline void refresh (); + void _redraw ( QRect redrawArea ); + inline void redrawSelection (); + void redrawSelection ( QRect redrawArea ); + void goLeft ( int dx = 0 ); + void goRight ( int dx = 0 ); + void goUp ( int dy = 0 ); + void goDown ( int dy = 0 ); + void fitToContents ( bool historyEnable=true ); + void fitToNet ( const Net*, bool historyEnable=true ); + void setScale ( float ); + void scaleHistoryUp (); + void scaleHistoryDown (); + // void setGridMode (); + // void setSymbolicMode (); + // void setPhysicalMode ( DbU::UnitPower ); + void setShowBoundaries ( bool state ); + void reframe (); + void reframe ( const Box& box, bool historyEnable=true ); + void displayReframe (); + void _goLeft ( int dx ); + void _goRight ( int dx ); + void _goUp ( int dy ); + void _goDown ( int dy ); + void _refresh (); private: class Spot { @@ -650,7 +650,7 @@ namespace Hurricane { DrawingPlanes _drawingPlanes; DrawingQuery _drawingQuery; TextDrawingQuery _textDrawingQuery; - int _darkening; + DisplayStyle::HSVr _darkening; QPoint _mousePosition; Spot _spot; shared_ptr _state; @@ -1335,7 +1335,7 @@ namespace Hurricane { { return _drawingPlanes.painter(plane); } - inline int CellWidget::getDarkening () const + inline const DisplayStyle::HSVr& CellWidget::getDarkening () const { return _darkening; } @@ -1389,7 +1389,7 @@ namespace Hurricane { { _drawingPlanes.painter(plane).setPen(pen); } - inline void CellWidget::setDarkening ( int darkening ) + inline void CellWidget::setDarkening ( const DisplayStyle::HSVr& darkening ) { _darkening = darkening; } diff --git a/hurricane/src/viewer/hurricane/viewer/ColorScale.h b/hurricane/src/viewer/hurricane/viewer/ColorScale.h index 33d8eaa6..65ed49fb 100644 --- a/hurricane/src/viewer/hurricane/viewer/ColorScale.h +++ b/hurricane/src/viewer/hurricane/viewer/ColorScale.h @@ -30,6 +30,7 @@ #include #include #include "hurricane/Name.h" +#include "hurricane/viewer/DisplayStyle.h" namespace Hurricane { @@ -53,7 +54,7 @@ namespace Hurricane { // Accessors. void qtAllocate (); inline const Name& getName () const; - QBrush getBrush ( size_t , int darkening ) const; + QBrush getBrush ( size_t, const DisplayStyle::HSVr& darkening ) const; protected: // Internal - Attributes. diff --git a/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h b/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h index 6ed7c8d0..8738654f 100644 --- a/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h +++ b/hurricane/src/viewer/hurricane/viewer/DisplayStyle.h @@ -29,78 +29,17 @@ #include #include - #include #include #include - #include "hurricane/Commons.h" #include "hurricane/Name.h" - #include "hurricane/viewer/ScreenUtilities.h" namespace Hurricane { - - class DrawingStyle { - - public: - // Constructors & Destructors. - static DrawingStyle* create ( const Name& name - , const string& pattern ="FFFFFFFFFFFFFFFF" - , int red =0 - , int green =0 - , int blue =0 - , int borderWidth=0 - , float threshold =1.0 - , bool goMatched =true - ); - DrawingStyle* link (); - size_t unlink (); - - // Accessors. - void qtAllocate (); - inline bool isGoMatched () const; - inline const Name& getName () const; - inline const string& getPattern () const; - QColor getColor ( int darkening ) const; - QPen getPen ( int darkening ) const; - QBrush getBrush ( int darkening ) const; - inline float getThreshold () const; - - protected: - // Internal - Attributes. - const Name _name; - int _red; - int _green; - int _blue; - int _borderWidth; - string _pattern; - QColor *_color; - QPen *_pen; - QBrush *_brush; - float _threshold; - bool _goMatched; - size_t _refcount; - - // Internal - Constructors & Destructors. - DrawingStyle ( const Name& name - , const string& pattern - , int red - , int green - , int blue - , int borderWidth - , float threshold - , bool goMatched - ); - DrawingStyle ( const DrawingStyle& ); - ~DrawingStyle (); - DrawingStyle& operator= ( const DrawingStyle& ); - - }; - - + class DrawingStyle; class DrawingGroup { @@ -142,6 +81,22 @@ namespace Hurricane { class DisplayStyle { + public: + class HSVr { + public: + inline HSVr ( float hue=1.0, float saturation=1.0, float value=1.0 ); + inline bool isId () const; + inline float getHue () const; + inline float getSaturation () const; + inline float getValue () const; + inline void setHue ( float ); + inline void setSaturation ( float ); + inline void setValue ( float ); + private: + float _hue; + float _saturation; + float _value; + }; public: // Static Members. @@ -166,6 +121,7 @@ namespace Hurricane { static const Name Undef; static const Name UnmatchedGroup; + static QColor darken ( const QColor& color, const DisplayStyle::HSVr& darkening ); // Constructor & Destructor. DisplayStyle ( const Name& name ); ~DisplayStyle (); @@ -173,12 +129,12 @@ namespace Hurricane { // Accessors. const Name& getName () const; inline const string& getDescription () const; - inline int getDarkening () const; + inline const HSVr& getDarkening () const; const Name& getGroup ( const Name& key ) const; const string& getPattern ( const Name& key ) const; - QColor getColor ( const Name& key, int darkening ) const; - QPen getPen ( const Name& key, int darkening ) const; - QBrush getBrush ( const Name& key, int darkening ) const; + QColor getColor ( const Name& key, const HSVr& ) const; + QPen getPen ( const Name& key, const HSVr& ) const; + QBrush getBrush ( const Name& key, const HSVr& ) const; float getThreshold ( const Name& key ) const; inline const vector& getDrawingGroups () const; DrawingStyle* find ( const Name& key ) const; @@ -188,7 +144,7 @@ namespace Hurricane { inline void setDescription ( const string& description ); inline void setDescription ( const char* description ); void inheritFrom ( const DisplayStyle* base ); - void setDarkening ( int darkening ); + void setDarkening ( const HSVr& ); void addDrawingStyle ( const Name& groupKey , const Name& key , const string& pattern @@ -205,7 +161,7 @@ namespace Hurricane { const Name _name; string _description; vector _groups; - int _darkening; + HSVr _darkening; // Internals - Methods. void findOrCreate ( const Name& groupKey @@ -218,6 +174,63 @@ namespace Hurricane { }; + class DrawingStyle { + public: + // Constructors & Destructors. + static DrawingStyle* create ( const Name& name + , const string& pattern ="FFFFFFFFFFFFFFFF" + , int red =0 + , int green =0 + , int blue =0 + , int borderWidth=0 + , float threshold =1.0 + , bool goMatched =true + ); + DrawingStyle* link (); + size_t unlink (); + public: + // Accessors. + void qtAllocate (); + inline bool isGoMatched () const; + inline const Name& getName () const; + inline const string& getPattern () const; + QColor getColor ( const DisplayStyle::HSVr& ) const; + QPen getPen ( const DisplayStyle::HSVr& ) const; + QBrush getBrush ( const DisplayStyle::HSVr& ) const; + inline float getThreshold () const; + private: + // Internal - Attributes. + const Name _name; + int _red; + int _green; + int _blue; + int _borderWidth; + string _pattern; + QColor *_color; + QPen *_pen; + QBrush *_brush; + float _threshold; + bool _goMatched; + size_t _refcount; + private: + // Internal - Constructors & Destructors. + DrawingStyle ( const Name& name + , const string& pattern + , int red + , int green + , int blue + , int borderWidth + , float threshold + , bool goMatched + ); + DrawingStyle ( const DrawingStyle& ); + ~DrawingStyle (); + DrawingStyle& operator= ( const DrawingStyle& ); + }; + + + + // Functions. @@ -231,11 +244,22 @@ namespace Hurricane { inline const Name& DisplayStyle::getName () const { return _name; } inline const vector& DisplayStyle::getDrawingGroups () const { return _groups; } - inline int DisplayStyle::getDarkening () const { return _darkening; } + inline const DisplayStyle::HSVr& DisplayStyle::getDarkening () const { return _darkening; } inline const string& DisplayStyle::getDescription () const { return _description; } inline void DisplayStyle::setDescription ( const string& description ) { _description = description; } inline void DisplayStyle::setDescription ( const char* description ) { _description = description; } + inline DisplayStyle::HSVr::HSVr ( float hue, float saturation, float value ) + : _hue(hue), _saturation(saturation), _value(value) { } + + inline bool DisplayStyle::HSVr::isId () const { return (_hue==1.0) and (_saturation==1.0) and (_value==1.0); } + inline float DisplayStyle::HSVr::getHue () const { return _hue; } + inline float DisplayStyle::HSVr::getSaturation () const { return _saturation; } + inline float DisplayStyle::HSVr::getValue () const { return _value; } + inline void DisplayStyle::HSVr::setHue ( float hue ) { _hue=hue; } + inline void DisplayStyle::HSVr::setSaturation ( float saturation ) { _saturation=saturation; } + inline void DisplayStyle::HSVr::setValue ( float value ) { _value=value; } + } // End of Hurricane namespace. diff --git a/hurricane/src/viewer/hurricane/viewer/Graphics.h b/hurricane/src/viewer/hurricane/viewer/Graphics.h index 986c699b..c0c68f96 100644 --- a/hurricane/src/viewer/hurricane/viewer/Graphics.h +++ b/hurricane/src/viewer/hurricane/viewer/Graphics.h @@ -60,13 +60,14 @@ namespace Hurricane { static const QFont getFixedFont ( int weight=QFont::Normal, bool italic=false, bool underline=false, int scale=0 ); 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 QColor getColor ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() ); + static QPen getPen ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() ); + static QBrush getBrush ( const Name& key, const DisplayStyle::HSVr& darkening=DisplayStyle::HSVr() ); static const string& getPattern ( const Name& key ); static float getThreshold ( const Name& key ); - static int getDarkening (); + static const DisplayStyle::HSVr& getDarkening (); static const ColorScale& getColorScale ( ColorScale::ScaleType ); + static QColor darken ( const QColor& ); static const TextTranslator& getHtmlTranslator(); static string toHtml ( const string& ); static bool breakpointStopCb ( const string& message ); @@ -106,12 +107,12 @@ namespace Hurricane { DisplayStyle* _getStyle () const; inline const vector& _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 QColor _getColor ( const Name& key, const DisplayStyle::HSVr& darkening ) const; + inline QPen _getPen ( const Name& key, const DisplayStyle::HSVr& darkening ) const; + inline QBrush _getBrush ( const Name& key, const DisplayStyle::HSVr& darkening ) const; inline const string& _getPattern ( const Name& key ) const; inline float _getThreshold ( const Name& key ) const; - inline int _getDarkening () const; + inline const DisplayStyle::HSVr& _getDarkening () const; inline const ColorScale& _getColorScale ( ColorScale::ScaleType ) const; inline void _enable (); inline const TextTranslator& _getHtmlTranslator () const; @@ -122,13 +123,13 @@ namespace Hurricane { inline const Name& Graphics::_getGroup ( const Name& name ) const { return _active->getGroup(name); } - inline QColor Graphics::_getColor ( const Name& name, int darkening ) const + inline QColor Graphics::_getColor ( const Name& name, const DisplayStyle::HSVr& darkening ) const { return _active->getColor(name,darkening); } - inline QPen Graphics::_getPen ( const Name& name, int darkening ) const + inline QPen Graphics::_getPen ( const Name& name, const DisplayStyle::HSVr& darkening ) const { return _active->getPen(name,darkening); } - inline QBrush Graphics::_getBrush ( const Name& name, int darkening ) const + inline QBrush Graphics::_getBrush ( const Name& name, const DisplayStyle::HSVr& darkening ) const { return _active->getBrush(name,darkening); } inline const string& Graphics::_getPattern ( const Name& name ) const @@ -137,7 +138,7 @@ namespace Hurricane { inline float Graphics::_getThreshold ( const Name& name ) const { return _active->getThreshold(name); } - inline int Graphics::_getDarkening () const + inline const DisplayStyle::HSVr& Graphics::_getDarkening () const { return _active->getDarkening(); } inline const ColorScale& Graphics::_getColorScale ( ColorScale::ScaleType id ) const