save for the moment
This commit is contained in:
parent
dfa8415862
commit
984e791437
|
@ -2,11 +2,12 @@ include(${QT_USE_FILE})
|
||||||
|
|
||||||
include_directories(${HURRICANE_SOURCE_DIR}/hurricane)
|
include_directories(${HURRICANE_SOURCE_DIR}/hurricane)
|
||||||
|
|
||||||
set(includes CellFigure.h InstanceFigure.h SliceFigure.h GoFigure.h SegmentFigure.h)
|
set(includes InstanceFigure.h Utils.h)
|
||||||
set(cpps CellFigure.cpp InstanceFigure.cpp SliceFigure.cpp GoFigure.cpp SegmentFigure.cpp)
|
set(cpps InstanceFigure.cpp CellScene.cpp)
|
||||||
|
|
||||||
add_library(hurricanefigs SHARED ${cpps})
|
add_library(hurricanefigs SHARED ${cpps})
|
||||||
target_link_libraries(hurricanefigs ${QT_LIBRARIES} hurricane)
|
target_link_libraries(hurricanefigs ${QT_LIBRARIES} hurricane)
|
||||||
|
|
||||||
install(FILES ${includes} DESTINATION /include/hurricane)
|
install(FILES ${includes} DESTINATION /include/hurricane)
|
||||||
install(TARGETS hurricanefigs DESTINATION /lib)
|
install(TARGETS hurricanefigs DESTINATION /lib)
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,10 @@ CellFigure::CellFigure(Cell* c):
|
||||||
new InstanceFigure(this, instance);
|
new InstanceFigure(this, instance);
|
||||||
end_for;
|
end_for;
|
||||||
}
|
}
|
||||||
for_each_slice(slice, cell->GetSlices()) {
|
//for_each_slice(slice, cell->GetSlices()) {
|
||||||
new SliceFigure(this, slice);
|
// new SliceFigure(this, slice);
|
||||||
end_for;
|
// end_for;
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
CellFigure::CellFigure(InstanceFigure* master, Cell* c) : QGraphicsItem(master), cell(c) {
|
CellFigure::CellFigure(InstanceFigure* master, Cell* c) : QGraphicsItem(master), cell(c) {
|
||||||
|
@ -54,12 +54,12 @@ void CellFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem* option
|
||||||
// pen.setColor(Qt::red);
|
// pen.setColor(Qt::red);
|
||||||
// painter->setPen(pen);
|
// painter->setPen(pen);
|
||||||
|
|
||||||
painter->setClipRect(option->exposedRect);
|
//painter->setClipRect(option->exposedRect);
|
||||||
if (option->levelOfDetail > 1.0) {
|
//if (option->levelOfDetail > 1.0) {
|
||||||
drawBoundary(painter);
|
// drawBoundary(painter);
|
||||||
} else {
|
//} else {
|
||||||
drawPhantom(painter);
|
// drawPhantom(painter);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellFigure::drawBoundary(QPainter* painter) {
|
void CellFigure::drawBoundary(QPainter* painter) {
|
||||||
|
@ -78,4 +78,3 @@ void CellFigure::drawPhantom(QPainter* painter) {
|
||||||
BoxToRectangle(box, rect);
|
BoxToRectangle(box, rect);
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
#include "CellScene.h"
|
||||||
|
|
||||||
|
|
||||||
|
void CellScene::drawItems(QPainter *painter,
|
||||||
|
int numItems,
|
||||||
|
QGraphicsItem *items[],
|
||||||
|
const QStyleOptionGraphicsItem options[],
|
||||||
|
QWidget *widget) {
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef __CELL_SCENE_H
|
||||||
|
#define __CELL_SCENE_H
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
|
||||||
|
class CellScene : public QGraphicsScene {
|
||||||
|
protected :
|
||||||
|
void drawItems(QPainter *painter,
|
||||||
|
int numItems,
|
||||||
|
QGraphicsItem *items[],
|
||||||
|
const QStyleOptionGraphicsItem options[],
|
||||||
|
QWidget *widget);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* __CELL_SCENE_H */
|
|
@ -1,30 +1,112 @@
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTransform>
|
#include <QTransform>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
#include "Cell.h"
|
||||||
|
#include "Slice.h"
|
||||||
|
#include "Segment.h"
|
||||||
|
#include "BasicLayer.h"
|
||||||
|
using namespace H;
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "InstanceFigure.h"
|
#include "InstanceFigure.h"
|
||||||
|
|
||||||
InstanceFigure::InstanceFigure(CellFigure* parent, Instance* inst):
|
//InstanceFigure::InstanceFigure(Instance* inst)
|
||||||
QGraphicsItem(parent),
|
// : instance(inst),
|
||||||
instance(inst) {
|
// cell(instance->GetMasterCell())
|
||||||
Cell* masterCell = inst->GetMasterCell();
|
//{
|
||||||
|
// Transformation transformation = instance->GetTransformation();
|
||||||
|
// QTransform transform;
|
||||||
|
// QPoint pos;
|
||||||
|
// HurricanePositionToQtPosition(transformation, transform, pos);
|
||||||
|
// setTransform(transform);
|
||||||
|
// setPos(pos);
|
||||||
|
// constructSubInstances();
|
||||||
|
//}
|
||||||
|
|
||||||
|
InstanceFigure::InstanceFigure(Cell* c)
|
||||||
|
: instance(NULL),
|
||||||
|
cell(c)
|
||||||
|
{
|
||||||
|
constructSubInstances();
|
||||||
|
}
|
||||||
|
|
||||||
|
InstanceFigure::InstanceFigure(InstanceFigure* parent, Instance* inst)
|
||||||
|
: QGraphicsItem(parent),
|
||||||
|
instance(inst),
|
||||||
|
cell(instance->GetMasterCell())
|
||||||
|
{
|
||||||
Transformation transformation = instance->GetTransformation();
|
Transformation transformation = instance->GetTransformation();
|
||||||
QTransform transform;
|
QTransform transform;
|
||||||
QPoint pos;
|
QPoint pos;
|
||||||
HurricanePositionToQtPosition(transformation, transform, pos);
|
HurricanePositionToQtPosition(transformation, transform, pos);
|
||||||
setTransform(transform);
|
setTransform(transform);
|
||||||
setPos(pos);
|
setPos(pos);
|
||||||
new CellFigure(this, masterCell);
|
constructSubInstances();
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceFigure::constructSubInstances() {
|
||||||
|
for_each_instance(instance, cell->GetInstances()) {
|
||||||
|
new InstanceFigure(this, instance);
|
||||||
|
end_for;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF InstanceFigure::boundingRect() const {
|
QRectF InstanceFigure::boundingRect() const {
|
||||||
Cell* masterCell = instance->GetMasterCell();
|
Box box = cell->GetAbutmentBox();
|
||||||
Box box = masterCell->GetAbutmentBox();
|
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
BoxToRectangle(box, rect);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void InstanceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
{}
|
painter->setClipRect(option->exposedRect.adjusted(-1.0, -1.0, 1.0, 1.0));
|
||||||
|
if (option->levelOfDetail > 1.0) {
|
||||||
|
drawBoundary(painter);
|
||||||
|
drawElements(painter);
|
||||||
|
} else {
|
||||||
|
drawPhantom(painter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceFigure::drawElements(QPainter* painter) {
|
||||||
|
for_each_slice(slice, cell->GetSlices()) {
|
||||||
|
painter->save();
|
||||||
|
BasicLayer* layer = dynamic_cast<BasicLayer*>(slice->GetLayer());
|
||||||
|
if (layer) {
|
||||||
|
painter->setBrush(QColor(layer->GetRedValue(), layer->GetGreenValue(), layer->GetBlueValue()));
|
||||||
|
} else {
|
||||||
|
painter->setBrush(Qt::blue);
|
||||||
|
}
|
||||||
|
for_each_go(go, slice->GetGos()) {
|
||||||
|
Segment* segment = dynamic_cast<Segment*>(go);
|
||||||
|
if (segment) {
|
||||||
|
Box box = segment->GetBoundingBox();
|
||||||
|
QRectF rect;
|
||||||
|
BoxToRectangle(box, rect);
|
||||||
|
painter->drawRect(rect);
|
||||||
|
|
||||||
|
}
|
||||||
|
end_for;
|
||||||
|
}
|
||||||
|
painter->restore();
|
||||||
|
end_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceFigure::drawBoundary(QPainter* painter) {
|
||||||
|
QPen pen(Qt::black);
|
||||||
|
painter->setPen(pen);
|
||||||
|
Box box = cell->GetAbutmentBox();
|
||||||
|
QRectF rect;
|
||||||
|
BoxToRectangle(box, rect);
|
||||||
|
painter->drawRect(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InstanceFigure::drawPhantom(QPainter* painter) {
|
||||||
|
painter->setBrush(Qt::red);
|
||||||
|
Box box = cell->GetAbutmentBox();
|
||||||
|
QRectF rect;
|
||||||
|
BoxToRectangle(box, rect);
|
||||||
|
painter->drawRect(rect);
|
||||||
|
}
|
||||||
|
|
|
@ -4,20 +4,26 @@
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "CellFigure.h"
|
|
||||||
|
|
||||||
#include "Instance.h"
|
#include "Instance.h"
|
||||||
|
#include "Cell.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class InstanceFigure : public QGraphicsItem {
|
class InstanceFigure : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
InstanceFigure(CellFigure* parent, Instance* instance);
|
InstanceFigure(InstanceFigure* parent, Instance* instance);
|
||||||
|
//InstanceFigure(Instance* instance);
|
||||||
|
InstanceFigure(Cell* cell);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Instance* instance;
|
Instance* instance;
|
||||||
|
Cell* cell;
|
||||||
|
void drawPhantom(QPainter* painter);
|
||||||
|
void drawBoundary(QPainter* painter);
|
||||||
|
void drawElements(QPainter* painter);
|
||||||
|
void constructSubInstances();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -7,15 +7,25 @@
|
||||||
using namespace H;
|
using namespace H;
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "SliceFigure.h"
|
||||||
#include "SegmentFigure.h"
|
#include "SegmentFigure.h"
|
||||||
|
|
||||||
SegmentFigure::SegmentFigure(SliceFigure* master, Segment* s):
|
SegmentFigure::SegmentFigure(SliceFigure* master, Segment* s):
|
||||||
GoFigure(master),
|
QGraphicsItem(master),
|
||||||
segment(s)
|
segment(s)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
QRectF SegmentFigure::boundingRect() const {
|
||||||
|
Box box = getGo()->GetBoundingBox();
|
||||||
|
QRectF rect;
|
||||||
|
BoxToRectangle(box, rect);
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
void SegmentFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void SegmentFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
if (option->levelOfDetail < 1.0) {
|
Q_UNUSED(widget);
|
||||||
|
|
||||||
|
if (option->levelOfDetail > 1.0) {
|
||||||
painter->setClipRect(option->exposedRect);
|
painter->setClipRect(option->exposedRect);
|
||||||
BasicLayer* layer = dynamic_cast<BasicLayer*>(segment->GetLayer());
|
BasicLayer* layer = dynamic_cast<BasicLayer*>(segment->GetLayer());
|
||||||
if (layer) {
|
if (layer) {
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "GoFigure.h"
|
|
||||||
|
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class SegmentFigure : public GoFigure {
|
class SliceFigure;
|
||||||
|
|
||||||
|
class SegmentFigure : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
SegmentFigure(SliceFigure* parent, Segment* segment);
|
SegmentFigure(SliceFigure* parent, Segment* segment);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
|
QRectF boundingRect() const;
|
||||||
private:
|
private:
|
||||||
Segment* segment;
|
Segment* segment;
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -21,25 +21,25 @@ QRectF SliceFigure::boundingRect() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void SliceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
if (option->levelOfDetail > 1.0) {
|
// if (option->levelOfDetail > 1.0) {
|
||||||
// painter->setClipRect(option->exposedRect);
|
//// painter->setClipRect(option->exposedRect);
|
||||||
BasicLayer* layer = dynamic_cast<BasicLayer*>(slice->GetLayer());
|
// BasicLayer* layer = dynamic_cast<BasicLayer*>(slice->GetLayer());
|
||||||
if (layer) {
|
// if (layer) {
|
||||||
painter->setBrush(QColor(layer->GetRedValue(), layer->GetGreenValue(), layer->GetBlueValue()));
|
// painter->setBrush(QColor(layer->GetRedValue(), layer->GetGreenValue(), layer->GetBlueValue()));
|
||||||
} else {
|
// } else {
|
||||||
painter->setBrush(Qt::blue);
|
// painter->setBrush(Qt::blue);
|
||||||
}
|
// }
|
||||||
for_each_go(go, slice->GetGos()) {
|
// for_each_go(go, slice->GetGos()) {
|
||||||
Segment* segment = dynamic_cast<Segment*>(go);
|
// Segment* segment = dynamic_cast<Segment*>(go);
|
||||||
if (segment) {
|
// if (segment) {
|
||||||
Box box = segment->GetBoundingBox();
|
// Box box = segment->GetBoundingBox();
|
||||||
QRectF rect;
|
// QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
// BoxToRectangle(box, rect);
|
||||||
painter->drawRect(rect);
|
// painter->drawRect(rect);
|
||||||
}
|
// }
|
||||||
end_for;
|
// end_for;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void SliceFigure::constructGoFigures() {
|
void SliceFigure::constructGoFigures() {
|
||||||
|
|
Loading…
Reference in New Issue