graphical view in progress

This commit is contained in:
Christophe Alexandre 2008-01-07 16:19:17 +00:00
parent 611d368c9c
commit 783ed6dc36
21 changed files with 265 additions and 54 deletions

View File

@ -78,7 +78,7 @@ class Component : public Go {
public: virtual Point GetCenter() const {return GetPosition();}; public: virtual Point GetCenter() const {return GetPosition();};
public: virtual Layer* GetLayer() const = 0; public: virtual Layer* GetLayer() const = 0;
public: virtual Box GetBoundingBox() 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 GetConnexComponents() const;
public: Components GetSlaveComponents() const; public: Components GetSlaveComponents() const;

View File

@ -51,28 +51,28 @@ BasicLayers CompositeLayer::GetBasicLayers() const
return GetCollection(_basicLayerList); return GetCollection(_basicLayerList);
} }
Unit CompositeLayer::GetContactSize(BasicLayer* basicLayer) const Unit CompositeLayer::GetContactSize(const BasicLayer* basicLayer) const
// ************************************************************** // **************************************************************
{ {
SizeMap::const_iterator it = _contactSizeMap.find(basicLayer); SizeMap::const_iterator it = _contactSizeMap.find(basicLayer);
return ((it == _contactSizeMap.end()) ? 0 : (*it).second); 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); SizeMap::const_iterator it = _segmentSizeMap.find(basicLayer);
return ((it == _segmentSizeMap.end()) ? 0 : (*it).second); 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); SizeMap::const_iterator it = _segmentExtentionMap.find(basicLayer);
return ((it == _segmentExtentionMap.end()) ? 0 : (*it).second); 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); SizeMap::const_iterator it = _padSizeMap.find(basicLayer);

View File

@ -50,7 +50,7 @@ class CompositeLayer : public Layer {
public: typedef list<BasicLayer*> BasicLayerList; public: typedef list<BasicLayer*> BasicLayerList;
public: typedef map<BasicLayer*, Unit> SizeMap; public: typedef map<const BasicLayer*, Unit> SizeMap;
// Attributes // Attributes
// ********** // **********
@ -79,10 +79,10 @@ class CompositeLayer : public Layer {
public: const Type& GetType() const {return _type;}; public: const Type& GetType() const {return _type;};
public: virtual BasicLayers GetBasicLayers() const; public: virtual BasicLayers GetBasicLayers() const;
public: Unit GetContactSize(BasicLayer* basicLayer) const; public: Unit GetContactSize(const BasicLayer* basicLayer) const;
public: Unit GetSegmentSize(BasicLayer* basicLayer) const; public: Unit GetSegmentSize(const BasicLayer* basicLayer) const;
public: Unit GetSegmentExtention(BasicLayer* basicLayer) const; public: Unit GetSegmentExtention(const BasicLayer* basicLayer) const;
public: Unit GetPadSize(BasicLayer* basicLayer) const; public: Unit GetPadSize(const BasicLayer* basicLayer) const;
public: const Unit& GetMaximalContactSize() const {return _maximalContactSize;}; public: const Unit& GetMaximalContactSize() const {return _maximalContactSize;};
public: const Unit& GetMaximalSegmentSize() const {return _maximalSegmentSize;}; public: const Unit& GetMaximalSegmentSize() const {return _maximalSegmentSize;};
public: const Unit& GetMaximalSegmentExtention() const {return _maximalSegmentExtention;}; public: const Unit& GetMaximalSegmentExtention() const {return _maximalSegmentExtention;};

View File

@ -183,7 +183,7 @@ Box Contact::GetBoundingBox() const
return Box(GetPosition()).inflate(GetHalfWidth() + size, GetHalfHeight() + size); 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(); if (!_layer->Contains(basicLayer)) return Box();
@ -354,8 +354,8 @@ Unit Contact::_GetSize() const
return size; return size;
} }
Unit Contact::_GetSize(BasicLayer* basicLayer) const Unit Contact::_GetSize(const BasicLayer* basicLayer) const
// ************************************************* // *******************************************************
{ {
Layer* layer = GetLayer(); Layer* layer = GetLayer();

View File

@ -71,7 +71,7 @@ class Contact : public Component {
public: virtual Point GetPosition() const; public: virtual Point GetPosition() const;
public: virtual Box GetBoundingBox() const; public: virtual Box GetBoundingBox() const;
public: virtual Layer* GetLayer() const {return _layer;}; 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: Hook* GetAnchorHook() {return &_anchorHook;};
public: Component* GetAnchor() const; public: Component* GetAnchor() const;
public: const Unit& GetDx() const {return _dx;}; public: const Unit& GetDx() const {return _dx;};
@ -108,7 +108,7 @@ class Contact : public Component {
public: virtual Record* _GetRecord() const; public: virtual Record* _GetRecord() const;
public: Unit _GetSize() 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 _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation);
//public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation); //public: virtual void _Highlight(View* view, const Box& updateArea, const Transformation& transformation);

View File

@ -67,7 +67,7 @@ Box Horizontal::GetBoundingBox() const
return Box(GetSourceX(), _y, GetTargetX(), _y).inflate(extention, size); 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(); if (!GetLayer()->Contains(basicLayer)) return Box();

View File

@ -47,7 +47,7 @@ class Horizontal : public Segment {
public: virtual Unit GetY() const {return _y;}; public: virtual Unit GetY() const {return _y;};
public: virtual Point GetCenter() const; public: virtual Point GetCenter() const;
public: virtual Box GetBoundingBox() 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 GetSourceX() const;
public: virtual Unit GetSourceY() const {return GetY();}; public: virtual Unit GetSourceY() const {return GetY();};
public: virtual Unit GetTargetX() const; public: virtual Unit GetTargetX() const;

View File

@ -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"); 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())); 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); return ((_mask & layer->GetMask()) != 0);
} }

View File

@ -64,8 +64,8 @@ class Layer : public DBo {
// Predicates // Predicates
// ********** // **********
public: bool Contains(Layer* layer) const; public: bool Contains(const Layer* layer) const;
public: bool Intersect(Layer* layer) const; public: bool Intersect(const Layer* layer) const;
// Updators // Updators
// ******** // ********

View File

@ -65,7 +65,7 @@ Box Pad::GetBoundingBox() const
return boundingBox; return boundingBox;
} }
Box Pad::GetBoundingBox(BasicLayer* basicLayer) const Box Pad::GetBoundingBox(const BasicLayer* basicLayer) const
// ************************************************** // **************************************************
{ {
if (!_layer->Contains(basicLayer)) return Box(); if (!_layer->Contains(basicLayer)) return Box();

View File

@ -48,7 +48,7 @@ class Pad : public Component {
public: virtual Unit GetX() const; public: virtual Unit GetX() const;
public: virtual Unit GetY() const; public: virtual Unit GetY() const;
public: virtual Box GetBoundingBox() 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;}; public: virtual Layer* GetLayer() const {return _layer;};
// Updators // Updators

View File

@ -100,7 +100,7 @@ Box Plug::GetBoundingBox() const
return _instance->GetTransformation().getBox(_masterNet->GetPosition()); return _instance->GetTransformation().getBox(_masterNet->GetPosition());
} }
Box Plug::GetBoundingBox(BasicLayer* basicLayer) const Box Plug::GetBoundingBox(const BasicLayer* basicLayer) const
// *************************************************** // ***************************************************
{ {
return Box(); return Box();

View File

@ -55,7 +55,7 @@ class Plug : public Component {
public: virtual Point GetPosition() const; public: virtual Point GetPosition() const;
public: virtual Box GetBoundingBox() const; public: virtual Box GetBoundingBox() const;
public: virtual Layer* GetLayer() const {return NULL;}; 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: Instance* GetInstance() const {return _instance;};
public: Net* GetMasterNet() const {return _masterNet;}; public: Net* GetMasterNet() const {return _masterNet;};

View File

@ -101,7 +101,7 @@ Box RoutingPad::GetBoundingBox() const
return Box(GetPosition()); return Box(GetPosition());
} }
Box RoutingPad::GetBoundingBox(BasicLayer* basicLayer) const Box RoutingPad::GetBoundingBox(const BasicLayer* basicLayer) const
// ****************************************************** // ******************************************************
{ {
Component* component = _GetEntityAsComponent(); Component* component = _GetEntityAsComponent();

View File

@ -57,7 +57,7 @@ class RoutingPad : public Component {
public: virtual Unit GetY() const; public: virtual Unit GetY() const;
public: virtual Box GetBoundingBox() const; public: virtual Box GetBoundingBox() const;
public: virtual Layer* GetLayer() 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: virtual Point GetCenter() const;
public: Occurrence GetOccurrence() const { return _occurrence; }; public: Occurrence GetOccurrence() const { return _occurrence; };
public: Occurrence GetPlugOccurrence(); public: Occurrence GetPlugOccurrence();

View File

@ -340,7 +340,7 @@ Unit Segment::_GetExtention() const
return extention; return extention;
} }
Unit Segment::_GetSize(BasicLayer* basicLayer) const Unit Segment::_GetSize(const BasicLayer* basicLayer) const
// ************************************************* // *************************************************
{ {
Layer* layer = GetLayer(); Layer* layer = GetLayer();
@ -355,7 +355,7 @@ Unit Segment::_GetSize(BasicLayer* basicLayer) const
return size; return size;
} }
Unit Segment::_GetExtention(BasicLayer* basicLayer) const Unit Segment::_GetExtention(const BasicLayer* basicLayer) const
// ****************************************************** // ******************************************************
{ {
Layer* layer = GetLayer(); Layer* layer = GetLayer();

View File

@ -114,8 +114,8 @@ class Segment : public Component {
public: Unit _GetSize() const; public: Unit _GetSize() const;
public: Unit _GetExtention() const; public: Unit _GetExtention() const;
public: Unit _GetSize(BasicLayer* basicLayer) const; public: Unit _GetSize(const BasicLayer* basicLayer) const;
public: Unit _GetExtention(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 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); // public: virtual void _Draw(View* view, BasicLayer* basicLayer, const Box& updateArea, const Transformation& transformation);

View File

@ -67,7 +67,7 @@ Box Vertical::GetBoundingBox() const
return Box(_x, GetSourceY(), _x, GetTargetY()).inflate(size, extention); 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(); if (!GetLayer()->Contains(basicLayer)) return Box();

View File

@ -47,7 +47,7 @@ class Vertical : public Segment {
public: virtual Unit GetX() const {return _x;}; public: virtual Unit GetX() const {return _x;};
public: virtual Point GetCenter() const; public: virtual Point GetCenter() const;
public: virtual Box GetBoundingBox() 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 GetSourceX() const {return GetX();};
public: virtual Unit GetSourceY() const; public: virtual Unit GetSourceY() const;
public: virtual Unit GetTargetX() const {return GetX();}; public: virtual Unit GetTargetX() const {return GetX();};

View File

@ -6,7 +6,10 @@
#include "DataBase.h" #include "DataBase.h"
#include "Technology.h" #include "Technology.h"
#include "BasicLayer.h"
#include "Slice.h"
#include "Box.h" #include "Box.h"
#include "Segment.h"
using namespace H; using namespace H;
#include "CellWidget.h" #include "CellWidget.h"
@ -21,6 +24,23 @@ Technology* getTechnology() {
return NULL; 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) CellWidget::CellWidget(Cell* c, QWidget* parent)
@ -28,11 +48,27 @@ CellWidget::CellWidget(Cell* c, QWidget* parent)
cell(c), cell(c),
invalidRegion(), invalidRegion(),
clipBox(), clipBox(),
clipX(),
clipY(),
painter(NULL), painter(NULL),
backgroundColor(20, 20, 20),
foregroundColor(255, 255, 255),
scale(1), scale(1),
screenDx(0), screenDx(0),
screenDy(0) { screenDy(0),
painter = new QPainter(); 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) { void CellWidget::paintEvent(QPaintEvent* event) {
@ -53,29 +89,45 @@ void CellWidget::invalidate(const QRect& screenRect) {
} }
} }
void CellWidget::redraw() { void CellWidget::redraw() {
if (!invalidRegion.isEmpty()) { if (!invalidRegion.isEmpty()) {
QRect invalidRect = invalidRegion.boundingRect(); QRect invalidRect = invalidRegion.boundingRect();
H::Box area = getBox(invalidRect).inflate(getSize(1)); H::Box area = getBox(invalidRect).inflate(getSize(1));
setClipBox(area);
QPaintDevice* device = this; QPaintDevice* device = this;
QPainter newPainter(device); QPainter newPainter(device);
QPainter* oldPainter = painter; QPainter* oldPainter = painter;
painter = &newPainter; 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->save();
painter->setBrush(QBrush(QColor(255, 255, 0))); //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()); drawBoundaries(cell, area, Transformation());
for_each_layer(layer, getTechnology()->GetLayers()) { painter->restore();
drawCell(cell, layer, area, Transformation());
for_each_basic_layer(basiclayer, getTechnology()->GetBasicLayers()) {
painter->save();
map<BasicLayer*, QBrush>::const_iterator bmit = basicLayersBrush.find(basiclayer);
if (bmit != basicLayersBrush.end()) {
setBrush(bmit->second, brightness);
}
map<BasicLayer*, QPen>::const_iterator pmit = basicLayersPen.find(basiclayer);
if (pmit != basicLayersPen.end()) {
setPen(pmit->second, brightness);
}
drawContent(cell, basiclayer, area, Transformation());
painter->restore();
end_for; 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<const Segment*>(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 { void CellWidget::drawPhantoms(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const {
for_each_instance(instance, cell->GetInstancesUnder(updateArea)) { for_each_instance(instance, cell->GetInstancesUnder(updateArea)) {
drawPhantoms(instance, updateArea, transformation); 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 { 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()) { for_each_instance(instance, cell->GetInstances()) {
drawBoundaries(instance, updateArea, transformation); drawBoundaries(instance, updateArea, transformation);
end_for; end_for;
@ -161,3 +257,93 @@ int CellWidget::getScreenX(const Unit& x) const {
int CellWidget::getScreenY(const Unit& y) const { int CellWidget::getScreenY(const Unit& y) const {
return height() - (int)rint(screenDy + (GetValue(y) * scale)); 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());
}
}

View File

@ -17,18 +17,30 @@ class CellWidget : public QWidget {
private: private:
Cell* cell; Cell* cell;
QRegion invalidRegion; QRegion invalidRegion;
H::Box clipBox; Box clipBox;
double clipX[4];
double clipY[4];
QPainter* painter; QPainter* painter;
QColor backgroundColor;
QColor foregroundColor;
double scale; double scale;
int screenDx; int screenDx;
int screenDy; int screenDy;
int brushDx;
int brushDy;
map<BasicLayer*, QBrush> basicLayersBrush;
map<BasicLayer*, QPen> basicLayersPen;
void drawCell(const Cell* cell, const Layer* layer, const H::Box& updateArea, const Transformation& transformation) const; void drawContent(const Cell* cell, const BasicLayer* basicLayer, const H::Box& updateArea, const Transformation& transformation) const;
void drawPhantoms(const Cell* cell, 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 drawPhantoms(const Instance* instance, 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 drawBoundaries(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const; void drawPhantoms(const Cell* cell, const Box& updateArea, const Transformation& transformation) const;
void drawBoundaries(const Instance* instance, const H::Box& updateArea, const Transformation& transformation) const; void drawPhantoms(const Instance* instance, const Box& updateArea, const Transformation& transformation) const;
void drawRectangle(const H::Box& box) 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 getX(int screenX) const;
Unit getY(int screenY) const; Unit getY(int screenY) const;
Unit getSize(int screenSize) const; Unit getSize(int screenSize) const;
@ -37,7 +49,20 @@ class CellWidget : public QWidget {
int getScreenY(const Unit& y) const; int getScreenY(const Unit& y) const;
void invalidate(); void invalidate();
void invalidate(const QRect& screenRect); 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 */ #endif /* __CELL_WIDGET_H */