From 783ed6dc36d2f5adde3a2c2b216ac1a081b93a19 Mon Sep 17 00:00:00 2001 From: Christophe Alexandre Date: Mon, 7 Jan 2008 16:19:17 +0000 Subject: [PATCH] graphical view in progress --- hurricane/src/hurricane/Component.h | 2 +- hurricane/src/hurricane/CompositeLayer.cpp | 8 +- hurricane/src/hurricane/CompositeLayer.h | 10 +- hurricane/src/hurricane/Contact.cpp | 6 +- hurricane/src/hurricane/Contact.h | 4 +- hurricane/src/hurricane/Horizontal.cpp | 2 +- hurricane/src/hurricane/Horizontal.h | 2 +- hurricane/src/hurricane/Layer.cpp | 8 +- hurricane/src/hurricane/Layer.h | 4 +- hurricane/src/hurricane/Pad.cpp | 2 +- hurricane/src/hurricane/Pad.h | 2 +- hurricane/src/hurricane/Plug.cpp | 2 +- hurricane/src/hurricane/Plug.h | 2 +- hurricane/src/hurricane/RoutingPad.cpp | 2 +- hurricane/src/hurricane/RoutingPad.h | 2 +- hurricane/src/hurricane/Segment.cpp | 4 +- hurricane/src/hurricane/Segment.h | 4 +- hurricane/src/hurricane/Vertical.cpp | 2 +- hurricane/src/hurricane/Vertical.h | 2 +- hurricane/src/viewer/CellWidget.cpp | 210 +++++++++++++++++++-- hurricane/src/viewer/CellWidget.h | 39 +++- 21 files changed, 265 insertions(+), 54 deletions(-) diff --git a/hurricane/src/hurricane/Component.h b/hurricane/src/hurricane/Component.h index 042bb39a..3d14515f 100644 --- a/hurricane/src/hurricane/Component.h +++ b/hurricane/src/hurricane/Component.h @@ -78,7 +78,7 @@ class Component : public Go { public: virtual Point GetCenter() const {return GetPosition();}; public: virtual Layer* GetLayer() const = 0; public: virtual Box GetBoundingBox() const = 0; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const = 0; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const = 0; public: Components GetConnexComponents() const; public: Components GetSlaveComponents() const; diff --git a/hurricane/src/hurricane/CompositeLayer.cpp b/hurricane/src/hurricane/CompositeLayer.cpp index c4ed01f3..201c3a04 100644 --- a/hurricane/src/hurricane/CompositeLayer.cpp +++ b/hurricane/src/hurricane/CompositeLayer.cpp @@ -51,28 +51,28 @@ BasicLayers CompositeLayer::GetBasicLayers() const return GetCollection(_basicLayerList); } -Unit CompositeLayer::GetContactSize(BasicLayer* basicLayer) const +Unit CompositeLayer::GetContactSize(const BasicLayer* basicLayer) const // ************************************************************** { SizeMap::const_iterator it = _contactSizeMap.find(basicLayer); return ((it == _contactSizeMap.end()) ? 0 : (*it).second); } -Unit CompositeLayer::GetSegmentSize(BasicLayer* basicLayer) const +Unit CompositeLayer::GetSegmentSize(const BasicLayer* basicLayer) const // ************************************************************** { SizeMap::const_iterator it = _segmentSizeMap.find(basicLayer); return ((it == _segmentSizeMap.end()) ? 0 : (*it).second); } -Unit CompositeLayer::GetSegmentExtention(BasicLayer* basicLayer) const +Unit CompositeLayer::GetSegmentExtention(const BasicLayer* basicLayer) const // ******************************************************************* { SizeMap::const_iterator it = _segmentExtentionMap.find(basicLayer); return ((it == _segmentExtentionMap.end()) ? 0 : (*it).second); } -Unit CompositeLayer::GetPadSize(BasicLayer* basicLayer) const +Unit CompositeLayer::GetPadSize(const BasicLayer* basicLayer) const // ********************************************************** { SizeMap::const_iterator it = _padSizeMap.find(basicLayer); diff --git a/hurricane/src/hurricane/CompositeLayer.h b/hurricane/src/hurricane/CompositeLayer.h index 2dbd4f16..e378eed8 100644 --- a/hurricane/src/hurricane/CompositeLayer.h +++ b/hurricane/src/hurricane/CompositeLayer.h @@ -50,7 +50,7 @@ class CompositeLayer : public Layer { public: typedef list BasicLayerList; - public: typedef map SizeMap; + public: typedef map SizeMap; // Attributes // ********** @@ -79,10 +79,10 @@ class CompositeLayer : public Layer { public: const Type& GetType() const {return _type;}; public: virtual BasicLayers GetBasicLayers() const; - public: Unit GetContactSize(BasicLayer* basicLayer) const; - public: Unit GetSegmentSize(BasicLayer* basicLayer) const; - public: Unit GetSegmentExtention(BasicLayer* basicLayer) const; - public: Unit GetPadSize(BasicLayer* basicLayer) const; + public: Unit GetContactSize(const BasicLayer* basicLayer) const; + public: Unit GetSegmentSize(const BasicLayer* basicLayer) const; + public: Unit GetSegmentExtention(const BasicLayer* basicLayer) const; + public: Unit GetPadSize(const BasicLayer* basicLayer) const; public: const Unit& GetMaximalContactSize() const {return _maximalContactSize;}; public: const Unit& GetMaximalSegmentSize() const {return _maximalSegmentSize;}; public: const Unit& GetMaximalSegmentExtention() const {return _maximalSegmentExtention;}; diff --git a/hurricane/src/hurricane/Contact.cpp b/hurricane/src/hurricane/Contact.cpp index 6e39ba11..3f9e346a 100644 --- a/hurricane/src/hurricane/Contact.cpp +++ b/hurricane/src/hurricane/Contact.cpp @@ -183,7 +183,7 @@ Box Contact::GetBoundingBox() const return Box(GetPosition()).inflate(GetHalfWidth() + size, GetHalfHeight() + size); } -Box Contact::GetBoundingBox(BasicLayer* basicLayer) const +Box Contact::GetBoundingBox(const BasicLayer* basicLayer) const // ****************************************************** { if (!_layer->Contains(basicLayer)) return Box(); @@ -354,8 +354,8 @@ Unit Contact::_GetSize() const return size; } -Unit Contact::_GetSize(BasicLayer* basicLayer) const -// ************************************************* +Unit Contact::_GetSize(const BasicLayer* basicLayer) const +// ******************************************************* { Layer* layer = GetLayer(); diff --git a/hurricane/src/hurricane/Contact.h b/hurricane/src/hurricane/Contact.h index d53e9917..d07446f9 100644 --- a/hurricane/src/hurricane/Contact.h +++ b/hurricane/src/hurricane/Contact.h @@ -71,7 +71,7 @@ class Contact : public Component { public: virtual Point GetPosition() const; public: virtual Box GetBoundingBox() const; public: virtual Layer* GetLayer() const {return _layer;}; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: Hook* GetAnchorHook() {return &_anchorHook;}; public: Component* GetAnchor() const; public: const Unit& GetDx() const {return _dx;}; @@ -108,7 +108,7 @@ class Contact : public Component { public: virtual Record* _GetRecord() const; public: Unit _GetSize() const; - public: Unit _GetSize(BasicLayer* basicLayer) const; + public: Unit _GetSize(const BasicLayer* basicLayer) const; //public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); diff --git a/hurricane/src/hurricane/Horizontal.cpp b/hurricane/src/hurricane/Horizontal.cpp index 375b256c..c1f6d5bf 100644 --- a/hurricane/src/hurricane/Horizontal.cpp +++ b/hurricane/src/hurricane/Horizontal.cpp @@ -67,7 +67,7 @@ Box Horizontal::GetBoundingBox() const return Box(GetSourceX(), _y, GetTargetX(), _y).inflate(extention, size); } -Box Horizontal::GetBoundingBox(BasicLayer* basicLayer) const +Box Horizontal::GetBoundingBox(const BasicLayer* basicLayer) const // ********************************************************* { if (!GetLayer()->Contains(basicLayer)) return Box(); diff --git a/hurricane/src/hurricane/Horizontal.h b/hurricane/src/hurricane/Horizontal.h index f8c8e0cc..e73f5a1c 100644 --- a/hurricane/src/hurricane/Horizontal.h +++ b/hurricane/src/hurricane/Horizontal.h @@ -47,7 +47,7 @@ class Horizontal : public Segment { public: virtual Unit GetY() const {return _y;}; public: virtual Point GetCenter() const; public: virtual Box GetBoundingBox() const; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: virtual Unit GetSourceX() const; public: virtual Unit GetSourceY() const {return GetY();}; public: virtual Unit GetTargetX() const; diff --git a/hurricane/src/hurricane/Layer.cpp b/hurricane/src/hurricane/Layer.cpp index 848959f8..5e4c1eb3 100644 --- a/hurricane/src/hurricane/Layer.cpp +++ b/hurricane/src/hurricane/Layer.cpp @@ -38,14 +38,14 @@ Layer::Layer(Technology* technology, const Name& name, const Unit& minimalSize, throw Error("Can't create " + _TName("Layer") + " " + GetString(_name) + " : already exists"); } -bool Layer::Contains(Layer* layer) const -// ************************************* +bool Layer::Contains(const Layer* layer) const +// ******************************************* { return (layer && ((_mask & layer->GetMask()) == layer->GetMask())); } -bool Layer::Intersect(Layer* layer) const -// ************************************** +bool Layer::Intersect(const Layer* layer) const +// ******************************************** { return ((_mask & layer->GetMask()) != 0); } diff --git a/hurricane/src/hurricane/Layer.h b/hurricane/src/hurricane/Layer.h index ee171d00..fb908cf9 100644 --- a/hurricane/src/hurricane/Layer.h +++ b/hurricane/src/hurricane/Layer.h @@ -64,8 +64,8 @@ class Layer : public DBo { // Predicates // ********** - public: bool Contains(Layer* layer) const; - public: bool Intersect(Layer* layer) const; + public: bool Contains(const Layer* layer) const; + public: bool Intersect(const Layer* layer) const; // Updators // ******** diff --git a/hurricane/src/hurricane/Pad.cpp b/hurricane/src/hurricane/Pad.cpp index d28d8140..41184efc 100644 --- a/hurricane/src/hurricane/Pad.cpp +++ b/hurricane/src/hurricane/Pad.cpp @@ -65,7 +65,7 @@ Box Pad::GetBoundingBox() const return boundingBox; } -Box Pad::GetBoundingBox(BasicLayer* basicLayer) const +Box Pad::GetBoundingBox(const BasicLayer* basicLayer) const // ************************************************** { if (!_layer->Contains(basicLayer)) return Box(); diff --git a/hurricane/src/hurricane/Pad.h b/hurricane/src/hurricane/Pad.h index 95e56ac0..7e9d708e 100644 --- a/hurricane/src/hurricane/Pad.h +++ b/hurricane/src/hurricane/Pad.h @@ -48,7 +48,7 @@ class Pad : public Component { public: virtual Unit GetX() const; public: virtual Unit GetY() const; public: virtual Box GetBoundingBox() const; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: virtual Layer* GetLayer() const {return _layer;}; // Updators diff --git a/hurricane/src/hurricane/Plug.cpp b/hurricane/src/hurricane/Plug.cpp index 26723a5f..e24641e1 100644 --- a/hurricane/src/hurricane/Plug.cpp +++ b/hurricane/src/hurricane/Plug.cpp @@ -100,7 +100,7 @@ Box Plug::GetBoundingBox() const return _instance->GetTransformation().getBox(_masterNet->GetPosition()); } -Box Plug::GetBoundingBox(BasicLayer* basicLayer) const +Box Plug::GetBoundingBox(const BasicLayer* basicLayer) const // *************************************************** { return Box(); diff --git a/hurricane/src/hurricane/Plug.h b/hurricane/src/hurricane/Plug.h index 9e7c87f6..aa94355c 100644 --- a/hurricane/src/hurricane/Plug.h +++ b/hurricane/src/hurricane/Plug.h @@ -55,7 +55,7 @@ class Plug : public Component { public: virtual Point GetPosition() const; public: virtual Box GetBoundingBox() const; public: virtual Layer* GetLayer() const {return NULL;}; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: Instance* GetInstance() const {return _instance;}; public: Net* GetMasterNet() const {return _masterNet;}; diff --git a/hurricane/src/hurricane/RoutingPad.cpp b/hurricane/src/hurricane/RoutingPad.cpp index 511bd71c..9afa2fa9 100644 --- a/hurricane/src/hurricane/RoutingPad.cpp +++ b/hurricane/src/hurricane/RoutingPad.cpp @@ -101,7 +101,7 @@ Box RoutingPad::GetBoundingBox() const return Box(GetPosition()); } -Box RoutingPad::GetBoundingBox(BasicLayer* basicLayer) const +Box RoutingPad::GetBoundingBox(const BasicLayer* basicLayer) const // ****************************************************** { Component* component = _GetEntityAsComponent(); diff --git a/hurricane/src/hurricane/RoutingPad.h b/hurricane/src/hurricane/RoutingPad.h index 28db0d4a..309e7a6f 100644 --- a/hurricane/src/hurricane/RoutingPad.h +++ b/hurricane/src/hurricane/RoutingPad.h @@ -57,7 +57,7 @@ class RoutingPad : public Component { public: virtual Unit GetY() const; public: virtual Box GetBoundingBox() const; public: virtual Layer* GetLayer() const; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: virtual Point GetCenter() const; public: Occurrence GetOccurrence() const { return _occurrence; }; public: Occurrence GetPlugOccurrence(); diff --git a/hurricane/src/hurricane/Segment.cpp b/hurricane/src/hurricane/Segment.cpp index 0c36d7bd..d18a4442 100644 --- a/hurricane/src/hurricane/Segment.cpp +++ b/hurricane/src/hurricane/Segment.cpp @@ -340,7 +340,7 @@ Unit Segment::_GetExtention() const return extention; } -Unit Segment::_GetSize(BasicLayer* basicLayer) const +Unit Segment::_GetSize(const BasicLayer* basicLayer) const // ************************************************* { Layer* layer = GetLayer(); @@ -355,7 +355,7 @@ Unit Segment::_GetSize(BasicLayer* basicLayer) const return size; } -Unit Segment::_GetExtention(BasicLayer* basicLayer) const +Unit Segment::_GetExtention(const BasicLayer* basicLayer) const // ****************************************************** { Layer* layer = GetLayer(); diff --git a/hurricane/src/hurricane/Segment.h b/hurricane/src/hurricane/Segment.h index 5f65f5a4..14ff5402 100644 --- a/hurricane/src/hurricane/Segment.h +++ b/hurricane/src/hurricane/Segment.h @@ -114,8 +114,8 @@ class Segment : public Component { public: Unit _GetSize() const; public: Unit _GetExtention() const; - public: Unit _GetSize(BasicLayer* basicLayer) const; - public: Unit _GetExtention(BasicLayer* basicLayer) const; + public: Unit _GetSize(const BasicLayer* basicLayer) const; + public: Unit _GetExtention(const BasicLayer* basicLayer) const; // public: virtual bool _IsInterceptedBy(View* view, const Point& point, const Unit& aperture) const; // public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation); diff --git a/hurricane/src/hurricane/Vertical.cpp b/hurricane/src/hurricane/Vertical.cpp index 88edb6f7..c458e090 100644 --- a/hurricane/src/hurricane/Vertical.cpp +++ b/hurricane/src/hurricane/Vertical.cpp @@ -67,7 +67,7 @@ Box Vertical::GetBoundingBox() const return Box(_x, GetSourceY(), _x, GetTargetY()).inflate(size, extention); } -Box Vertical::GetBoundingBox(BasicLayer* basicLayer) const +Box Vertical::GetBoundingBox(const BasicLayer* basicLayer) const // ******************************************************* { if (!GetLayer()->Contains(basicLayer)) return Box(); diff --git a/hurricane/src/hurricane/Vertical.h b/hurricane/src/hurricane/Vertical.h index 2bb7ce55..d74dd00a 100644 --- a/hurricane/src/hurricane/Vertical.h +++ b/hurricane/src/hurricane/Vertical.h @@ -47,7 +47,7 @@ class Vertical : public Segment { public: virtual Unit GetX() const {return _x;}; public: virtual Point GetCenter() const; public: virtual Box GetBoundingBox() const; - public: virtual Box GetBoundingBox(BasicLayer* basicLayer) const; + public: virtual Box GetBoundingBox(const BasicLayer* basicLayer) const; public: virtual Unit GetSourceX() const {return GetX();}; public: virtual Unit GetSourceY() const; public: virtual Unit GetTargetX() const {return GetX();}; diff --git a/hurricane/src/viewer/CellWidget.cpp b/hurricane/src/viewer/CellWidget.cpp index cc0321d3..afe4874d 100644 --- a/hurricane/src/viewer/CellWidget.cpp +++ b/hurricane/src/viewer/CellWidget.cpp @@ -6,7 +6,10 @@ #include "DataBase.h" #include "Technology.h" +#include "BasicLayer.h" +#include "Slice.h" #include "Box.h" +#include "Segment.h" using namespace H; #include "CellWidget.h" @@ -21,6 +24,23 @@ Technology* getTechnology() { return NULL; } +static QColor backgroundColor = QColor( 50, 50, 50 ); +static QColor foregroundColor = QColor( 255, 255, 255 ); +static QColor rubberColor = QColor( 192, 0, 192 ); +static QColor phantomColor = QColor( 139, 134, 130 ); +static QColor boundaryColor = QColor( 208*255, 199*255, 192*255 ); +static QColor markerColor = QColor( 80, 250, 80 ); +static QColor selectionDrawColor = QColor( 255, 255, 255 ); +static QColor selectionFillColor = QColor( 255, 255, 255 ); +static QColor gridColor = QColor( 255, 255, 255 ); +static QColor spotColor = QColor( 255, 255, 255 ); +static QColor ghostColor = QColor( 255, 255, 255 ); + +static QPen boundariesPen = QPen(boundaryColor); +static QBrush boundariesBrush = QBrush(boundaryColor); +static QPen phantomsPen = QPen(phantomColor); +static QBrush phantomsBrush = QBrush(phantomColor); + } CellWidget::CellWidget(Cell* c, QWidget* parent) @@ -28,11 +48,27 @@ CellWidget::CellWidget(Cell* c, QWidget* parent) cell(c), invalidRegion(), clipBox(), + clipX(), + clipY(), painter(NULL), + backgroundColor(20, 20, 20), + foregroundColor(255, 255, 255), scale(1), screenDx(0), - screenDy(0) { - painter = new QPainter(); + screenDy(0), + brushDx(0), + brushDy(0), + basicLayersBrush(), + basicLayersPen() { + for_each_basic_layer(basiclayer, getTechnology()->GetBasicLayers()) { + basicLayersBrush[basiclayer] = + QBrush(QColor(basiclayer->GetRedValue(), basiclayer->GetGreenValue(), basiclayer->GetBlueValue())); + basicLayersPen[basiclayer] = + QPen(QColor(basiclayer->GetRedValue(), basiclayer->GetGreenValue(), basiclayer->GetBlueValue())); + end_for; + } + + } void CellWidget::paintEvent(QPaintEvent* event) { @@ -53,29 +89,45 @@ void CellWidget::invalidate(const QRect& screenRect) { } } - - void CellWidget::redraw() { if (!invalidRegion.isEmpty()) { QRect invalidRect = invalidRegion.boundingRect(); H::Box area = getBox(invalidRect).inflate(getSize(1)); + setClipBox(area); + QPaintDevice* device = this; QPainter newPainter(device); QPainter* oldPainter = painter; painter = &newPainter; - painter->fillRect(QRectF(0, 0, 100, 100), QBrush(QColor(255, 255, 255))); + double brightness = 1.0; - painter->setPen(QPen(QColor(255, 255, 0))); - painter->setBrush(QBrush(QColor(255, 255, 0))); + //painter->save(); + //setBrush(phantomsBrush, brightness); + //drawPhantoms(cell, area, Transformation()); + //painter->restore(); - drawPhantoms(cell, area, Transformation()); + painter->save(); + setPen(boundariesPen, brightness); + setBrush(boundariesBrush, brightness); drawBoundaries(cell, area, Transformation()); - for_each_layer(layer, getTechnology()->GetLayers()) { - drawCell(cell, layer, area, Transformation()); + painter->restore(); + + for_each_basic_layer(basiclayer, getTechnology()->GetBasicLayers()) { + painter->save(); + map::const_iterator bmit = basicLayersBrush.find(basiclayer); + if (bmit != basicLayersBrush.end()) { + setBrush(bmit->second, brightness); + } + map::const_iterator pmit = basicLayersPen.find(basiclayer); + if (pmit != basicLayersPen.end()) { + setPen(pmit->second, brightness); + } + drawContent(cell, basiclayer, area, Transformation()); + painter->restore(); end_for; } @@ -83,9 +135,53 @@ void CellWidget::redraw() { } } -void CellWidget::drawCell(const Cell* cell, const Layer* layer, const H::Box& updateArea, const Transformation& transformation) const { +void CellWidget::drawContent(const Cell* cell, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const { + for_each_instance(instance, cell->GetInstancesUnder(updateArea)) { + drawContent(instance, basicLayer, updateArea, transformation); + end_for; + } + + for_each_slice(slice, cell->GetSlices()) { + drawSlice(slice, basicLayer, updateArea, transformation); + end_for; + } } + +void CellWidget::drawContent(const Instance* instance, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const { + Box masterArea = updateArea; + Transformation masterTransformation = instance->GetTransformation(); + instance->GetTransformation().getInvert().applyOn(masterArea); + transformation.applyOn(masterTransformation); + drawContent(instance->GetMasterCell(), basicLayer, masterArea, masterTransformation); +} + + +void CellWidget::drawSlice(const Slice* slice, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const { + if (slice->GetLayer()->Contains(basicLayer)) { + if (slice->GetBoundingBox().intersect(updateArea)) { + //if ((basicLayer == _layer->_GetSymbolicBasicLayer()) || (3 < view->GetScale())) + for_each_go(go, slice->GetGosUnder(updateArea)) { + drawGo(go, basicLayer, updateArea, transformation); + end_for; + } + } + } +} + +void CellWidget::drawGo(const Go* go, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const { + const Segment* segment = dynamic_cast(go); + if (segment) { + drawSegment(segment, basicLayer, updateArea, transformation); + } +} + + +void CellWidget::drawSegment(const Segment* segment, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const { + drawRectangle(transformation.getBox(segment->GetBoundingBox(basicLayer))); +} + + void CellWidget::drawPhantoms(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const { for_each_instance(instance, cell->GetInstancesUnder(updateArea)) { drawPhantoms(instance, updateArea, transformation); @@ -102,7 +198,7 @@ void CellWidget::drawPhantoms(const Instance* instance, const H::Box& updateArea } void CellWidget::drawBoundaries(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const { - drawRectangle(cell->GetAbutmentBox()); + drawRectangle(transformation.getBox(cell->GetAbutmentBox())); for_each_instance(instance, cell->GetInstances()) { drawBoundaries(instance, updateArea, transformation); end_for; @@ -161,3 +257,93 @@ int CellWidget::getScreenX(const Unit& x) const { int CellWidget::getScreenY(const Unit& y) const { return height() - (int)rint(screenDy + (GetValue(y) * scale)); } + + +void CellWidget::setClipBox(const Box& area) { + clipBox = Box(area).inflate(getSize(2)); + + clipX[0] = GetValue(clipBox.getXMin()); + clipX[1] = GetValue(clipBox.getXMax()); + clipX[2] = GetValue(clipBox.getXMin()); + clipX[3] = GetValue(clipBox.getXMax()); + clipY[0] = GetValue(clipBox.getYMin()); + clipY[1] = GetValue(clipBox.getYMin()); + clipY[2] = GetValue(clipBox.getYMax()); + clipY[3] = GetValue(clipBox.getYMax()); +} + + +void CellWidget::setFont(const QFont& font) { + if (painter) { + painter->setFont(font); + } +} + +void CellWidget::setPen(const QPen& pen, double brightness) { + if (!((0.1 <= brightness) && (brightness <= 1.0))) { + throw Error(__FILE__, __LINE__); + } + + if (painter) { + if (pen == Qt::NoPen) { + painter->setPen(pen); + } + else { + QPen correctedPen = pen; + + if (brightness < 1) { + QColor bgColor = getBackgroundColor(); + int r = bgColor.red(); + int g = bgColor.green(); + int b = bgColor.blue(); + + QColor color = pen.color(); + r = r + (int)((color.red() - r) * brightness); + g = g + (int)((color.green() - g) * brightness); + b = b + (int)((color.blue() - b) * brightness); + + correctedPen = QPen(QColor(r, g, b)); + } + + painter->setPen(correctedPen); + } + } +} + +void CellWidget::setBrush(const QBrush& brush, double brightness) { + if (!((0.1 <= brightness) && (brightness <= 1.0))) { + throw Error(__FILE__, __LINE__); + } + + if (painter) { + if (brush == Qt::NoBrush) { + painter->setBrush(brush); + } + else { + QBrush correctedBrush = brush; + + if (brightness < 1) { + QColor bgColor = getBackgroundColor(); + int r = bgColor.red(); + int g = bgColor.green(); + int b = bgColor.blue(); + + QColor color = brush.color(); + r = r + (int)((color.red() - r) * brightness); + g = g + (int)((color.green() - g) * brightness); + b = b + (int)((color.blue() - b) * brightness); + + correctedBrush = QBrush(QColor(r, g, b), brush.style()); + } + + painter->setBrush(correctedBrush); + } + } +} + +void CellWidget::setBrushOrigin(const QPoint& origin) { + if (painter) { + painter->setBrushOrigin(brushDx + origin.x(), brushDy + origin.y()); + } +} + diff --git a/hurricane/src/viewer/CellWidget.h b/hurricane/src/viewer/CellWidget.h index a54d80c1..3708a173 100644 --- a/hurricane/src/viewer/CellWidget.h +++ b/hurricane/src/viewer/CellWidget.h @@ -17,18 +17,30 @@ class CellWidget : public QWidget { private: Cell* cell; QRegion invalidRegion; - H::Box clipBox; + Box clipBox; + double clipX[4]; + double clipY[4]; QPainter* painter; + QColor backgroundColor; + QColor foregroundColor; double scale; int screenDx; int screenDy; + int brushDx; + int brushDy; + map basicLayersBrush; + map basicLayersPen; - void drawCell(const Cell* cell, const Layer* layer, const H::Box& updateArea, const Transformation& transformation) const; - void drawPhantoms(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const; - void drawPhantoms(const Instance* instance, const H::Box& updateArea, const Transformation& transformation) const; - void drawBoundaries(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const; - void drawBoundaries(const Instance* instance, const H::Box& updateArea, const Transformation& transformation) const; - void drawRectangle(const H::Box& box) const; + void drawContent(const Cell* cell, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const; + void drawContent(const Instance* instance, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const; + void drawSlice(const Slice* slice, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const; + void drawPhantoms(const Cell* cell, const Box& updateArea, const Transformation& transformation) const; + void drawPhantoms(const Instance* instance, const Box& updateArea, const Transformation& transformation) const; + void drawBoundaries(const Cell* cell, const Box& updateArea, const Transformation& transformation) const; + void drawBoundaries(const Instance* instance, const Box& updateArea, const Transformation& transformation) const; + void drawGo(const Go* go, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const; + void drawSegment(const Segment* segment, const BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation) const; + void drawRectangle(const Box& box) const; Unit getX(int screenX) const; Unit getY(int screenY) const; Unit getSize(int screenSize) const; @@ -37,7 +49,20 @@ class CellWidget : public QWidget { int getScreenY(const Unit& y) const; void invalidate(); void invalidate(const QRect& screenRect); + void setClipBox(const Box& area); + void setFont(const QFont& font); + void setPen(const QPen& pen, double brightness = 1.0); + void setBrush(const QBrush& brush, double brightness = 1.0); + void setBrushOrigin(const QPoint& origin); + + const QColor& getBackgroundColor() const; }; + +inline const QColor& CellWidget::getBackgroundColor() const { + return backgroundColor; +} + + #endif /* __CELL_WIDGET_H */