editor in progress
This commit is contained in:
parent
2f4e281425
commit
1b45c3b7c2
|
@ -6,5 +6,5 @@ includedir=${exec_prefix}/include
|
||||||
Name: hurricane
|
Name: hurricane
|
||||||
Description: Hurricane Libs
|
Description: Hurricane Libs
|
||||||
Version: 2.0.b
|
Version: 2.0.b
|
||||||
Libs: -L${libdir} -lanalogic -lhurricaneviewer -lhurricane
|
Libs: -L${libdir} -lanalogic -lhurricaneviewer -lhurricaneeditor -lhurricane
|
||||||
Cflags: -I${includedir}/coriolis/hurricane
|
Cflags: -I${includedir}/coriolis/hurricane
|
||||||
|
|
|
@ -4,12 +4,13 @@ include_directories(${HURRICANE_SOURCE_DIR}/src/hurricane)
|
||||||
|
|
||||||
set(includes CellEditor.h CellScene.h)
|
set(includes CellEditor.h CellScene.h)
|
||||||
set(exports CellEditor.h)
|
set(exports CellEditor.h)
|
||||||
set(cpps InstanceFigure.cpp CellScene.cpp CellEditor.cpp)
|
set(cpps CellGraphicsItem.cpp InstanceGraphicsItem.cpp SegmentFigure.cpp
|
||||||
|
CellScene.cpp CellEditor.cpp)
|
||||||
|
|
||||||
QT4_WRAP_CPP(MOC_SRCS ${includes})
|
QT4_WRAP_CPP(MOC_SRCS ${includes})
|
||||||
|
|
||||||
add_library(hurricaneeditor SHARED ${cpps} ${MOC_SRCS})
|
add_library(hurricaneeditor SHARED ${cpps} ${MOC_SRCS})
|
||||||
target_link_libraries(hurricaneeditor ${QT_LIBRARIES} hurricane)
|
target_link_libraries(hurricaneeditor ${QT_LIBRARIES} hurricane)
|
||||||
|
|
||||||
install(FILES ${includes} DESTINATION /include/coriolis/hurricane)
|
install(FILES ${exports} DESTINATION /include/coriolis/hurricane)
|
||||||
install(TARGETS hurricaneeditor DESTINATION /lib)
|
install(TARGETS hurricaneeditor DESTINATION /lib)
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include "Utils.h"
|
||||||
|
#include "CellScene.h"
|
||||||
|
|
||||||
|
#include "CellEditor.h"
|
||||||
|
|
||||||
|
CellEditor::CellEditor(Cell* c)
|
||||||
|
: QMainWindow(),
|
||||||
|
cell(c)
|
||||||
|
{
|
||||||
|
|
||||||
|
createActions();
|
||||||
|
createMenus();
|
||||||
|
|
||||||
|
scene = new CellScene(cell);
|
||||||
|
view = new QGraphicsView(scene);
|
||||||
|
|
||||||
|
setCentralWidget(view);
|
||||||
|
|
||||||
|
setWindowTitle(tr("Cell Editor"));
|
||||||
|
resize(1000, 500);
|
||||||
|
fitToWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
CellEditor::~CellEditor() {
|
||||||
|
delete view;
|
||||||
|
delete scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
//void CellEditor::keyPressEvent(QKeyEvent *event) {
|
||||||
|
// switch (event->key()) {
|
||||||
|
// case Qt::Key_Plus:
|
||||||
|
// zoom(ZoomInFactor);
|
||||||
|
// break;
|
||||||
|
// case Qt::Key_Minus:
|
||||||
|
// zoom(ZoomOutFactor);
|
||||||
|
// break;
|
||||||
|
// case Qt::Key_Left:
|
||||||
|
// scroll(-ScrollStep, 0);
|
||||||
|
// break;
|
||||||
|
// case Qt::Key_Right:
|
||||||
|
// scroll(+ScrollStep, 0);
|
||||||
|
// break;
|
||||||
|
// case Qt::Key_Down:
|
||||||
|
// scroll(0, -ScrollStep);
|
||||||
|
// break;
|
||||||
|
// case Qt::Key_Up:
|
||||||
|
// scroll(0, +ScrollStep);
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// QWidget::keyPressEvent(event);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//void CellEditor::wheelEvent(QWheelEvent *event) {
|
||||||
|
// int numDegrees = event->delta() / 8;
|
||||||
|
// double numSteps = numDegrees / 15.0f;
|
||||||
|
// zoom(pow(ZoomInFactor, numSteps));
|
||||||
|
//}
|
||||||
|
|
||||||
|
void CellEditor::zoomIn() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellEditor::zoomOut() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellEditor::fitToWindow() {
|
||||||
|
if (cell) {
|
||||||
|
Box area(cell->GetBoundingBox());
|
||||||
|
QRectF rect;
|
||||||
|
boxToRectangle(area, rect);
|
||||||
|
view->fitInView(rect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellEditor::createActions() {
|
||||||
|
zoomInAct = new QAction(tr("Zoom &In (25%)"), this);
|
||||||
|
zoomInAct->setShortcut(tr("Ctrl++"));
|
||||||
|
zoomInAct->setEnabled(true);
|
||||||
|
connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn()));
|
||||||
|
|
||||||
|
zoomOutAct = new QAction(tr("Zoom &Out (25%)"), this);
|
||||||
|
zoomOutAct->setShortcut(tr("Ctrl+-"));
|
||||||
|
zoomOutAct->setEnabled(true);
|
||||||
|
connect(zoomOutAct, SIGNAL(triggered()), this, SLOT(zoomOut()));
|
||||||
|
|
||||||
|
fitToWindowAct = new QAction(tr("Fit &To &Window"), this);
|
||||||
|
fitToWindowAct->setShortcut(tr("f"));
|
||||||
|
fitToWindowAct->setEnabled(true);
|
||||||
|
connect(fitToWindowAct, SIGNAL(triggered()), this, SLOT(fitToWindow()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellEditor::createMenus() {
|
||||||
|
viewMenu = new QMenu(tr("&View"), this);
|
||||||
|
viewMenu->addAction(zoomInAct);
|
||||||
|
viewMenu->addAction(zoomOutAct);
|
||||||
|
viewMenu->addAction(fitToWindowAct);
|
||||||
|
|
||||||
|
menuBar()->addMenu(viewMenu);
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
#ifndef __CELL_EDITOR_H
|
||||||
|
#define __CELL_EDITOR_H
|
||||||
|
|
||||||
|
#include "Cell.h"
|
||||||
|
using namespace H;
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
class QGraphicsView;
|
||||||
|
class CellScene;
|
||||||
|
|
||||||
|
class CellEditor : public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
CellEditor(Cell* cell);
|
||||||
|
~CellEditor();
|
||||||
|
private:
|
||||||
|
Cell* cell;
|
||||||
|
CellScene *scene;
|
||||||
|
QGraphicsView *view;
|
||||||
|
|
||||||
|
QAction *zoomInAct;
|
||||||
|
QAction *zoomOutAct;
|
||||||
|
QAction *fitToWindowAct;
|
||||||
|
QMenu *viewMenu;
|
||||||
|
|
||||||
|
void createActions();
|
||||||
|
void createMenus();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void zoomIn();
|
||||||
|
void zoomOut();
|
||||||
|
void fitToWindow();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,80 +0,0 @@
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QStyleOptionGraphicsItem>
|
|
||||||
|
|
||||||
#include "InstanceFigure.h"
|
|
||||||
#include "SliceFigure.h"
|
|
||||||
|
|
||||||
#include "Utils.h"
|
|
||||||
#include "CellFigure.h"
|
|
||||||
|
|
||||||
CellFigure::CellFigure(Cell* c):
|
|
||||||
QGraphicsItem(),
|
|
||||||
cell(c) {
|
|
||||||
QTransform transform;
|
|
||||||
transform.setMatrix(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0);
|
|
||||||
setTransform(transform);
|
|
||||||
for_each_instance(instance, cell->GetInstances()) {
|
|
||||||
new InstanceFigure(this, instance);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
//for_each_slice(slice, cell->GetSlices()) {
|
|
||||||
// new SliceFigure(this, slice);
|
|
||||||
// end_for;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
CellFigure::CellFigure(InstanceFigure* master, Cell* c) : QGraphicsItem(master), cell(c) {
|
|
||||||
for_each_instance(instance, cell->GetInstances()) {
|
|
||||||
new InstanceFigure(this, instance);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
for_each_slice(slice, cell->GetSlices()) {
|
|
||||||
new SliceFigure(this, slice);
|
|
||||||
end_for;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF CellFigure::boundingRect() const {
|
|
||||||
Box box = cell->GetBoundingBox();
|
|
||||||
QRectF rect;
|
|
||||||
BoxToRectangle(box, rect);
|
|
||||||
rect = transform().mapRect(rect);
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget *) {
|
|
||||||
// QPen pen(Qt::blue);
|
|
||||||
// pen.setWidth(10);
|
|
||||||
// painter->setPen(pen);
|
|
||||||
// painter->drawLine(0, 0, 50, 0);
|
|
||||||
//
|
|
||||||
// painter->drawLine(0, 0, 0, 50);
|
|
||||||
// pen.setColor(Qt::red);
|
|
||||||
// painter->setPen(pen);
|
|
||||||
|
|
||||||
//painter->setClipRect(option->exposedRect);
|
|
||||||
//if (option->levelOfDetail > 1.0) {
|
|
||||||
// drawBoundary(painter);
|
|
||||||
//} else {
|
|
||||||
// drawPhantom(painter);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellFigure::drawBoundary(QPainter* painter) {
|
|
||||||
QPen pen(Qt::black);
|
|
||||||
painter->setPen(pen);
|
|
||||||
Box box = cell->GetAbutmentBox();
|
|
||||||
QRectF rect;
|
|
||||||
BoxToRectangle(box, rect);
|
|
||||||
painter->drawRect(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CellFigure::drawPhantom(QPainter* painter) {
|
|
||||||
painter->setBrush(Qt::red);
|
|
||||||
Box box = cell->GetAbutmentBox();
|
|
||||||
QRectF rect;
|
|
||||||
BoxToRectangle(box, rect);
|
|
||||||
painter->drawRect(rect);
|
|
||||||
}
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QStyleOptionGraphicsItem>
|
||||||
|
|
||||||
|
#include "Slice.h"
|
||||||
|
using namespace H;
|
||||||
|
|
||||||
|
#include "Utils.h"
|
||||||
|
#include "InstanceGraphicsItem.h"
|
||||||
|
#include "SegmentFigure.h"
|
||||||
|
#include "CellGraphicsItem.h"
|
||||||
|
|
||||||
|
CellGraphicsItem::CellGraphicsItem(Cell* c):
|
||||||
|
QGraphicsItem(),
|
||||||
|
cell(c) {
|
||||||
|
//QTransform transform;
|
||||||
|
//transform.setMatrix(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0);
|
||||||
|
//setTransform(transform);
|
||||||
|
//for_each_instance(instance, cell->GetInstances()) {
|
||||||
|
// new InstanceGraphicsItem(this, instance);
|
||||||
|
// end_for;
|
||||||
|
//}
|
||||||
|
|
||||||
|
for_each_slice(slice, cell->GetSlices()) {
|
||||||
|
for_each_go(go, slice->GetGos()) {
|
||||||
|
Segment* segment = dynamic_cast<Segment*>(go);
|
||||||
|
if (segment) {
|
||||||
|
new SegmentGraphicsItem(this, segment);
|
||||||
|
}
|
||||||
|
end_for;
|
||||||
|
}
|
||||||
|
end_for;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CellGraphicsItem::CellGraphicsItem(InstanceGraphicsItem* master, Cell* c) : QGraphicsItem(master), cell(c) {
|
||||||
|
//for_each_instance(instance, cell->GetInstances()) {
|
||||||
|
// new InstanceGraphicsItem(this, instance);
|
||||||
|
// end_for;
|
||||||
|
//}
|
||||||
|
//for_each_slice(slice, cell->GetSlices()) {
|
||||||
|
// new SliceFigure(this, slice);
|
||||||
|
// end_for;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
QRectF CellGraphicsItem::boundingRect() const {
|
||||||
|
Box box = cell->GetBoundingBox();
|
||||||
|
QRectF rect;
|
||||||
|
boxToRectangle(box, rect);
|
||||||
|
//rect = transform().mapRect(rect);
|
||||||
|
return rect;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem* option, QWidget *) {
|
||||||
|
painter->setClipRect(option->exposedRect);
|
||||||
|
drawBoundary(painter);
|
||||||
|
//drawPhantom(painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellGraphicsItem::drawBoundary(QPainter* painter) {
|
||||||
|
QPen pen(Qt::black);
|
||||||
|
painter->setPen(pen);
|
||||||
|
Box box = cell->GetAbutmentBox();
|
||||||
|
QRectF rect;
|
||||||
|
boxToRectangle(box, rect);
|
||||||
|
painter->drawRect(rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CellGraphicsItem::drawPhantom(QPainter* painter) {
|
||||||
|
painter->setBrush(Qt::red);
|
||||||
|
Box box = cell->GetAbutmentBox();
|
||||||
|
QRectF rect;
|
||||||
|
boxToRectangle(box, rect);
|
||||||
|
painter->drawRect(rect);
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __CELL_FIGURE_H
|
#ifndef __CELL_GRAPHICS_ITEM_H
|
||||||
#define __CELL_FIGURE_H
|
#define __CELL_GRAPHICS_ITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -7,12 +7,12 @@
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class InstanceFigure;
|
class InstanceGraphicsItem;
|
||||||
|
|
||||||
class CellFigure : public QGraphicsItem {
|
class CellGraphicsItem : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
CellFigure(Cell* cell);
|
CellGraphicsItem(Cell* cell);
|
||||||
CellFigure(InstanceFigure* master, Cell* cell);
|
CellGraphicsItem(InstanceGraphicsItem* master, 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);
|
||||||
|
@ -23,4 +23,4 @@ class CellFigure : public QGraphicsItem {
|
||||||
void drawPhantom(QPainter* painter);
|
void drawPhantom(QPainter* painter);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __CELL_FIGURE_H */
|
#endif /* __CELL_GRAPHICS_ITEM_H */
|
|
@ -1,6 +1,11 @@
|
||||||
|
#include "CellGraphicsItem.h"
|
||||||
|
|
||||||
#include "CellScene.h"
|
#include "CellScene.h"
|
||||||
|
|
||||||
CellScene::CellScene(Cell* c)
|
CellScene::CellScene(Cell* c)
|
||||||
: QGraphicsScene()
|
: QGraphicsScene()
|
||||||
, cell(c)
|
, cell(c)
|
||||||
{}
|
{
|
||||||
|
CellGraphicsItem* cellItem = new CellGraphicsItem(cell);
|
||||||
|
addItem(cellItem);
|
||||||
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
using namespace H;
|
using namespace H;
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "InstanceFigure.h"
|
#include "InstanceGraphicsItem.h"
|
||||||
|
|
||||||
//InstanceFigure::InstanceFigure(Instance* inst)
|
//InstanceGraphicsItem::InstanceGraphicsItem(Instance* inst)
|
||||||
// : instance(inst),
|
// : instance(inst),
|
||||||
// cell(instance->GetMasterCell())
|
// cell(instance->GetMasterCell())
|
||||||
//{
|
//{
|
||||||
|
@ -24,42 +24,42 @@ using namespace H;
|
||||||
// constructSubInstances();
|
// constructSubInstances();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
InstanceFigure::InstanceFigure(Cell* c)
|
InstanceGraphicsItem::InstanceGraphicsItem(Cell* c)
|
||||||
: instance(NULL),
|
: instance(NULL),
|
||||||
cell(c)
|
cell(c)
|
||||||
{
|
{
|
||||||
constructSubInstances();
|
constructSubInstances();
|
||||||
}
|
}
|
||||||
|
|
||||||
InstanceFigure::InstanceFigure(InstanceFigure* parent, Instance* inst)
|
//InstanceGraphicsItem::InstanceGraphicsItem(InstanceGraphicsItem* parent, Instance* inst)
|
||||||
: QGraphicsItem(parent),
|
// : QGraphicsItem(parent),
|
||||||
instance(inst),
|
// instance(inst),
|
||||||
cell(instance->GetMasterCell())
|
// 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);
|
||||||
constructSubInstances();
|
// constructSubInstances();
|
||||||
}
|
//}
|
||||||
|
|
||||||
void InstanceFigure::constructSubInstances() {
|
void InstanceGraphicsItem::constructSubInstances() {
|
||||||
for_each_instance(instance, cell->GetInstances()) {
|
for_each_instance(instance, cell->GetInstances()) {
|
||||||
new InstanceFigure(this, instance);
|
//new InstanceGraphicsItem(this, instance);
|
||||||
end_for;
|
end_for;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF InstanceFigure::boundingRect() const {
|
QRectF InstanceGraphicsItem::boundingRect() const {
|
||||||
Box box = cell->GetAbutmentBox();
|
Box box = cell->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 InstanceGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
painter->setClipRect(option->exposedRect.adjusted(-1.0, -1.0, 1.0, 1.0));
|
painter->setClipRect(option->exposedRect.adjusted(-1.0, -1.0, 1.0, 1.0));
|
||||||
if (option->levelOfDetail > 1.0) {
|
if (option->levelOfDetail > 1.0) {
|
||||||
drawBoundary(painter);
|
drawBoundary(painter);
|
||||||
|
@ -69,7 +69,7 @@ void InstanceFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceFigure::drawElements(QPainter* painter) {
|
void InstanceGraphicsItem::drawElements(QPainter* painter) {
|
||||||
for_each_slice(slice, cell->GetSlices()) {
|
for_each_slice(slice, cell->GetSlices()) {
|
||||||
painter->save();
|
painter->save();
|
||||||
BasicLayer* layer = dynamic_cast<BasicLayer*>(slice->GetLayer());
|
BasicLayer* layer = dynamic_cast<BasicLayer*>(slice->GetLayer());
|
||||||
|
@ -83,7 +83,7 @@ void InstanceFigure::drawElements(QPainter* painter) {
|
||||||
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,19 +94,19 @@ void InstanceFigure::drawElements(QPainter* painter) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceFigure::drawBoundary(QPainter* painter) {
|
void InstanceGraphicsItem::drawBoundary(QPainter* painter) {
|
||||||
QPen pen(Qt::black);
|
QPen pen(Qt::black);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
Box box = cell->GetAbutmentBox();
|
Box box = cell->GetAbutmentBox();
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
boxToRectangle(box, rect);
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InstanceFigure::drawPhantom(QPainter* painter) {
|
void InstanceGraphicsItem::drawPhantom(QPainter* painter) {
|
||||||
painter->setBrush(Qt::red);
|
painter->setBrush(Qt::red);
|
||||||
Box box = cell->GetAbutmentBox();
|
Box box = cell->GetAbutmentBox();
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
boxToRectangle(box, rect);
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __INSTANCE_FIGURE_H
|
#ifndef __INSTANCE_GRAPHICS_ITEM_H
|
||||||
#define __INSTANCE_FIGURE_H
|
#define __INSTANCE_GRAPHICS_ITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -8,11 +8,10 @@
|
||||||
#include "Cell.h"
|
#include "Cell.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class InstanceFigure : public QGraphicsItem {
|
class InstanceGraphicsItem : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
InstanceFigure(InstanceFigure* parent, Instance* instance);
|
//InstanceGraphicsItem(InstanceGraphicsItem* parent, Instance* instance);
|
||||||
//InstanceFigure(Instance* instance);
|
InstanceGraphicsItem(Cell* cell);
|
||||||
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);
|
||||||
|
@ -27,4 +26,4 @@ class InstanceFigure : public QGraphicsItem {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __INSTANCE_FIGURE_H */
|
#endif /* __INSTANCE_GRAPHICS_ITEM_H */
|
|
@ -7,25 +7,26 @@
|
||||||
using namespace H;
|
using namespace H;
|
||||||
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "SliceFigure.h"
|
#include "CellGraphicsItem.h"
|
||||||
#include "SegmentFigure.h"
|
#include "SegmentFigure.h"
|
||||||
|
|
||||||
SegmentFigure::SegmentFigure(SliceFigure* master, Segment* s):
|
SegmentGraphicsItem::SegmentGraphicsItem(CellGraphicsItem* master, Segment* s):
|
||||||
QGraphicsItem(master),
|
QGraphicsItem(master),
|
||||||
segment(s)
|
segment(s)
|
||||||
{}
|
{
|
||||||
|
setFlag(ItemIsMovable);
|
||||||
|
}
|
||||||
|
|
||||||
QRectF SegmentFigure::boundingRect() const {
|
QRectF SegmentGraphicsItem::boundingRect() const {
|
||||||
Box box = getGo()->GetBoundingBox();
|
Box box = segment->GetBoundingBox();
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
boxToRectangle(box, rect);
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SegmentFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
void SegmentGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
|
||||||
Q_UNUSED(widget);
|
|
||||||
|
|
||||||
if (option->levelOfDetail > 1.0) {
|
//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) {
|
||||||
|
@ -35,7 +36,18 @@ void SegmentFigure::paint(QPainter *painter, const QStyleOptionGraphicsItem *opt
|
||||||
}
|
}
|
||||||
Box box = segment->GetBoundingBox();
|
Box box = segment->GetBoundingBox();
|
||||||
QRectF rect;
|
QRectF rect;
|
||||||
BoxToRectangle(box, rect);
|
boxToRectangle(box, rect);
|
||||||
painter->drawRect(rect);
|
painter->drawRect(rect);
|
||||||
}
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SegmentGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
update();
|
||||||
|
QGraphicsItem::mousePressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SegmentGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
|
update();
|
||||||
|
QGraphicsItem::mouseReleaseEvent(event);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef __SEGMENT_FIGURE_H
|
#ifndef __SEGMENT_GRAPHICS_ITEM_H
|
||||||
#define __SEGMENT_FIGURE_H
|
#define __SEGMENT_GRAPHICS_ITEM_H
|
||||||
|
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -7,17 +7,18 @@
|
||||||
#include "Segment.h"
|
#include "Segment.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class SliceFigure;
|
class CellGraphicsItem;
|
||||||
|
|
||||||
class SegmentFigure : public QGraphicsItem {
|
class SegmentGraphicsItem : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
SegmentFigure(SliceFigure* parent, Segment* segment);
|
SegmentGraphicsItem(CellGraphicsItem* parent, Segment* segment);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
private:
|
private:
|
||||||
Segment* segment;
|
Segment* segment;
|
||||||
protected:
|
protected:
|
||||||
Go* getGo() const { return segment; }
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __SEGMENT_FIGURE_H */
|
#endif /* __SEGMENT_GRAPHICS_ITEM_H */
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "BasicLayer.h"
|
#include "BasicLayer.h"
|
||||||
using namespace H;
|
using namespace H;
|
||||||
|
|
||||||
#include "SegmentFigure.h"
|
#include "SegmentGraphicsItem.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "SliceFigure.h"
|
#include "SliceFigure.h"
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ void SliceFigure::constructGoFigures() {
|
||||||
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) {
|
||||||
new SegmentFigure(this, segment);
|
new SegmentGraphicsItem(this, segment);
|
||||||
}
|
}
|
||||||
end_for;
|
end_for;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,14 +4,14 @@
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "CellFigure.h"
|
#include "CellGraphicsItem.h"
|
||||||
|
|
||||||
#include "Slice.h"
|
#include "Slice.h"
|
||||||
using namespace Hurricane;
|
using namespace Hurricane;
|
||||||
|
|
||||||
class SliceFigure : public QGraphicsItem {
|
class SliceFigure : public QGraphicsItem {
|
||||||
public:
|
public:
|
||||||
SliceFigure(CellFigure* parent, Slice* slice);
|
SliceFigure(CellGraphicsItem* parent, Slice* slice);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include "Transformation.h"
|
#include "Transformation.h"
|
||||||
using namespace H;
|
using namespace H;
|
||||||
|
|
||||||
inline void BoxToRectangle(const Box& box, QRectF& rec) {
|
inline void boxToRectangle(const Box& box, QRectF& rec) {
|
||||||
double xmin = GetValue(box.getXMin());
|
double xmin = GetValue(box.getXMin());
|
||||||
double xmax = GetValue(box.getXMax());
|
double xmax = GetValue(box.getXMax());
|
||||||
double ymin = GetValue(box.getYMin());
|
double ymin = GetValue(box.getYMin());
|
||||||
|
@ -15,7 +15,7 @@ inline void BoxToRectangle(const Box& box, QRectF& rec) {
|
||||||
rec.setCoords(xmin, ymin, xmax, ymax);
|
rec.setCoords(xmin, ymin, xmax, ymax);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void HurricanePositionToQtPosition(const Transformation& transformation, QTransform& transform, QPoint& position) {
|
inline void hurricanePositionToQtPosition(const Transformation& transformation, QTransform& transform, QPoint& position) {
|
||||||
double tx = GetValue(transformation.getTx());
|
double tx = GetValue(transformation.getTx());
|
||||||
double ty = GetValue(transformation.getTy());
|
double ty = GetValue(transformation.getTy());
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ set(includes CellWidget.h LayersWidget.h CellViewer.h)
|
||||||
set(exports CellViewer.h)
|
set(exports CellViewer.h)
|
||||||
set(cpps CellWidget.cpp LayersWidget.cpp CellViewer.cpp)
|
set(cpps CellWidget.cpp LayersWidget.cpp CellViewer.cpp)
|
||||||
|
|
||||||
Q4_WRAP_CPP(MOC_SRCS ${includes})
|
QT4_WRAP_CPP(MOC_SRCS ${includes})
|
||||||
|
|
||||||
add_library(hurricaneviewer SHARED ${cpps} ${MOC_SRCS})
|
add_library(hurricaneviewer SHARED ${cpps} ${MOC_SRCS})
|
||||||
target_link_libraries(hurricaneviewer ${QT_LIBRARIES} hurricane)
|
target_link_libraries(hurricaneviewer ${QT_LIBRARIES} hurricane)
|
||||||
|
|
Loading…
Reference in New Issue