diff --git a/hurricane/src/viewer/CellViewer.cpp b/hurricane/src/viewer/CellViewer.cpp new file mode 100644 index 00000000..09b8183e --- /dev/null +++ b/hurricane/src/viewer/CellViewer.cpp @@ -0,0 +1,80 @@ +#include + +#include "CellWidget.h" +#include "LayersWidget.h" + +#include "CellViewer.h" + +CellViewer::CellViewer(Cell* cell) + : QMainWindow() +{ + cellWidget = new CellWidget(cell); + setCentralWidget(cellWidget); + + createActions(); + createMenus(); + + setWindowTitle(tr("Cell Viewer")); + resize(500, 400); +} + +CellViewer::~CellViewer() { + delete cellWidget; + delete layersWidget; +} + +//void CellViewer::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 CellViewer::wheelEvent(QWheelEvent *event) { +// int numDegrees = event->delta() / 8; +// double numSteps = numDegrees / 15.0f; +// zoom(pow(ZoomInFactor, numSteps)); +//} + +void CellViewer::zoomIn() { + cellWidget->reframe(cellWidget->getScale() * 1.2); + cellWidget->redraw(); +} + +void CellViewer::zoomOut() { +} + +void CellViewer::fitToWindow() { +} + +void CellViewer::createActions() { + zoomInAct = new QAction(tr("Zoom &In (25%)"), this); + zoomInAct->setShortcut(tr("Ctrl++")); + zoomInAct->setEnabled(true); + connect(zoomInAct, SIGNAL(triggered()), this, SLOT(zoomIn())); +} + +void CellViewer::createMenus() { + viewMenu = new QMenu(tr("&View"), this); + viewMenu->addAction(zoomInAct); + + menuBar()->addMenu(viewMenu); +} diff --git a/hurricane/src/viewer/CellViewer.h b/hurricane/src/viewer/CellViewer.h new file mode 100644 index 00000000..4ee9614d --- /dev/null +++ b/hurricane/src/viewer/CellViewer.h @@ -0,0 +1,34 @@ +#ifndef __CELL_VIEWER_H +#define __CELL_VIEWER_H + +#include "Cell.h" +using namespace H; + +#include + +class CellWidget; +class LayersWidget; + +class CellViewer : public QMainWindow { + Q_OBJECT + + public: + CellViewer(Cell* cell); + ~CellViewer(); + private: + CellWidget* cellWidget; + LayersWidget* layersWidget; + + QAction *zoomInAct; + QMenu *viewMenu; + + void createActions(); + void createMenus(); + + private slots: + void zoomIn(); + void zoomOut(); + void fitToWindow(); +}; + +#endif diff --git a/hurricane/src/viewer/LayersWidget.cpp b/hurricane/src/viewer/LayersWidget.cpp new file mode 100644 index 00000000..956f03ed --- /dev/null +++ b/hurricane/src/viewer/LayersWidget.cpp @@ -0,0 +1,45 @@ +#include "DataBase.h" +#include "Technology.h" +#include "BasicLayer.h" +using namespace H; + +#include +#include +#include + +#include "LayersWidget.h" + +LayersWidget::LayersWidget(QWidget* parent) + : QWidget(parent), + widgets() +{ + DataBase* db = GetDataBase(); + Technology* techno = db->GetTechnology(); + QGridLayout* mainLayout = new QGridLayout; + + int line = 0; + for_each_basic_layer(basicLayer, techno->GetBasicLayers()) { + QCheckBox* checkBox = new QCheckBox(); + widgets.insert(checkBox); + mainLayout->addWidget(checkBox, line, 0, Qt::AlignRight); + //connect(checkBox, SIGNAL(toggled(bool)), + // renderArea, SLOT(setAntialiased(bool))); + + string layerName = GetString(basicLayer->GetName()); + QLabel* label = new QLabel(tr(layerName.c_str())); + widgets.insert(label); + mainLayout->addWidget(label, line, 1, Qt::AlignRight); + ++line; + end_for; + } + setLayout(mainLayout); + setWindowTitle(tr("Layers")); +} + +LayersWidget::~LayersWidget() { + for (set::iterator wsit = widgets.begin(); + wsit != widgets.end(); + wsit++) { + delete *wsit; + } +} diff --git a/hurricane/src/viewer/LayersWidget.h b/hurricane/src/viewer/LayersWidget.h new file mode 100644 index 00000000..a797029b --- /dev/null +++ b/hurricane/src/viewer/LayersWidget.h @@ -0,0 +1,19 @@ +#ifndef LAYERS_WIDGET_H +#define LAYERS_WIDGET_H + +#include +using namespace std; + +#include + +class LayersWidget : public QWidget { + Q_OBJECT + + public : + LayersWidget(QWidget *parent = 0); + ~LayersWidget(); + private: + set widgets; +}; + +#endif