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)
|
||||
|
||||
set(includes CellFigure.h InstanceFigure.h SliceFigure.h GoFigure.h SegmentFigure.h)
|
||||
set(cpps CellFigure.cpp InstanceFigure.cpp SliceFigure.cpp GoFigure.cpp SegmentFigure.cpp)
|
||||
set(includes InstanceFigure.h Utils.h)
|
||||
set(cpps InstanceFigure.cpp CellScene.cpp)
|
||||
|
||||
add_library(hurricanefigs SHARED ${cpps})
|
||||
target_link_libraries(hurricanefigs ${QT_LIBRARIES} hurricane)
|
||||
|
||||
install(FILES ${includes} DESTINATION /include/hurricane)
|
||||
install(TARGETS hurricanefigs DESTINATION /lib)
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ CellFigure::CellFigure(Cell* c):
|
|||
new InstanceFigure(this, instance);
|
||||
end_for;
|
||||
}
|
||||
for_each_slice(slice, cell->GetSlices()) {
|
||||
new SliceFigure(this, slice);
|
||||
end_for;
|
||||
}
|
||||
//for_each_slice(slice, cell->GetSlices()) {
|
||||
// new SliceFigure(this, slice);
|
||||
// end_for;
|
||||
//}
|
||||
}
|
||||
|
||||
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);
|
||||
// painter->setPen(pen);
|
||||
|
||||
painter->setClipRect(option->exposedRect);
|
||||
if (option->levelOfDetail > 1.0) {
|
||||
drawBoundary(painter);
|
||||
} else {
|
||||
drawPhantom(painter);
|
||||
}
|
||||
//painter->setClipRect(option->exposedRect);
|
||||
//if (option->levelOfDetail > 1.0) {
|
||||
// drawBoundary(painter);
|
||||
//} else {
|
||||
// drawPhantom(painter);
|
||||
//}
|
||||
}
|
||||
|
||||
void CellFigure::drawBoundary(QPainter* painter) {
|
||||
|
@ -78,4 +78,3 @@ void CellFigure::drawPhantom(QPainter* painter) {
|
|||
BoxToRectangle(box, 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 <QTransform>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
|
||||
#include "Cell.h"
|
||||
#include "Slice.h"
|
||||
#include "Segment.h"
|
||||
#include "BasicLayer.h"
|
||||
using namespace H;
|
||||
|
||||
#include "Utils.h"
|
||||
#include "InstanceFigure.h"
|
||||
|
||||
InstanceFigure::InstanceFigure(CellFigure* parent, Instance* inst):
|
||||
QGraphicsItem(parent),
|
||||
instance(inst) {
|
||||
Cell* masterCell = inst->GetMasterCell();
|
||||
|
||||
Transformation transformation = instance->GetTransformation();
|
||||
QTransform transform;
|
||||
QPoint pos;
|
||||
HurricanePositionToQtPosition(transformation, transform, pos);
|
||||
setTransform(transform);
|
||||
setPos(pos);
|
||||
new CellFigure(this, masterCell);
|
||||
//InstanceFigure::InstanceFigure(Instance* inst)
|
||||
// : instance(inst),
|
||||
// cell(instance->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();
|
||||
QTransform transform;
|
||||
QPoint pos;
|
||||
HurricanePositionToQtPosition(transformation, transform, pos);
|
||||
setTransform(transform);
|
||||
setPos(pos);
|
||||
constructSubInstances();
|
||||
}
|
||||
|
||||
void InstanceFigure::constructSubInstances() {
|
||||
for_each_instance(instance, cell->GetInstances()) {
|
||||
new InstanceFigure(this, instance);
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
|
||||
QRectF InstanceFigure::boundingRect() const {
|
||||
Cell* masterCell = instance->GetMasterCell();
|
||||
Box box = masterCell->GetAbutmentBox();
|
||||
QRectF rect;
|
||||
BoxToRectangle(box, rect);
|
||||
return rect;
|
||||
Box box = cell->GetAbutmentBox();
|
||||
QRectF rect;
|
||||
BoxToRectangle(box, 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 <QObject>
|
||||
|
||||
#include "CellFigure.h"
|
||||
|
||||
#include "Instance.h"
|
||||
#include "Cell.h"
|
||||
using namespace Hurricane;
|
||||
|
||||
class InstanceFigure : public QGraphicsItem {
|
||||
public:
|
||||
InstanceFigure(CellFigure* parent, Instance* instance);
|
||||
InstanceFigure(InstanceFigure* parent, Instance* instance);
|
||||
//InstanceFigure(Instance* instance);
|
||||
InstanceFigure(Cell* cell);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||
QWidget *widget);
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
#include "Utils.h"
|
||||
#include "SliceFigure.h"
|
||||
#include "SegmentFigure.h"
|
||||
|
||||
SegmentFigure::SegmentFigure(SliceFigure* master, Segment* s):
|
||||
GoFigure(master),
|
||||
QGraphicsItem(master),
|
||||
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) {
|
||||
if (option->levelOfDetail < 1.0) {
|
||||
Q_UNUSED(widget);
|
||||
|
||||
if (option->levelOfDetail > 1.0) {
|
||||
painter->setClipRect(option->exposedRect);
|
||||
BasicLayer* layer = dynamic_cast<BasicLayer*>(segment->GetLayer());
|
||||
if (layer) {
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
#include <QGraphicsItem>
|
||||
#include <QObject>
|
||||
|
||||
#include "GoFigure.h"
|
||||
|
||||
#include "Segment.h"
|
||||
using namespace Hurricane;
|
||||
|
||||
class SegmentFigure : public GoFigure {
|
||||
class SliceFigure;
|
||||
|
||||
class SegmentFigure : public QGraphicsItem {
|
||||
public:
|
||||
SegmentFigure(SliceFigure* parent, Segment* segment);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
|
||||
QRectF boundingRect() const;
|
||||
private:
|
||||
Segment* segment;
|
||||
protected:
|
||||
|
|
|
@ -21,25 +21,25 @@ QRectF SliceFigure::boundingRect() const {
|
|||
}
|
||||
|
||||
void SliceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||
if (option->levelOfDetail > 1.0) {
|
||||
// painter->setClipRect(option->exposedRect);
|
||||
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;
|
||||
}
|
||||
}
|
||||
// if (option->levelOfDetail > 1.0) {
|
||||
//// painter->setClipRect(option->exposedRect);
|
||||
// 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;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
void SliceFigure::constructGoFigures() {
|
||||
|
|
Loading…
Reference in New Issue