MAJ
This commit is contained in:
parent
9322a046f0
commit
7134556b5e
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QPen>
|
||||
|
||||
#include "DataBase.h"
|
||||
#include "Technology.h"
|
||||
|
@ -20,35 +21,128 @@ Technology* getTechnology() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CellWidget::CellWidget(Cell* c, QWidget* parent)
|
||||
: QAbstractScrollArea(parent),
|
||||
cell(c) {
|
||||
cell(c),
|
||||
invalidRegion(),
|
||||
clipBox(),
|
||||
painter(NULL),
|
||||
scale(1),
|
||||
screenDx(0),
|
||||
screenDy(0) {
|
||||
painter = new QPainter();
|
||||
}
|
||||
|
||||
void CellWidget::paintEvent(QPaintEvent* event) {
|
||||
//invalidate(event->rect());
|
||||
redraw();
|
||||
invalidate(event->rect());
|
||||
|
||||
if (!invalidRegion.isEmpty()) {
|
||||
QRect invalidRect = invalidRegion.boundingRect();
|
||||
|
||||
H::Box area = getBox(invalidRect).inflate(getSize(1));
|
||||
cerr << "akecoucou3" << endl;
|
||||
|
||||
//QPaintDevice* device = this;
|
||||
|
||||
//QPainter newPainter(device);
|
||||
//QPainter* oldPainter = painter;
|
||||
//painter = &newPainter;
|
||||
|
||||
painter->setPen(QPen(QColor(255, 255, 255)));
|
||||
painter->fillRect(QRectF(0, 0, 100, 100), QBrush(QColor(255, 255, 255)));
|
||||
|
||||
|
||||
drawPhantoms(cell, area, Transformation());
|
||||
drawBoundaries(cell, area, Transformation());
|
||||
for_each_layer(layer, getTechnology()->GetLayers()) {
|
||||
drawCell(cell, layer, area, Transformation());
|
||||
end_for;
|
||||
}
|
||||
|
||||
invalidRegion = QRegion();
|
||||
}
|
||||
}
|
||||
|
||||
void CellWidget::invalidate() {
|
||||
invalidRegion = QRegion(rect());
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::invalidate(const QRect& screenRect) {
|
||||
QRect visibleScreenRect = screenRect.intersect(rect());
|
||||
|
||||
if (!visibleScreenRect.isEmpty()) {
|
||||
invalidRegion = invalidRegion.unite(QRegion(visibleScreenRect));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CellWidget::redraw() {
|
||||
drawPhantoms(cell);
|
||||
drawBoundaries(cell);
|
||||
for_each_layer(layer, getTechnology()->GetLayers()) {
|
||||
drawCell(cell, layer);
|
||||
if (!invalidRegion.isEmpty()) {
|
||||
QRect invalidRect = invalidRegion.boundingRect();
|
||||
|
||||
H::Box area = getBox(invalidRect).inflate(getSize(1));
|
||||
cerr << "akecoucou2" << endl;
|
||||
|
||||
QPaintDevice* device = this;
|
||||
|
||||
QPainter newPainter(device);
|
||||
QPainter* oldPainter = painter;
|
||||
painter = &newPainter;
|
||||
|
||||
//painter->fillRect(QRectF(0, 0, 100, 100), QBrush(QColor(255, 255, 255)));
|
||||
|
||||
//painter->setPen(QPen(QColor(255, 255, 255)));
|
||||
|
||||
//drawPhantoms(cell, area, Transformation());
|
||||
//drawBoundaries(cell, area, Transformation());
|
||||
//for_each_layer(layer, getTechnology()->GetLayers()) {
|
||||
// drawCell(cell, layer, area, Transformation());
|
||||
// end_for;
|
||||
//}
|
||||
|
||||
invalidRegion = QRegion();
|
||||
}
|
||||
}
|
||||
|
||||
void CellWidget::drawCell(const Cell* cell, const Layer* layer, 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)) {
|
||||
drawPhantoms(instance, updateArea, transformation);
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
|
||||
void CellWidget::drawCell(const Cell* cell, const Layer* layer) const {
|
||||
void CellWidget::drawPhantoms(const Instance* instance, const H::Box& updateArea, const Transformation& transformation) const {
|
||||
H::Box masterArea = updateArea;
|
||||
Transformation masterTransformation = instance->GetTransformation();
|
||||
instance->GetTransformation().GetInvert().ApplyOn(masterArea);
|
||||
transformation.ApplyOn(masterTransformation);
|
||||
drawPhantoms(instance->GetMasterCell(), masterArea, masterTransformation);
|
||||
}
|
||||
|
||||
void CellWidget::drawPhantoms(const Cell* cell) const {
|
||||
void CellWidget::drawBoundaries(const Cell* cell, const H::Box& updateArea, const Transformation& transformation) const {
|
||||
drawRectangle(cell->GetAbutmentBox());
|
||||
for_each_instance(instance, cell->GetInstances()) {
|
||||
drawBoundaries(instance, updateArea, transformation);
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
|
||||
void CellWidget::drawBoundaries(const Cell* cell) const {
|
||||
void CellWidget::drawBoundaries(const Instance* instance, const H::Box& updateArea, const Transformation& transformation) const {
|
||||
H::Box masterArea = updateArea;
|
||||
Transformation masterTransformation = instance->GetTransformation();
|
||||
instance->GetTransformation().GetInvert().ApplyOn(masterArea);
|
||||
transformation.ApplyOn(masterTransformation);
|
||||
drawBoundaries(instance->GetMasterCell(), masterArea, masterTransformation);
|
||||
}
|
||||
|
||||
void CellWidget::drawRectangle(const H::Box& box) {
|
||||
void CellWidget::drawRectangle(const H::Box& box) const {
|
||||
if (painter) {
|
||||
H::Box ibox = box.getIntersection(clipBox);
|
||||
if (!ibox.isEmpty()) {
|
||||
|
@ -62,6 +156,29 @@ void CellWidget::drawRectangle(const H::Box& box) {
|
|||
}
|
||||
}
|
||||
|
||||
Unit CellWidget::getX(int screenX) const {
|
||||
return GetUnit((screenX - screenDx) / scale);
|
||||
}
|
||||
|
||||
Unit CellWidget::getY(int screenY) const {
|
||||
return GetUnit(((height() - screenY) - screenDy) / scale);
|
||||
}
|
||||
|
||||
Unit CellWidget::getSize(int screenSize) const {
|
||||
return GetUnit(screenSize / scale);
|
||||
}
|
||||
|
||||
H::Box CellWidget::getBox(const QRect& screenRect) const {
|
||||
if (screenRect.isEmpty()) {
|
||||
return H::Box();
|
||||
}
|
||||
|
||||
return H::Box(getX(screenRect.left()),
|
||||
getY(screenRect.bottom()),
|
||||
getX(screenRect.right()),
|
||||
getY(screenRect.top()));
|
||||
}
|
||||
|
||||
int CellWidget::getScreenX(const Unit& x) const {
|
||||
return screenDx + (int)rint(GetValue(x) * scale);
|
||||
}
|
||||
|
@ -69,5 +186,3 @@ int CellWidget::getScreenX(const Unit& x) const {
|
|||
int CellWidget::getScreenY(const Unit& y) const {
|
||||
return height() - (int)rint(screenDy + (GetValue(y) * scale));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,18 +16,27 @@ class CellWidget : public QAbstractScrollArea {
|
|||
void paintEvent(QPaintEvent* event);
|
||||
private:
|
||||
Cell* cell;
|
||||
QPainter* painter;
|
||||
QRegion invalidRegion;
|
||||
H::Box clipBox;
|
||||
QPainter* painter;
|
||||
double scale;
|
||||
int screenDx;
|
||||
int screenDy;
|
||||
|
||||
void drawCell(const Cell* cell, const Layer* layer) const;
|
||||
void drawPhantoms(const Cell* cell) const;
|
||||
void drawBoundaries(const Cell* cell) const;
|
||||
void drawRectangle(const H::Box& box);
|
||||
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;
|
||||
Unit getX(int screenX) const;
|
||||
Unit getY(int screenY) const;
|
||||
Unit getSize(int screenSize) const;
|
||||
H::Box getBox(const QRect& screenRect) const;
|
||||
int getScreenX(const Unit& x) const;
|
||||
int getScreenY(const Unit& y) const;
|
||||
void invalidate();
|
||||
void invalidate(const QRect& screenRect);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue