The new Viewer (h).
|
@ -1,4 +1,4 @@
|
|||
add_subdirectory(hurricane)
|
||||
add_subdirectory(hinspector)
|
||||
add_subdirectory(viewer)
|
||||
add_subdirectory(hviewer)
|
||||
add_subdirectory(pyext)
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
include ( ${QT_USE_FILE} )
|
||||
|
||||
include_directories ( ${HURRICANE_SOURCE_DIR}/src/hurricane )
|
||||
|
||||
set ( includes ScreenUtilities.h
|
||||
DisplayStyle.h
|
||||
Graphics.h
|
||||
)
|
||||
set ( mocincludes PaletteEntry.h
|
||||
LayerPaletteEntry.h
|
||||
GroupPaletteEntry.h
|
||||
ViewerPaletteEntry.h
|
||||
Palette.h
|
||||
CellWidget.h
|
||||
CellViewer.h
|
||||
)
|
||||
set ( exports ScreenUtilities.h
|
||||
PaletteEntry.h
|
||||
Palette.h
|
||||
DisplayStyle.h
|
||||
Graphics.h
|
||||
CellViewer.h
|
||||
)
|
||||
set ( cpps ScreenUtilities.cpp
|
||||
DisplayStyle.cpp
|
||||
Graphics.cpp
|
||||
PaletteEntry.cpp
|
||||
LayerPaletteEntry.cpp
|
||||
GroupPaletteEntry.cpp
|
||||
ViewerPaletteEntry.cpp
|
||||
Palette.cpp
|
||||
CellWidget.cpp
|
||||
CellViewer.cpp
|
||||
)
|
||||
|
||||
qt4_wrap_cpp ( MOC_SRCS ${mocincludes} )
|
||||
qt4_add_resources ( RCC_SRCS CellViewer.qrc )
|
||||
|
||||
add_library ( hviewer SHARED ${cpps} ${MOC_SRCS} ${RCC_SRCS} )
|
||||
target_link_libraries ( hviewer ${QT_LIBRARIES} hurricane )
|
||||
|
||||
install ( FILES ${exports} DESTINATION /include/hurricane )
|
||||
install ( TARGETS hviewer DESTINATION /lib )
|
|
@ -0,0 +1,144 @@
|
|||
|
||||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QAction>
|
||||
# include <QMenu>
|
||||
# include <QMenuBar>
|
||||
# include <QDockWidget>
|
||||
|
||||
# include "Cell.h"
|
||||
|
||||
//# include "MapView.h"
|
||||
# include "Palette.h"
|
||||
# include "CellWidget.h"
|
||||
# include "CellViewer.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
CellViewer::CellViewer ( Cell* cell ) : QMainWindow()
|
||||
, _openAction(NULL)
|
||||
, _nextCellAction(NULL)
|
||||
, _previousCellAction(NULL)
|
||||
, _nextAction(NULL)
|
||||
, _saveAction(NULL)
|
||||
, _exitAction(NULL)
|
||||
, _refreshAction(NULL)
|
||||
, _fitToContentsAction(NULL)
|
||||
, _showBoundariesAction(NULL)
|
||||
, _fileMenu(NULL)
|
||||
, _viewMenu(NULL)
|
||||
//, _mapView(NULL)
|
||||
, _palette(NULL)
|
||||
, _cellWidget(NULL)
|
||||
{
|
||||
createMenus ();
|
||||
createLayout ( cell );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CellViewer::createActions ()
|
||||
{
|
||||
if ( _openAction ) return;
|
||||
|
||||
_openAction = new QAction ( tr("&Open Cell"), this );
|
||||
_openAction->setIcon ( QIcon(":/images/stock_open.png") );
|
||||
_openAction->setStatusTip ( tr("Open (load) a new Cell") );
|
||||
|
||||
_nextCellAction = new QAction ( tr("Next Cell"), this );
|
||||
_nextCellAction->setStatusTip ( tr("Go to the next Cell in history") );
|
||||
|
||||
_previousCellAction = new QAction ( tr("Previous Cell"), this );
|
||||
_previousCellAction->setStatusTip ( tr("Go to the previous Cell in history") );
|
||||
|
||||
_nextAction = new QAction ( tr("&Next Breakpoint"), this );
|
||||
_nextAction->setStatusTip ( tr("Proceed to the next breakpoint") );
|
||||
|
||||
_saveAction = new QAction ( tr("&Save Cell"), this );
|
||||
_saveAction->setIcon ( QIcon(":/images/stock_save.png") );
|
||||
_saveAction->setStatusTip ( tr("Save the current Cell") );
|
||||
|
||||
_exitAction = new QAction ( tr("&Exit"), this );
|
||||
_exitAction->setStatusTip ( tr("Close Coriolis CellViewer") );
|
||||
_exitAction->setShortcut ( QKeySequence(tr("CTRL+Q")) );
|
||||
connect ( _exitAction, SIGNAL(triggered()), this, SLOT(close()) );
|
||||
|
||||
_refreshAction = new QAction ( tr("&Refresh"), this );
|
||||
_refreshAction->setStatusTip ( tr("Force full redrawing of the display") );
|
||||
_refreshAction->setShortcut ( QKeySequence(tr("CTRL+L")) );
|
||||
|
||||
_fitToContentsAction = new QAction ( tr("&Fit to Contents"), this );
|
||||
_fitToContentsAction->setStatusTip ( tr("Adjust zoom to fit the whole cell's contents") );
|
||||
_fitToContentsAction->setShortcut ( Qt::Key_F );
|
||||
|
||||
_showBoundariesAction = new QAction ( tr("&Boundaries"), this );
|
||||
_showBoundariesAction->setCheckable ( true );
|
||||
_showBoundariesAction->setStatusTip ( tr("Show/hide cell & instances abutment boxes") );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CellViewer::createMenus ()
|
||||
{
|
||||
if ( _fileMenu ) return;
|
||||
if ( !_openAction ) createActions ();
|
||||
|
||||
_fileMenu = menuBar()->addMenu ( tr("File") );
|
||||
_fileMenu->addAction ( _openAction );
|
||||
_fileMenu->addAction ( _nextCellAction );
|
||||
_fileMenu->addAction ( _previousCellAction );
|
||||
_fileMenu->addAction ( _nextAction );
|
||||
_fileMenu->addAction ( _saveAction );
|
||||
_fileMenu->addAction ( _exitAction );
|
||||
|
||||
_viewMenu = menuBar()->addMenu ( tr("View") );
|
||||
_viewMenu->addAction ( _refreshAction );
|
||||
_viewMenu->addAction ( _fitToContentsAction );
|
||||
_viewMenu->addAction ( _showBoundariesAction );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CellViewer::createLayout ( Cell* cell )
|
||||
{
|
||||
if ( _cellWidget ) return;
|
||||
|
||||
_cellWidget = new CellWidget ( cell );
|
||||
_palette = _cellWidget->getPalette();
|
||||
//_mapView = _cellWidget->getMapView ();
|
||||
|
||||
setCorner ( Qt::TopLeftCorner , Qt::LeftDockWidgetArea );
|
||||
setCorner ( Qt::BottomLeftCorner , Qt::LeftDockWidgetArea );
|
||||
setCorner ( Qt::TopRightCorner , Qt::RightDockWidgetArea );
|
||||
setCorner ( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
||||
|
||||
// QDockWidget* mapViewDock = new QDockWidget ( tr("Map") );
|
||||
// mapViewDock->setObjectName ( "MapView" );
|
||||
// mapViewDock->setWidget ( _mapView );
|
||||
// mapViewDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
// addDockWidget ( Qt::RightDockWidgetArea, mapViewDock );
|
||||
|
||||
QDockWidget* layerMapDock = new QDockWidget ( tr("Layers") );
|
||||
layerMapDock->setObjectName ( "Palette" );
|
||||
layerMapDock->setWidget ( _palette );
|
||||
layerMapDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||
addDockWidget ( Qt::RightDockWidgetArea, layerMapDock );
|
||||
|
||||
setCentralWidget ( _cellWidget );
|
||||
|
||||
connect ( _refreshAction , SIGNAL(triggered()) , _cellWidget, SLOT(redraw ()) );
|
||||
connect ( _fitToContentsAction , SIGNAL(triggered()) , _cellWidget, SLOT(fitToContents()) );
|
||||
|
||||
_showBoundariesAction->setChecked ( _cellWidget->showBoundaries() );
|
||||
connect ( _showBoundariesAction, SIGNAL(toggled(bool)), _cellWidget, SLOT(setShowBoundaries(bool)) );
|
||||
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,64 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __CELL_VIEWER_H__
|
||||
# define __CELL_VIEWER_H__
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
# include <QMainWindow>
|
||||
|
||||
class QKeyEvent;
|
||||
class QAction;
|
||||
class QMenu;
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class Cell;
|
||||
class Palette;
|
||||
//class MapView;
|
||||
class CellWidget;
|
||||
|
||||
|
||||
class CellViewer : public QMainWindow {
|
||||
Q_OBJECT;
|
||||
|
||||
protected:
|
||||
QAction* _openAction;
|
||||
QAction* _nextCellAction;
|
||||
QAction* _previousCellAction;
|
||||
QAction* _nextAction;
|
||||
QAction* _saveAction;
|
||||
QAction* _exitAction;
|
||||
QAction* _refreshAction;
|
||||
QAction* _fitToContentsAction;
|
||||
QAction* _showBoundariesAction;
|
||||
QMenu* _fileMenu;
|
||||
QMenu* _viewMenu;
|
||||
//MapView* _mapView;
|
||||
Palette* _palette;
|
||||
CellWidget* _cellWidget;
|
||||
|
||||
public:
|
||||
CellViewer ( Cell* cell );
|
||||
|
||||
protected:
|
||||
void createActions ();
|
||||
void createMenus ();
|
||||
void createLayout ( Cell* cell );
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,12 @@
|
|||
<RCC>
|
||||
<qresource>
|
||||
<file>images/stock_open.png</file>
|
||||
<file>images/stock_save.png</file>
|
||||
<file>images/palette_show_all.png</file>
|
||||
<file>images/palette_hide_all.png</file>
|
||||
<file>images/gtk-go-up.png</file>
|
||||
<file>images/gtk-go-down.png</file>
|
||||
<file>images/gtk-go-forward-rtl.png</file>
|
||||
<file>images/gtk-go-forward-ltr.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
|
@ -0,0 +1,665 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QMouseEvent>
|
||||
# include <QKeyEvent>
|
||||
# include <QAction>
|
||||
# include <QPainter>
|
||||
# include <QStylePainter>
|
||||
# include <QBitmap>
|
||||
|
||||
# include "DataBase.h"
|
||||
# include "Technology.h"
|
||||
# include "BasicLayer.h"
|
||||
# include "Cell.h"
|
||||
# include "Instance.h"
|
||||
# include "Slice.h"
|
||||
# include "Segment.h"
|
||||
# include "Contact.h"
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "PaletteEntry.h"
|
||||
# include "Palette.h"
|
||||
// # include "MapView.h"
|
||||
# include "CellWidget.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
const int CellWidget::_stripWidth = 100;
|
||||
|
||||
|
||||
|
||||
|
||||
CellWidget::CellWidget ( Cell* cell ) : QWidget()
|
||||
, _palette(NULL)
|
||||
, _displayArea(0,0,6*_stripWidth,6*_stripWidth)
|
||||
, _visibleArea(_stripWidth,_stripWidth,4*_stripWidth,4*_stripWidth)
|
||||
, _scale(1.0)
|
||||
, _offsetVA(_stripWidth,_stripWidth)
|
||||
, _drawingBuffer(6*_stripWidth,6*_stripWidth)
|
||||
, _painter()
|
||||
, _lastMousePosition(0,0)
|
||||
, _cell(cell)
|
||||
, _mouseGo(false)
|
||||
, _openCell(true)
|
||||
, _showBoundaries(true)
|
||||
, _redrawRectCount(0)
|
||||
{
|
||||
//setBackgroundRole ( QPalette::Dark );
|
||||
//setAutoFillBackground ( false );
|
||||
setAttribute ( Qt::WA_OpaquePaintEvent );
|
||||
//setAttribute ( Qt::WA_NoSystemBackground );
|
||||
//setAttribute ( Qt::WA_PaintOnScreen );
|
||||
//setAttribute ( Qt::WA_StaticContents );
|
||||
setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Expanding );
|
||||
setFocusPolicy ( Qt::StrongFocus );
|
||||
|
||||
//_mapView = new MapView ( this );
|
||||
_palette = new Palette ( this );
|
||||
|
||||
fitToContents ();
|
||||
_openCell = false;
|
||||
}
|
||||
|
||||
|
||||
CellWidget::~CellWidget ()
|
||||
{
|
||||
cerr << "CellWidget::~CellWidget()" << endl;
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::pushCursor ( Qt::CursorShape cursor )
|
||||
{
|
||||
setCursor ( cursor );
|
||||
_cursors.push_back ( cursor );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::popCursor ()
|
||||
{
|
||||
_cursors.pop_back ();
|
||||
if ( !_cursors.empty() )
|
||||
setCursor ( _cursors.back() );
|
||||
else
|
||||
unsetCursor ();
|
||||
}
|
||||
|
||||
|
||||
QSize CellWidget::minimumSizeHint () const
|
||||
{
|
||||
return QSize(_stripWidth*4,_stripWidth*4);
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::redraw ( QRect redrawArea )
|
||||
{
|
||||
_redrawRectCount = 0;
|
||||
|
||||
pushCursor ( Qt::BusyCursor );
|
||||
|
||||
_painter.begin ( &_drawingBuffer );
|
||||
|
||||
_painter.setPen ( Qt::NoPen );
|
||||
_painter.setBackground ( Graphics::getBrush("background") );
|
||||
_painter.setClipRect ( redrawArea );
|
||||
_painter.eraseRect ( redrawArea );
|
||||
|
||||
Box redrawBox = getBox ( redrawArea );
|
||||
|
||||
vector<PaletteEntry*>& paletteEntries = _palette->getEntries ();
|
||||
for ( size_t i=0 ; i<paletteEntries.size() ; i++ ) {
|
||||
_painter.setPen ( Graphics::getPen (paletteEntries[i]->getName()) );
|
||||
_painter.setBrush ( Graphics::getBrush(paletteEntries[i]->getName()) );
|
||||
|
||||
if ( paletteEntries[i]->isBasicLayer() && isDrawable(paletteEntries[i]) ) {
|
||||
drawCell ( _cell, paletteEntries[i]->getBasicLayer(), redrawBox, Transformation() );
|
||||
} else if ( (paletteEntries[i]->getName() == DisplayStyle::Boundaries)
|
||||
&& paletteEntries[i]->isChecked() ) {
|
||||
drawBoundaries ( _cell, redrawBox, Transformation() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_painter.end ();
|
||||
|
||||
update ();
|
||||
popCursor ();
|
||||
|
||||
cerr << "Redrawed rectangles: " << _redrawRectCount << endl;
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawBoundaries ( const Cell* cell
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
drawBox ( transformation.getBox(cell->getAbutmentBox()) );
|
||||
for_each_instance ( instance, cell->getInstances() ) {
|
||||
drawBoundaries ( instance, redrawArea, transformation );
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawBoundaries ( const Instance* instance
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
Box masterArea = redrawArea;
|
||||
Transformation masterTransformation = instance->getTransformation();
|
||||
|
||||
instance->getTransformation().getInvert().applyOn ( masterArea );
|
||||
transformation.applyOn ( masterTransformation );
|
||||
|
||||
drawBoundaries ( instance->getMasterCell(), masterArea, masterTransformation );
|
||||
}
|
||||
|
||||
|
||||
bool CellWidget::isDrawable ( PaletteEntry* entry )
|
||||
{
|
||||
return entry->isChecked()
|
||||
&& ( entry->getBasicLayer()->getDisplayThreshold() < _scale*100 );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawCell ( const Cell* cell
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
for_each_instance ( instance, cell->getInstancesUnder(redrawArea) ) {
|
||||
drawInstance ( instance, basicLayer, redrawArea, transformation );
|
||||
end_for;
|
||||
}
|
||||
|
||||
for_each_slice ( slice, cell->getSlices() ) {
|
||||
drawSlice ( slice, basicLayer, redrawArea, transformation );
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawInstance ( const Instance* instance
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
Box masterArea = redrawArea;
|
||||
Transformation masterTransformation = instance->getTransformation();
|
||||
|
||||
instance->getTransformation().getInvert().applyOn ( masterArea );
|
||||
transformation.applyOn ( masterTransformation );
|
||||
|
||||
drawCell ( instance->getMasterCell(), basicLayer, masterArea, masterTransformation );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawSlice ( const Slice* slice
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
if ( slice->getLayer()->contains(basicLayer) ) {
|
||||
if ( slice->getBoundingBox().intersect(redrawArea) ) {
|
||||
for_each_go ( go, slice->getGosUnder(redrawArea) ) {
|
||||
drawGo ( go, basicLayer, redrawArea, transformation );
|
||||
end_for;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawGo ( const Go* go
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
const Segment* segment = dynamic_cast<const Segment*>(go);
|
||||
if (segment) {
|
||||
drawSegment ( segment, basicLayer, redrawArea, transformation );
|
||||
return;
|
||||
}
|
||||
|
||||
const Contact* contact = dynamic_cast<const Contact*>(go);
|
||||
if (contact) {
|
||||
drawContact ( contact, basicLayer, redrawArea, transformation );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawSegment ( const Segment* segment
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
if ( 1 < getScreenLength(segment->getWidth()) ) {
|
||||
drawBox ( transformation.getBox(segment->getBoundingBox(basicLayer)) );
|
||||
} else {
|
||||
drawLine ( transformation.getPoint(segment->getSourcePosition()),
|
||||
transformation.getPoint(segment->getTargetPosition()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawContact ( const Contact* contact
|
||||
, const BasicLayer* basicLayer
|
||||
, const Box& redrawArea
|
||||
, const Transformation& transformation
|
||||
)
|
||||
{
|
||||
drawBox ( transformation.getBox(contact->getBoundingBox(basicLayer)) );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawBox ( const Box& box )
|
||||
{
|
||||
_redrawRectCount++;
|
||||
_painter.drawRect ( getScreenRect(box) );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::drawLine ( const Point& p1, const Point& p2 )
|
||||
{
|
||||
_painter.drawLine ( getScreenPoint(p1), getScreenPoint(p2) );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::goLeft ( int dx )
|
||||
{
|
||||
if ( !dx ) dx = geometry().size().width() / 4;
|
||||
if ( _offsetVA.rx() - dx >= 0 ) {
|
||||
_offsetVA.rx() -= dx;
|
||||
update ();
|
||||
} else {
|
||||
shiftLeft ( dx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::goRight ( int dx )
|
||||
{
|
||||
if ( !dx ) dx = geometry().size().width() / 4;
|
||||
|
||||
//cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||
|
||||
if ( _offsetVA.rx() + dx < 2*_stripWidth ) {
|
||||
_offsetVA.rx() += dx;
|
||||
update ();
|
||||
} else {
|
||||
shiftRight ( dx );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::goUp ( int dy )
|
||||
{
|
||||
if ( !dy ) dy = geometry().size().height() / 4;
|
||||
if ( _offsetVA.ry() - dy >= 0 ) {
|
||||
_offsetVA.ry() -= dy;
|
||||
update ();
|
||||
} else {
|
||||
shiftUp ( dy );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::goDown ( int dy )
|
||||
{
|
||||
if ( !dy ) dy = geometry().size().height() / 4;
|
||||
if ( _offsetVA.ry() + dy < 2*_stripWidth ) {
|
||||
_offsetVA.ry() += dy;
|
||||
update ();
|
||||
} else {
|
||||
shiftDown ( dy );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::screenReframe ()
|
||||
{
|
||||
_offsetVA.rx() = _stripWidth;
|
||||
_offsetVA.ry() = _stripWidth;
|
||||
|
||||
Unit xmin = (Unit)( _visibleArea.getXMin() - ((float)_offsetVA.x()/_scale) );
|
||||
Unit xmax = (Unit)( xmin + ((float)_drawingBuffer.width()/_scale) ) ;
|
||||
Unit ymax = (Unit)( _visibleArea.getYMax() + ((float)_offsetVA.y()/_scale) );
|
||||
Unit ymin = (Unit)( ymax - ((float)_drawingBuffer.height()/_scale) ) ;
|
||||
|
||||
_displayArea = Box ( xmin, ymin, xmax, ymax );
|
||||
|
||||
redraw ();
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::setScale ( float scale )
|
||||
{
|
||||
_scale = scale;
|
||||
|
||||
Point center = _visibleArea.getCenter();
|
||||
|
||||
_visibleArea.makeEmpty ();
|
||||
_visibleArea.merge ( (Unit)( center.getX() - width () / (_scale*2) )
|
||||
, (Unit)( center.getY() - height() / (_scale*2) )
|
||||
, (Unit)( center.getX() + width () / (_scale*2) )
|
||||
, (Unit)( center.getY() + height() / (_scale*2) )
|
||||
);
|
||||
|
||||
//cerr << "_visibleArea: " << _visibleArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
||||
//cerr << " " << center << endl;
|
||||
|
||||
screenReframe ();
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::reframe ( const Box& box )
|
||||
{
|
||||
//cerr << "CellWidget::reframe() - " << box << endl;
|
||||
//cerr << " widget size := " << _drawingBuffer.width() << "x" << _drawingBuffer.height() << endl;
|
||||
|
||||
int width = this->width ();
|
||||
int height = this->height ();
|
||||
|
||||
float scaleX = width / (float)box.getWidth ();
|
||||
float scaleY = height / (float)box.getHeight();
|
||||
_scale = min ( scaleX, scaleY );
|
||||
|
||||
//cerr << " _scale := " << _scale << endl;
|
||||
|
||||
Point center = box.getCenter();
|
||||
|
||||
width /= 2;
|
||||
height /= 2;
|
||||
|
||||
_visibleArea = Box ( (Unit)( center.getX() - width / _scale )
|
||||
, (Unit)( center.getY() - height / _scale )
|
||||
, (Unit)( center.getX() + width / _scale )
|
||||
, (Unit)( center.getY() + height / _scale )
|
||||
);
|
||||
screenReframe ();
|
||||
|
||||
//cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::fitToContents ()
|
||||
{
|
||||
reframe ( _cell->getBoundingBox() );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::shiftLeft ( int dx )
|
||||
{
|
||||
//cerr << "CellWidget::shiftLeft() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||
|
||||
int leftShift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth;
|
||||
|
||||
_displayArea.translate ( - (Unit)( leftShift / _scale ) , 0 );
|
||||
_visibleArea.translate ( - (Unit)( leftShift / _scale ) , 0 );
|
||||
_offsetVA.rx() -= dx - leftShift;
|
||||
|
||||
if ( leftShift >= _drawingBuffer.width() ) {
|
||||
redraw ();
|
||||
} else {
|
||||
//cerr << "Left Shift " << leftShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||
_painter.begin ( &_drawingBuffer );
|
||||
_painter.drawPixmap ( leftShift, 0
|
||||
, _drawingBuffer
|
||||
, 0, 0
|
||||
, _drawingBuffer.width()-leftShift, _drawingBuffer.height()
|
||||
);
|
||||
_painter.end ();
|
||||
|
||||
redraw ( QRect ( QPoint ( 0, 0 )
|
||||
, QSize ( leftShift, _drawingBuffer.height() )) );
|
||||
}
|
||||
|
||||
assert ( _offsetVA.rx() >= 0 );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::shiftRight ( int dx )
|
||||
{
|
||||
//cerr << "CellWidget::shiftRight() - " << dx << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||
|
||||
int rightShift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth;
|
||||
|
||||
_displayArea.translate ( (Unit)( rightShift / _scale ) , 0 );
|
||||
_visibleArea.translate ( (Unit)( rightShift / _scale ) , 0 );
|
||||
_offsetVA.rx() += dx - rightShift;
|
||||
|
||||
//cerr << " _displayArea: " << _displayArea << endl;
|
||||
|
||||
if ( rightShift >= _drawingBuffer.width() ) {
|
||||
redraw ();
|
||||
} else {
|
||||
//cerr << " Right Shift " << rightShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||
_painter.begin ( &_drawingBuffer );
|
||||
_painter.drawPixmap ( 0, 0
|
||||
, _drawingBuffer
|
||||
, rightShift, 0
|
||||
, _drawingBuffer.width()-rightShift, _drawingBuffer.height()
|
||||
);
|
||||
_painter.end ();
|
||||
|
||||
redraw ( QRect ( QPoint ( _drawingBuffer.width()-rightShift, 0 )
|
||||
, QSize ( rightShift, _drawingBuffer.height() )) );
|
||||
}
|
||||
|
||||
assert ( _offsetVA.rx() >= 0 );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::shiftUp ( int dy )
|
||||
{
|
||||
//cerr << "CellWidget::shiftUp() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||
|
||||
int upShift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth;
|
||||
|
||||
_displayArea.translate ( 0, (Unit)( upShift / _scale ) );
|
||||
_visibleArea.translate ( 0, (Unit)( upShift / _scale ) );
|
||||
_offsetVA.ry() -= dy - upShift;
|
||||
|
||||
if ( upShift >= _drawingBuffer.height() ) {
|
||||
redraw ();
|
||||
} else {
|
||||
//cerr << "Left Shift " << upShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||
_painter.begin ( &_drawingBuffer );
|
||||
_painter.drawPixmap ( 0, upShift
|
||||
, _drawingBuffer
|
||||
, 0, 0
|
||||
, _drawingBuffer.width(), _drawingBuffer.height()-upShift
|
||||
);
|
||||
_painter.end ();
|
||||
|
||||
redraw ( QRect ( QPoint ( 0, 0 )
|
||||
, QSize ( _drawingBuffer.width(), upShift )) );
|
||||
}
|
||||
|
||||
assert ( _offsetVA.ry() >= 0 );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::shiftDown ( int dy )
|
||||
{
|
||||
//cerr << "CellWidget::shiftDown() - " << dy << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||
|
||||
int downShift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth;
|
||||
|
||||
_displayArea.translate ( 0, - (Unit)( downShift / _scale ) );
|
||||
_visibleArea.translate ( 0, - (Unit)( downShift / _scale ) );
|
||||
_offsetVA.ry() += dy - downShift;
|
||||
|
||||
if ( downShift >= _drawingBuffer.height() ) {
|
||||
redraw ();
|
||||
} else {
|
||||
//cerr << "Right Shift " << downShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||
_painter.begin ( &_drawingBuffer );
|
||||
_painter.drawPixmap ( 0, 0
|
||||
, _drawingBuffer
|
||||
, 0, downShift
|
||||
, _drawingBuffer.width(), _drawingBuffer.height()-downShift
|
||||
);
|
||||
_painter.end ();
|
||||
|
||||
redraw ( QRect ( QPoint ( 0, _drawingBuffer.height()-downShift )
|
||||
, QSize ( _drawingBuffer.width(), downShift )) );
|
||||
}
|
||||
|
||||
assert ( _offsetVA.ry() >= 0 );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::paintEvent ( QPaintEvent* )
|
||||
{
|
||||
//cerr << "CellWidget::paintEvent()" << endl;
|
||||
|
||||
QPainter painter ( this );
|
||||
painter.drawPixmap ( 0, 0, _drawingBuffer, _offsetVA.rx(), _offsetVA.ry(), width(), height() );
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::resizeEvent ( QResizeEvent* )
|
||||
{
|
||||
QSize uaDelta ( 0, 0 );
|
||||
QSize uaSize = geometry().size();
|
||||
|
||||
uaSize.rwidth () += 2*_stripWidth;
|
||||
uaSize.rheight() += 2*_stripWidth;
|
||||
|
||||
if ( uaSize.width () > _drawingBuffer.width () )
|
||||
uaDelta.rwidth () = uaSize.width () - _drawingBuffer.width ();
|
||||
|
||||
if ( uaSize.height() > _drawingBuffer.height() )
|
||||
uaDelta.rheight() = uaSize.height() - _drawingBuffer.height();
|
||||
|
||||
//cerr << "New UA widget size: " << uaSize.width() << "x" << uaSize.height() << endl;
|
||||
|
||||
if ( uaDelta.width() || uaDelta.height() ) {
|
||||
_displayArea.inflate ( 0, 0, (Unit)(uaDelta.width()/_scale), (Unit)(uaDelta.height()/_scale) );
|
||||
_visibleArea.inflate ( 0, 0, (Unit)(uaDelta.width()/_scale), (Unit)(uaDelta.height()/_scale) );
|
||||
//cerr << "new " << _displayArea << endl;
|
||||
|
||||
//cerr << "Previous buffer size: " << _drawingBuffer.width () << "x"
|
||||
// << _drawingBuffer.height() << endl;
|
||||
|
||||
QSize bufferSize ( ( ( uaSize.width () / _stripWidth ) + 1 ) * _stripWidth
|
||||
, ( ( uaSize.height() / _stripWidth ) + 1 ) * _stripWidth );
|
||||
_drawingBuffer = QPixmap ( bufferSize );
|
||||
|
||||
//cerr << "Effective buffer resize to: " << bufferSize.width() << "x"
|
||||
// << bufferSize.height() << endl;
|
||||
}
|
||||
redraw ();
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::keyPressEvent ( QKeyEvent* event )
|
||||
{
|
||||
switch ( event->key() ) {
|
||||
case Qt::Key_Up: goUp (); break;
|
||||
case Qt::Key_Down: goDown (); break;
|
||||
case Qt::Key_Left: goLeft (); break;
|
||||
case Qt::Key_Right: goRight (); break;
|
||||
case Qt::Key_Z: setScale ( _scale*2.0 ); break;
|
||||
case Qt::Key_M: setScale ( _scale/2.0 ); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::mouseMoveEvent ( QMouseEvent* event )
|
||||
{
|
||||
//cerr << "CellWidget::mouseMoveEvent()" << endl;
|
||||
|
||||
if ( _mouseGo ) {
|
||||
int dx = event->x() - _lastMousePosition.x();
|
||||
dx <<= 1;
|
||||
//cerr << "dX (px): " << dx << " _offsetVA.rx() " << _offsetVA.rx() << endl;
|
||||
if ( dx > 0 ) goLeft ( dx );
|
||||
if ( dx < 0 ) goRight ( -dx );
|
||||
|
||||
int dy = event->y() - _lastMousePosition.y();
|
||||
dy <<= 1;
|
||||
//cerr << "dY (px): " << dy << " _offsetVA.ry() " << _offsetVA.ry() << endl;
|
||||
if ( dy > 0 ) goUp ( dy );
|
||||
if ( dy < 0 ) goDown ( -dy );
|
||||
|
||||
_lastMousePosition = event->pos();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::mousePressEvent ( QMouseEvent* event )
|
||||
{
|
||||
if ( ( event->button() == Qt::LeftButton ) && !_mouseGo ) {
|
||||
_mouseGo = true;
|
||||
_lastMousePosition = event->pos();
|
||||
pushCursor ( Qt::ClosedHandCursor );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::mouseReleaseEvent ( QMouseEvent* event )
|
||||
{
|
||||
if ( ( event->button() == Qt::LeftButton ) && _mouseGo ) {
|
||||
_mouseGo = false;
|
||||
popCursor ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QPoint CellWidget::getScreenPoint ( Unit x, Unit y ) const
|
||||
{
|
||||
return QPoint ( getScreenX(x), getScreenY(y) );
|
||||
}
|
||||
|
||||
|
||||
QPoint CellWidget::getScreenPoint ( const Point& point ) const
|
||||
{
|
||||
return getScreenPoint ( point.getX(), point.getY() );
|
||||
}
|
||||
|
||||
|
||||
QRect CellWidget::getScreenRect ( Unit x1, Unit y1, Unit x2, Unit y2 ) const
|
||||
{
|
||||
return QRect ( getScreenX(x1)
|
||||
, getScreenY(y2)
|
||||
, getScreenX(x2) - getScreenX(x1)
|
||||
, getScreenY(y1) - getScreenY(y2)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
QRect CellWidget::getScreenRect ( const Box& box ) const
|
||||
{
|
||||
return getScreenRect ( box.getXMin()
|
||||
, box.getYMin()
|
||||
, box.getXMax()
|
||||
, box.getYMax()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void CellWidget::setShowBoundaries ( bool state )
|
||||
{
|
||||
if ( _showBoundaries != state ) {
|
||||
_showBoundaries = state;
|
||||
redraw ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,221 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __CELL_WIDGET_H__
|
||||
# define __CELL_WIDGET_H__
|
||||
|
||||
# include <math.h>
|
||||
|
||||
# include <vector>
|
||||
|
||||
# include <QWidget>
|
||||
# include <QPixmap>
|
||||
# include <QPainter>
|
||||
# include <QRect>
|
||||
# include <QPoint>
|
||||
|
||||
class QCursor;
|
||||
class QResizeEvent;
|
||||
class QMouseEvent;
|
||||
class QKeyEvent;
|
||||
class QAction;
|
||||
|
||||
|
||||
# include "Commons.h"
|
||||
# include "Point.h"
|
||||
# include "Box.h"
|
||||
# include "Transformation.h"
|
||||
|
||||
# include "DisplayStyle.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
class BasicLayer;
|
||||
class Go;
|
||||
class Cell;
|
||||
class Instance;
|
||||
class Slice;
|
||||
class Segment;
|
||||
class Contact;
|
||||
|
||||
class PaletteEntry;
|
||||
class Palette;
|
||||
//class MapView;
|
||||
|
||||
|
||||
class CellWidget : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
||||
// Attributes.
|
||||
protected:
|
||||
static const int _stripWidth;
|
||||
vector<Qt::CursorShape> _cursors;
|
||||
// MapView* _mapView;
|
||||
Palette* _palette;
|
||||
Box _displayArea;
|
||||
Box _visibleArea;
|
||||
float _scale;
|
||||
QPoint _offsetVA;
|
||||
QPixmap _drawingBuffer;
|
||||
QPainter _painter;
|
||||
QPoint _lastMousePosition;
|
||||
Cell* _cell;
|
||||
bool _mouseGo;
|
||||
bool _openCell;
|
||||
bool _showBoundaries;
|
||||
size_t _redrawRectCount;
|
||||
|
||||
public:
|
||||
CellWidget ( Cell* cell );
|
||||
virtual ~CellWidget ();
|
||||
|
||||
public slots:
|
||||
void redraw ( QRect redrawArea );
|
||||
inline void redraw ();
|
||||
void goLeft ( int dx = 0 );
|
||||
void goRight ( int dx = 0 );
|
||||
void goUp ( int dy = 0 );
|
||||
void goDown ( int dy = 0 );
|
||||
void fitToContents ();
|
||||
void setScale ( float scale );
|
||||
void setShowBoundaries ( bool state );
|
||||
void reframe ( const Box& box );
|
||||
void screenReframe ();
|
||||
void shiftLeft ( int dx );
|
||||
void shiftRight ( int dx );
|
||||
void shiftUp ( int dy );
|
||||
void shiftDown ( int dy );
|
||||
|
||||
// Qt QWidget Overloads.
|
||||
public:
|
||||
void pushCursor ( Qt::CursorShape cursor );
|
||||
void popCursor ();
|
||||
QSize minimumSizeHint () const;
|
||||
void paintEvent ( QPaintEvent* );
|
||||
void resizeEvent ( QResizeEvent* );
|
||||
void keyPressEvent ( QKeyEvent* );
|
||||
void mouseMoveEvent ( QMouseEvent* );
|
||||
void mousePressEvent ( QMouseEvent* );
|
||||
void mouseReleaseEvent ( QMouseEvent* );
|
||||
|
||||
// Geometric conversions.
|
||||
public:
|
||||
QRect getScreenRect ( Unit x1, Unit y1, Unit x2, Unit y2 ) const;
|
||||
QRect getScreenRect ( const Box& box ) const;
|
||||
QPoint getScreenPoint ( Unit x, Unit y ) const;
|
||||
QPoint getScreenPoint ( const Point& point ) const;
|
||||
inline int getScreenX ( Unit x ) const;
|
||||
inline int getScreenY ( Unit y ) const;
|
||||
inline int getScreenLength ( Unit length ) const;
|
||||
inline Unit getX ( int x ) const;
|
||||
inline Unit getY ( int y ) const;
|
||||
inline Unit getLength ( int length ) const;
|
||||
inline Box getBox ( const QRect& rect ) const;
|
||||
|
||||
// Painter control & Hurricane objects drawing primitives.
|
||||
public:
|
||||
void drawBoundaries ( const Cell* , const Box&, const Transformation& );
|
||||
void drawBoundaries ( const Instance*, const Box&, const Transformation& );
|
||||
bool isDrawable ( PaletteEntry* entry );
|
||||
void drawCell ( const Cell* , const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawInstance ( const Instance*, const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawSlice ( const Slice* , const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawGo ( const Go* , const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawSegment ( const Segment* , const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawContact ( const Contact* , const BasicLayer*, const Box&, const Transformation& );
|
||||
void drawBox ( const Box& );
|
||||
void drawLine ( const Point&, const Point& );
|
||||
|
||||
// Accessors.
|
||||
public:
|
||||
// MapView* getMapView () { return _mapView; };
|
||||
inline Cell* getCell () const;
|
||||
inline Palette* getPalette ();
|
||||
inline bool showBoundaries () const;
|
||||
|
||||
// Modifiers.
|
||||
public:
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
inline void CellWidget::redraw ()
|
||||
{
|
||||
redraw ( QRect(QPoint(0,0),_drawingBuffer.size()) );
|
||||
}
|
||||
|
||||
|
||||
inline int CellWidget::getScreenX ( Unit x ) const
|
||||
{
|
||||
return (int)rint ( (float)( x - _displayArea.getXMin() ) * _scale );
|
||||
}
|
||||
|
||||
|
||||
inline int CellWidget::getScreenY ( Unit y ) const
|
||||
{
|
||||
return (int)rint ( (float)( _displayArea.getYMax() - y ) * _scale );
|
||||
}
|
||||
|
||||
|
||||
inline int CellWidget::getScreenLength ( Unit length ) const
|
||||
{
|
||||
return (int)rint ( (float)length * _scale );
|
||||
}
|
||||
|
||||
|
||||
inline Unit CellWidget::getX ( int x ) const
|
||||
{
|
||||
return (Unit)(x/_scale) + _displayArea.getXMin();
|
||||
}
|
||||
|
||||
|
||||
inline Unit CellWidget::getY ( int y ) const
|
||||
{
|
||||
return _displayArea.getYMax() - (Unit)(y/_scale);
|
||||
}
|
||||
|
||||
|
||||
inline Unit CellWidget::getLength ( int length ) const
|
||||
{
|
||||
return (int)( (float)length / _scale );
|
||||
}
|
||||
|
||||
|
||||
inline Box CellWidget::getBox ( const QRect& rect ) const
|
||||
{
|
||||
return Box ( getX(rect.x())
|
||||
, getY(rect.y())
|
||||
, getX(rect.x()+rect.width ())
|
||||
, getY(rect.y()+rect.height()));
|
||||
}
|
||||
|
||||
|
||||
inline Cell* CellWidget::getCell () const
|
||||
{
|
||||
return _cell;
|
||||
}
|
||||
|
||||
|
||||
inline Palette* CellWidget::getPalette ()
|
||||
{
|
||||
return _palette;
|
||||
}
|
||||
|
||||
|
||||
inline bool CellWidget::showBoundaries () const
|
||||
{
|
||||
return _showBoundaries;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,303 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <cassert>
|
||||
|
||||
# include "DisplayStyle.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
const Name DisplayStyle::UnmatchedGroup;
|
||||
const Name DisplayStyle::Viewer = "Viewer";
|
||||
const Name DisplayStyle::Fallback = "fallback";
|
||||
const Name DisplayStyle::Background = "background";
|
||||
const Name DisplayStyle::Foreground = "foreground";
|
||||
const Name DisplayStyle::Rubber = "rubber";
|
||||
const Name DisplayStyle::Phantom = "phantom";
|
||||
const Name DisplayStyle::Boundaries = "boundaries";
|
||||
const Name DisplayStyle::Marker = "marker";
|
||||
const Name DisplayStyle::SelectionDraw = "selectionDraw";
|
||||
const Name DisplayStyle::SelectionFill = "selectionFill";
|
||||
const Name DisplayStyle::Grid = "grid";
|
||||
const Name DisplayStyle::Spot = "spot";
|
||||
const Name DisplayStyle::Ghost = "ghost";
|
||||
const Name DisplayStyle::Text = "text";
|
||||
const Name DisplayStyle::Undef = "undef";
|
||||
|
||||
|
||||
|
||||
DrawingStyle::DrawingStyle ( const Name& name
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
) : _name(name)
|
||||
, _pattern(pattern)
|
||||
, _color(QColor(red,green,blue))
|
||||
, _pen(_color)
|
||||
, _brush(Hurricane::getBrush(_pattern,red,green,blue))
|
||||
, _threshold(threshold)
|
||||
, _refcount(1)
|
||||
{
|
||||
if ( borderWidth )
|
||||
_pen.setWidth ( borderWidth );
|
||||
else
|
||||
_pen.setStyle ( Qt::NoPen );
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawingStyle* DrawingStyle::create ( const Name& name
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
)
|
||||
{
|
||||
return new DrawingStyle ( name, pattern, red, green, blue, borderWidth, threshold );
|
||||
}
|
||||
|
||||
|
||||
DrawingStyle::~DrawingStyle ()
|
||||
{
|
||||
assert ( _refcount == 0 );
|
||||
}
|
||||
|
||||
|
||||
size_t DrawingStyle::unlink ()
|
||||
{
|
||||
_refcount--;
|
||||
|
||||
if ( !_refcount ) {
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return _refcount;
|
||||
}
|
||||
|
||||
|
||||
DrawingStyle* DrawingStyle::link ()
|
||||
{
|
||||
_refcount++;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
DrawingGroup::DrawingGroup ( const Name& name )
|
||||
: _name(name), _drawingStyles()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
DrawingGroup* DrawingGroup::getClone ()
|
||||
{
|
||||
DrawingGroup* clone = new DrawingGroup ( getName() );
|
||||
|
||||
for ( size_t i=0 ; i < _drawingStyles.size() ; i++ )
|
||||
clone->_drawingStyles.push_back ( _drawingStyles[i]->link() );
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
DrawingGroup::~DrawingGroup ()
|
||||
{
|
||||
for ( size_t i=0 ; i < _drawingStyles.size() ; i++ )
|
||||
_drawingStyles[i]->unlink ();
|
||||
}
|
||||
|
||||
|
||||
size_t DrawingGroup::findIndex ( const Name& key ) const
|
||||
{
|
||||
for ( size_t i=0 ; i < _drawingStyles.size() ; i++ ) {
|
||||
if ( _drawingStyles[i]->getName() == key )
|
||||
return i;
|
||||
}
|
||||
|
||||
return InvalidIndex;
|
||||
}
|
||||
|
||||
|
||||
DrawingStyle* DrawingGroup::find ( const Name& key )
|
||||
{
|
||||
size_t i = findIndex ( key );
|
||||
if ( i != InvalidIndex )
|
||||
return _drawingStyles[i];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
DrawingStyle* DrawingGroup::addDrawingStyle ( const Name& key
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
)
|
||||
{
|
||||
size_t i = findIndex ( key );
|
||||
if ( i != InvalidIndex ) {
|
||||
_drawingStyles[i]->unlink ();
|
||||
} else {
|
||||
i = _drawingStyles.size ();
|
||||
_drawingStyles.push_back ( NULL );
|
||||
}
|
||||
|
||||
return _drawingStyles[i] =
|
||||
DrawingStyle::create ( key, pattern, red, green, blue, borderWidth, threshold );
|
||||
}
|
||||
|
||||
|
||||
DisplayStyle::DisplayStyle ( const Name& name )
|
||||
: _name(name), _groups()
|
||||
{
|
||||
addDrawingStyle ( Viewer, Fallback , "FFFFFFFFFFFFFFFF", 0, 0, 0, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Background , "FFFFFFFFFFFFFFFF", 50, 50, 50, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Foreground , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Rubber , "FFFFFFFFFFFFFFFF", 192, 0, 192, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Phantom , "FFFFFFFFFFFFFFFF", 139, 134, 130, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Boundaries , "0000000000000000", 208, 199, 192, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Marker , "FFFFFFFFFFFFFFFF", 80, 250, 80, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, SelectionDraw, "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, SelectionFill, "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Grid , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Spot , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Ghost , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1, 1.0 );
|
||||
addDrawingStyle ( Viewer, Text , "8822441188224411", 255, 255, 255, 0, 1.0 );
|
||||
addDrawingStyle ( Viewer, Undef , "2244118822441188", 238, 130, 238, 0, 1.0 );
|
||||
}
|
||||
|
||||
|
||||
DisplayStyle::~DisplayStyle ()
|
||||
{
|
||||
for ( size_t i=0 ; i < _groups.size() ; i++ ) {
|
||||
delete _groups[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const Name& DisplayStyle::getGroup ( const Name& key ) const
|
||||
{
|
||||
for ( size_t gi=0 ; gi < _groups.size() ; gi++ ) {
|
||||
DrawingStyle* style = _groups[gi]->find ( key );
|
||||
if ( style )
|
||||
return _groups[gi]->getName();
|
||||
}
|
||||
|
||||
return UnmatchedGroup;
|
||||
}
|
||||
|
||||
|
||||
const string& DisplayStyle::getPattern ( const Name& key ) const
|
||||
{
|
||||
return find(key)->getPattern();
|
||||
}
|
||||
|
||||
|
||||
const QColor& DisplayStyle::getColor ( const Name& key ) const
|
||||
{
|
||||
return find(key)->getColor();
|
||||
}
|
||||
|
||||
|
||||
const QPen& DisplayStyle::getPen ( const Name& key ) const
|
||||
{
|
||||
return find(key)->getPen();
|
||||
}
|
||||
|
||||
|
||||
const QBrush& DisplayStyle::getBrush ( const Name& key ) const
|
||||
{
|
||||
return find(key)->getBrush();
|
||||
}
|
||||
|
||||
|
||||
float DisplayStyle::getThreshold ( const Name& key ) const
|
||||
{
|
||||
return find(key)->getThreshold();
|
||||
}
|
||||
|
||||
|
||||
void DisplayStyle::findOrCreate ( const Name& groupKey, size_t& gi )
|
||||
{
|
||||
for ( gi=0 ; gi < _groups.size() ; gi++ ) {
|
||||
if ( _groups[gi]->getName() == groupKey )
|
||||
break;
|
||||
}
|
||||
if ( gi == _groups.size() )
|
||||
_groups.push_back ( new DrawingGroup(groupKey) );
|
||||
}
|
||||
|
||||
|
||||
void DisplayStyle::find ( const Name& groupKey
|
||||
, const Name& key
|
||||
, size_t& gi
|
||||
, size_t& si
|
||||
)
|
||||
{
|
||||
for ( gi=0 ; gi < _groups.size() ; gi++ ) {
|
||||
if ( _groups[gi]->getName() == groupKey ) {
|
||||
si = _groups[gi]->findIndex ( key );
|
||||
if ( si != InvalidIndex )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gi = InvalidIndex;
|
||||
si = InvalidIndex;
|
||||
}
|
||||
|
||||
|
||||
DrawingStyle* DisplayStyle::find ( const Name& key ) const
|
||||
{
|
||||
for ( size_t gi=0 ; gi < _groups.size() ; gi++ ) {
|
||||
DrawingStyle* style = _groups[gi]->find ( key );
|
||||
if ( style )
|
||||
return style;
|
||||
}
|
||||
|
||||
return find ( "fallback" );
|
||||
}
|
||||
|
||||
|
||||
void DisplayStyle::addDrawingStyle ( const Name& groupKey
|
||||
, const Name& key
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
)
|
||||
{
|
||||
size_t gi;
|
||||
findOrCreate ( groupKey, gi );
|
||||
|
||||
_groups[gi]->addDrawingStyle ( key, pattern, red, green, blue, borderWidth, threshold );
|
||||
}
|
||||
|
||||
|
||||
void DisplayStyle::inheritFrom ( const DisplayStyle* base )
|
||||
{
|
||||
assert ( base != NULL );
|
||||
|
||||
for ( size_t gi=0 ; gi < base->_groups.size() ; gi++ ) {
|
||||
_groups.push_back ( base->_groups[gi]->getClone() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,198 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __DISPLAYSTYLE_H__
|
||||
# define __DISPLAYSTYLE_H__
|
||||
|
||||
|
||||
# include <string>
|
||||
# include <map>
|
||||
|
||||
# include <QColor>
|
||||
# include <QPen>
|
||||
# include <QBrush>
|
||||
|
||||
# include "Commons.h"
|
||||
# include "Name.h"
|
||||
|
||||
# include "ScreenUtilities.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
|
||||
|
||||
class DrawingStyle {
|
||||
|
||||
public:
|
||||
// Constructors & Destructors.
|
||||
static DrawingStyle* create ( const Name& name
|
||||
, const string& pattern ="FFFFFFFFFFFFFFFF"
|
||||
, int red =0
|
||||
, int green =0
|
||||
, int blue =0
|
||||
, int borderWidth=0
|
||||
, float threshold =1.0
|
||||
);
|
||||
DrawingStyle* link ();
|
||||
size_t unlink ();
|
||||
|
||||
// Accessors.
|
||||
inline const Name& getName () const;
|
||||
inline const string& getPattern () const;
|
||||
inline const QColor& getColor () const;
|
||||
inline const QPen& getPen () const;
|
||||
inline const QBrush& getBrush () const;
|
||||
inline float getThreshold () const;
|
||||
|
||||
protected:
|
||||
// Internal - Attributes.
|
||||
const Name _name;
|
||||
string _pattern;
|
||||
QColor _color;
|
||||
QPen _pen;
|
||||
QBrush _brush;
|
||||
float _threshold;
|
||||
size_t _refcount;
|
||||
|
||||
// Internal - Constructors & Destructors.
|
||||
DrawingStyle ( const Name& name
|
||||
, const string& pattern ="FFFFFFFFFFFFFFFF"
|
||||
, int red =0
|
||||
, int green =0
|
||||
, int blue =0
|
||||
, int borderWidth=0
|
||||
, float threshold =1.0
|
||||
);
|
||||
DrawingStyle ( const DrawingStyle& );
|
||||
~DrawingStyle ();
|
||||
DrawingStyle& operator= ( const DrawingStyle& );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class DrawingGroup {
|
||||
|
||||
public:
|
||||
// Constructors & Destructors.
|
||||
DrawingGroup ( const Name& name );
|
||||
~DrawingGroup ();
|
||||
DrawingGroup* getClone ();
|
||||
|
||||
// Methods.
|
||||
inline const Name& getName () const;
|
||||
inline vector<DrawingStyle*>& getDrawingStyles ();
|
||||
size_t findIndex ( const Name& key ) const;
|
||||
DrawingStyle* find ( const Name& key );
|
||||
DrawingStyle* addDrawingStyle ( const Name& key
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
);
|
||||
|
||||
protected:
|
||||
// Internal - Attributes.
|
||||
const Name _name;
|
||||
vector<DrawingStyle*> _drawingStyles;
|
||||
|
||||
// Internal - Constructors & Destructors.
|
||||
DrawingGroup ( const DrawingGroup& );
|
||||
DrawingGroup& operator= ( const DrawingGroup& );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class DisplayStyle {
|
||||
|
||||
public:
|
||||
// Static Members.
|
||||
static const Name Viewer;
|
||||
static const Name Fallback;
|
||||
static const Name Background;
|
||||
static const Name Foreground;
|
||||
static const Name Rubber;
|
||||
static const Name Phantom;
|
||||
static const Name Boundaries;
|
||||
static const Name Marker;
|
||||
static const Name SelectionDraw;
|
||||
static const Name SelectionFill;
|
||||
static const Name Grid;
|
||||
static const Name Spot;
|
||||
static const Name Ghost;
|
||||
static const Name Text;
|
||||
static const Name Undef;
|
||||
static const Name UnmatchedGroup;
|
||||
|
||||
// Constructor & Destructor.
|
||||
DisplayStyle ( const Name& name );
|
||||
~DisplayStyle ();
|
||||
|
||||
// Accessors.
|
||||
const Name& getName () const;
|
||||
const Name& getGroup ( const Name& key ) const;
|
||||
const string& getPattern ( const Name& key ) const;
|
||||
const QColor& getColor ( const Name& key ) const;
|
||||
const QPen& getPen ( const Name& key ) const;
|
||||
const QBrush& getBrush ( const Name& key ) const;
|
||||
float getThreshold ( const Name& key ) const;
|
||||
inline vector<DrawingGroup*>& getDrawingGroups ();
|
||||
DrawingStyle* find ( const Name& key ) const;
|
||||
|
||||
// Modifiers.
|
||||
void inheritFrom ( const DisplayStyle* base );
|
||||
void addDrawingStyle ( const Name& groupKey
|
||||
, const Name& key
|
||||
, const string& pattern
|
||||
, int red
|
||||
, int green
|
||||
, int blue
|
||||
, int borderWidth
|
||||
, float threshold
|
||||
);
|
||||
|
||||
protected:
|
||||
// Internals - Attributes.
|
||||
const Name _name;
|
||||
vector<DrawingGroup*> _groups;
|
||||
|
||||
// Internals - Methods.
|
||||
void findOrCreate ( const Name& groupKey
|
||||
, size_t& gi );
|
||||
void find ( const Name& groupKey
|
||||
, const Name& key
|
||||
, size_t& gi
|
||||
, size_t& si );
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Functions.
|
||||
inline const Name& DrawingStyle::getName () const { return _name; }
|
||||
inline const string& DrawingStyle::getPattern () const { return _pattern; }
|
||||
inline const QColor& DrawingStyle::getColor () const { return _color; }
|
||||
inline const QPen& DrawingStyle::getPen () const { return _pen; }
|
||||
inline const QBrush& DrawingStyle::getBrush () const { return _brush; }
|
||||
inline float DrawingStyle::getThreshold () const { return _threshold; }
|
||||
|
||||
inline const Name& DrawingGroup::getName () const { return _name; }
|
||||
inline vector<DrawingStyle*>& DrawingGroup::getDrawingStyles () { return _drawingStyles; }
|
||||
|
||||
inline const Name& DisplayStyle::getName () const { return _name; }
|
||||
inline vector<DrawingGroup*>& DisplayStyle::getDrawingGroups () { return _groups; }
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,176 @@
|
|||
|
||||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <assert.h>
|
||||
|
||||
# include <QBrush>
|
||||
# include <QPen>
|
||||
# include <QFont>
|
||||
# include <QApplication>
|
||||
|
||||
# include "Name.h"
|
||||
|
||||
# include "DisplayStyle.h"
|
||||
# include "Graphics.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
Graphics* Graphics::_singleton = NULL;
|
||||
|
||||
|
||||
Graphics::Graphics ()
|
||||
: _styles()
|
||||
, _active(NULL)
|
||||
{
|
||||
_styles.push_back ( new DisplayStyle("Fallback") );
|
||||
_active = _styles[0];
|
||||
}
|
||||
|
||||
|
||||
Graphics::~Graphics ()
|
||||
{
|
||||
delete _singleton;
|
||||
}
|
||||
|
||||
|
||||
Graphics* Graphics::getGraphics ()
|
||||
{
|
||||
if ( !_singleton )
|
||||
_singleton = new Graphics ();
|
||||
|
||||
return _singleton;
|
||||
}
|
||||
|
||||
|
||||
const QFont Graphics::getFixedFont ( bool bold, bool underline )
|
||||
{
|
||||
const QFont defaultFont = QApplication::font ();
|
||||
|
||||
QFont fixedFont ( "Bitstream Vera Sans Mono", defaultFont.pointSize() );
|
||||
if ( bold ) fixedFont.setBold ( true );
|
||||
if ( underline ) fixedFont.setUnderline ( true );
|
||||
|
||||
return fixedFont;
|
||||
}
|
||||
|
||||
|
||||
size_t Graphics::_findStyle ( const Name& name ) const
|
||||
{
|
||||
size_t si = 0;
|
||||
for ( ; si < _styles.size() ; si++ )
|
||||
if ( _styles[si]->getName() == name )
|
||||
break;
|
||||
|
||||
return si;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Graphics::_addStyle ( DisplayStyle* displayStyle )
|
||||
{
|
||||
size_t si = _findStyle(displayStyle->getName());
|
||||
if ( si != _styles.size() ) {
|
||||
cerr << "[WARNING] Graphics::addStyle(): overriding style \""
|
||||
<< displayStyle->getName() << "\"." << endl;
|
||||
|
||||
delete _styles [ si ];
|
||||
} else {
|
||||
_styles.push_back ( NULL );
|
||||
}
|
||||
|
||||
_styles [ si ] = displayStyle;
|
||||
_active = _styles [ si ];
|
||||
}
|
||||
|
||||
|
||||
void Graphics::_setStyle ( const Name& key )
|
||||
{
|
||||
size_t si = _findStyle(key);
|
||||
if ( si == _styles.size() ) {
|
||||
cerr << "[WARNING] Graphics::setStyle(): no style named \"" << key << "\"." << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
_active = _styles [ si ];
|
||||
}
|
||||
|
||||
|
||||
DisplayStyle* Graphics::_getStyle ( const Name& key )
|
||||
{
|
||||
size_t si = _findStyle(key);
|
||||
if ( si == _styles.size() )
|
||||
return NULL;
|
||||
|
||||
return _styles [ si ];
|
||||
}
|
||||
|
||||
|
||||
void Graphics::addStyle ( DisplayStyle* displayStyle )
|
||||
{
|
||||
getGraphics()->_addStyle ( displayStyle );
|
||||
}
|
||||
|
||||
|
||||
void Graphics::setStyle ( const Name& key )
|
||||
{
|
||||
getGraphics()->_setStyle ( key );
|
||||
}
|
||||
|
||||
|
||||
DisplayStyle* Graphics::getStyle ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getStyle ( key );
|
||||
}
|
||||
|
||||
|
||||
DisplayStyle* Graphics::getStyle ()
|
||||
{
|
||||
return getGraphics()->_getStyle ();
|
||||
}
|
||||
|
||||
|
||||
const Name& Graphics::getGroup ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getGroup ( key );
|
||||
}
|
||||
|
||||
|
||||
const QColor& Graphics::getColor ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getColor ( key );
|
||||
}
|
||||
|
||||
|
||||
const QPen& Graphics::getPen ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getPen ( key );
|
||||
}
|
||||
|
||||
|
||||
const QBrush& Graphics::getBrush ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getBrush ( key );
|
||||
}
|
||||
|
||||
|
||||
const string& Graphics::getPattern ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getPattern ( key );
|
||||
}
|
||||
|
||||
|
||||
float Graphics::getThreshold ( const Name& key )
|
||||
{
|
||||
return getGraphics()->_getThreshold ( key );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,102 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __GRAPHICS_H__
|
||||
# define __GRAPHICS_H__
|
||||
|
||||
|
||||
# include <string>
|
||||
# include <vector>
|
||||
|
||||
# include "DisplayStyle.h"
|
||||
|
||||
class QFont;
|
||||
class QColor;
|
||||
class QPen;
|
||||
class QBrush;
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class Name;
|
||||
|
||||
|
||||
class Graphics {
|
||||
|
||||
public:
|
||||
// Accessors.
|
||||
static Graphics* getGraphics ();
|
||||
static const QFont getFixedFont ( bool bold=false, bool underline=false );
|
||||
static const Name& getGroup ( const Name& key );
|
||||
static const QColor& getColor ( const Name& key );
|
||||
static const QPen& getPen ( const Name& key );
|
||||
static const QBrush& getBrush ( const Name& key );
|
||||
static const string& getPattern ( const Name& key );
|
||||
static float getThreshold ( const Name& key );
|
||||
|
||||
// Modifiers.
|
||||
static void addStyle ( DisplayStyle* displayStyle );
|
||||
static void setStyle ( const Name& key );
|
||||
static DisplayStyle* getStyle ( const Name& key );
|
||||
static DisplayStyle* getStyle ();
|
||||
|
||||
// Internals - Attributes.
|
||||
protected:
|
||||
static Graphics* _singleton;
|
||||
vector<DisplayStyle*> _styles;
|
||||
DisplayStyle* _active;
|
||||
|
||||
// Internals - Constructors & Destructors.
|
||||
Graphics ();
|
||||
Graphics ( const Graphics& );
|
||||
Graphics& operator= ( const Graphics& );
|
||||
~Graphics ();
|
||||
|
||||
// Internals - Methods.
|
||||
size_t _findStyle ( const Name& key ) const;
|
||||
void _addStyle ( DisplayStyle* displayStyle );
|
||||
void _setStyle ( const Name& key );
|
||||
DisplayStyle* _getStyle ( const Name& key );
|
||||
DisplayStyle* _getStyle () const;
|
||||
inline const Name& _getGroup ( const Name& key ) const;
|
||||
inline const QColor& _getColor ( const Name& key ) const;
|
||||
inline const QPen& _getPen ( const Name& key ) const;
|
||||
inline const QBrush& _getBrush ( const Name& key ) const;
|
||||
inline const string& _getPattern ( const Name& key ) const;
|
||||
inline float _getThreshold ( const Name& key ) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
inline const Name& Graphics::_getGroup ( const Name& name ) const
|
||||
{ return _active->getGroup(name); }
|
||||
|
||||
inline const QColor& Graphics::_getColor ( const Name& name ) const
|
||||
{ return _active->getColor(name); }
|
||||
|
||||
inline const QPen& Graphics::_getPen ( const Name& name ) const
|
||||
{ return _active->getPen(name); }
|
||||
|
||||
inline const QBrush& Graphics::_getBrush ( const Name& name ) const
|
||||
{ return _active->getBrush(name); }
|
||||
|
||||
inline const string& Graphics::_getPattern ( const Name& name ) const
|
||||
{ return _active->getPattern(name); }
|
||||
|
||||
inline float Graphics::_getThreshold ( const Name& name ) const
|
||||
{ return _active->getThreshold(name); }
|
||||
|
||||
inline DisplayStyle* Graphics::_getStyle () const
|
||||
{ return _active; }
|
||||
|
||||
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,153 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QPushButton>
|
||||
# include <QHBoxLayout>
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "GroupPaletteEntry.h"
|
||||
# include "Palette.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
GroupPaletteEntry::GroupPaletteEntry ( Palette* palette, const Name& name )
|
||||
: PaletteEntry(palette)
|
||||
, _name(name)
|
||||
, _button(NULL)
|
||||
, _index(0)
|
||||
, _expanded(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
GroupPaletteEntry* GroupPaletteEntry::create ( Palette* palette, const Name& name )
|
||||
{
|
||||
GroupPaletteEntry* entry = new GroupPaletteEntry ( palette, name );
|
||||
|
||||
entry->_postCreate ();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
void GroupPaletteEntry::_postCreate ()
|
||||
{
|
||||
|
||||
_index = _palette->getEntries().size();
|
||||
|
||||
QHBoxLayout* layout = new QHBoxLayout ();
|
||||
layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||
|
||||
_button = new QPushButton ( this );
|
||||
_button->setFlat ( true );
|
||||
_button->setText ( getString(getName()).c_str() );
|
||||
_button->setFont ( Graphics::getFixedFont(true,true) );
|
||||
|
||||
layout->addWidget ( _button );
|
||||
layout->addStretch ();
|
||||
|
||||
setLayout ( layout );
|
||||
|
||||
connect ( _button, SIGNAL(clicked()), this, SLOT(toggle()) );
|
||||
}
|
||||
|
||||
|
||||
bool GroupPaletteEntry::isGroup () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool GroupPaletteEntry::isBasicLayer () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const Name& GroupPaletteEntry::getName () const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
BasicLayer* GroupPaletteEntry::getBasicLayer ()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool GroupPaletteEntry::isChecked () const
|
||||
{
|
||||
return _expanded;
|
||||
}
|
||||
|
||||
|
||||
void GroupPaletteEntry::setChecked ( bool state )
|
||||
{
|
||||
_expanded = state;
|
||||
|
||||
hideShow ();
|
||||
}
|
||||
|
||||
|
||||
void GroupPaletteEntry::toggle ()
|
||||
{
|
||||
_expanded = !_expanded;
|
||||
|
||||
hideShow ();
|
||||
}
|
||||
|
||||
|
||||
void GroupPaletteEntry::hideShow ()
|
||||
{
|
||||
vector<PaletteEntry*> entries = _palette->getEntries ();
|
||||
|
||||
if ( entries[_index] != this )
|
||||
cerr << "[ERROR] Incoherent index for group \"" << getString(getName()) << "\"." << endl;
|
||||
|
||||
_button->setText ( getLabel().c_str() );
|
||||
|
||||
for ( size_t i=_index+1 ; i<entries.size() ; i++ ) {
|
||||
if ( entries[i]->isGroup() ) break;
|
||||
|
||||
if ( _expanded ) entries[i]->show ();
|
||||
else entries[i]->hide ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string GroupPaletteEntry::getLabel ()
|
||||
{
|
||||
string label = getString(getName());
|
||||
|
||||
for ( size_t i=0 ; i<label.size() ; i++ ) {
|
||||
if ( label[i] == '&' ) {
|
||||
label.insert ( i, 1, '&' );
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
|
||||
size_t spacingLeft = 0;
|
||||
size_t spacingRight = 0;
|
||||
|
||||
if ( label.size() < 15 ) {
|
||||
spacingLeft = (15 - label.size()) / 2;
|
||||
spacingRight = spacingLeft + ( ((15 - label.size()) % 2) ? 1 : 0 );
|
||||
}
|
||||
|
||||
if ( !_expanded )
|
||||
_button->setFont ( Graphics::getFixedFont(true,true) );
|
||||
else
|
||||
_button->setFont ( Graphics::getFixedFont(true,false) );
|
||||
|
||||
label.insert ( 0, spacingLeft, ' ' );
|
||||
label.append ( spacingRight, ' ' );
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,61 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __GROUP_PALETTE_ENTRY_H__
|
||||
# define __GROUP_PALETTE_ENTRY_H__
|
||||
|
||||
|
||||
class QPushButton;
|
||||
|
||||
# include "Name.h"
|
||||
|
||||
# include "PaletteEntry.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class GroupPaletteEntry : public PaletteEntry {
|
||||
Q_OBJECT;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
static GroupPaletteEntry* create ( Palette* palette, const Name& name );
|
||||
|
||||
// Methods.
|
||||
public:
|
||||
virtual bool isGroup () const;
|
||||
virtual bool isBasicLayer () const;
|
||||
virtual const Name& getName () const;
|
||||
virtual BasicLayer* getBasicLayer ();
|
||||
virtual bool isChecked () const;
|
||||
virtual void setChecked ( bool state );
|
||||
|
||||
// Slots.
|
||||
public slots:
|
||||
virtual void toggle ();
|
||||
|
||||
// Internal - Attributes.
|
||||
protected:
|
||||
const Name _name;
|
||||
QPushButton* _button;
|
||||
size_t _index;
|
||||
bool _expanded;
|
||||
|
||||
// Internal - Constructor.
|
||||
GroupPaletteEntry ( Palette* palette, const Name& name );
|
||||
GroupPaletteEntry ( const GroupPaletteEntry& );
|
||||
GroupPaletteEntry& operator= ( const GroupPaletteEntry& );
|
||||
virtual void _postCreate ();
|
||||
|
||||
// Internal - Methods.
|
||||
void hideShow ();
|
||||
string getLabel ();
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,96 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QCheckBox>
|
||||
# include <QHBoxLayout>
|
||||
|
||||
# include "BasicLayer.h"
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "LayerPaletteEntry.h"
|
||||
# include "Palette.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
LayerPaletteEntry::LayerPaletteEntry ( Palette* entry, BasicLayer* basicLayer )
|
||||
: PaletteEntry(entry)
|
||||
, _basicLayer(basicLayer)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LayerPaletteEntry* LayerPaletteEntry::create ( Palette* palette, BasicLayer* basicLayer )
|
||||
{
|
||||
LayerPaletteEntry* entry = new LayerPaletteEntry ( palette, basicLayer );
|
||||
|
||||
entry->_postCreate ();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
void LayerPaletteEntry::_postCreate ()
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout ();
|
||||
layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||
|
||||
layout->addWidget ( new PaletteSample(this) );
|
||||
|
||||
_checkBox = new QCheckBox ( this );
|
||||
_checkBox->setChecked ( true );
|
||||
_checkBox->setText ( getString(getName()).c_str() );
|
||||
_checkBox->setFont ( Graphics::getFixedFont() );
|
||||
layout->addWidget ( _checkBox );
|
||||
|
||||
setLayout ( layout );
|
||||
|
||||
connect ( _checkBox, SIGNAL(clicked()), this, SLOT(toggle()) );
|
||||
}
|
||||
|
||||
|
||||
bool LayerPaletteEntry::isGroup () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool LayerPaletteEntry::isBasicLayer () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const Name& LayerPaletteEntry::getName () const
|
||||
{
|
||||
return _basicLayer->getName();
|
||||
}
|
||||
|
||||
|
||||
BasicLayer* LayerPaletteEntry::getBasicLayer ()
|
||||
{
|
||||
return _basicLayer;
|
||||
}
|
||||
|
||||
|
||||
bool LayerPaletteEntry::isChecked () const
|
||||
{
|
||||
return _checkBox->isChecked ();
|
||||
}
|
||||
|
||||
|
||||
void LayerPaletteEntry::setChecked ( bool state )
|
||||
{
|
||||
_checkBox->setChecked ( state );
|
||||
}
|
||||
|
||||
|
||||
void LayerPaletteEntry::toggle ()
|
||||
{
|
||||
_palette->redrawCellWidget();
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __LAYER_PALETTE_ENTRY_H__
|
||||
# define __LAYER_PALETTE_ENTRY_H__
|
||||
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
# include "PaletteEntry.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class LayerPaletteEntry : public PaletteEntry {
|
||||
Q_OBJECT;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
static LayerPaletteEntry* create ( Palette* palette, BasicLayer* basicLayer );
|
||||
|
||||
// Methods.
|
||||
public:
|
||||
virtual bool isGroup () const;
|
||||
virtual bool isBasicLayer () const;
|
||||
virtual const Name& getName () const;
|
||||
virtual BasicLayer* getBasicLayer ();
|
||||
virtual bool isChecked () const;
|
||||
virtual void setChecked ( bool state );
|
||||
|
||||
// Slots.
|
||||
public slots:
|
||||
virtual void toggle ();
|
||||
|
||||
// Internal - Attributes.
|
||||
protected:
|
||||
BasicLayer* _basicLayer;
|
||||
QCheckBox* _checkBox;
|
||||
|
||||
// Internal - Constructor.
|
||||
LayerPaletteEntry ( Palette* palette, BasicLayer* basicLayer );
|
||||
LayerPaletteEntry ( const LayerPaletteEntry& );
|
||||
LayerPaletteEntry& operator= ( const LayerPaletteEntry& );
|
||||
virtual void _postCreate ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <vector>
|
||||
|
||||
# include <QHBoxLayout>
|
||||
# include <QVBoxLayout>
|
||||
# include <QCheckBox>
|
||||
# include <QPushButton>
|
||||
|
||||
# include "Name.h"
|
||||
# include "DataBase.h"
|
||||
# include "Technology.h"
|
||||
# include "BasicLayer.h"
|
||||
# include "BasicLayers.h"
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "PaletteEntry.h"
|
||||
# include "LayerPaletteEntry.h"
|
||||
# include "GroupPaletteEntry.h"
|
||||
# include "ViewerPaletteEntry.h"
|
||||
# include "Palette.h"
|
||||
# include "CellWidget.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
|
||||
Palette::Palette ( CellWidget* cellWidget ) : QScrollArea()
|
||||
, _cellWidget(cellWidget)
|
||||
, _entries()
|
||||
, _showAll(NULL)
|
||||
, _hideAll(NULL)
|
||||
{
|
||||
setWidgetResizable ( true );
|
||||
|
||||
QWidget* adaptator = new QWidget ();
|
||||
QVBoxLayout* layout = new QVBoxLayout ();
|
||||
|
||||
//layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||
|
||||
vector<DrawingGroup*> groups = Graphics::getStyle()->getDrawingGroups();
|
||||
vector<DrawingStyle*> styles = groups[0]->getDrawingStyles();
|
||||
|
||||
GroupPaletteEntry* gentry = GroupPaletteEntry::create ( this, groups[0]->getName() );
|
||||
layout->addWidget ( gentry, 0, Qt::AlignLeft );
|
||||
layout->addSpacing ( -5 );
|
||||
_entries.push_back ( gentry );
|
||||
|
||||
for ( size_t si=0 ; si<styles.size() ; si++ ) {
|
||||
if ( styles[si]->getName() == DisplayStyle::Foreground ) continue;
|
||||
if ( styles[si]->getName() == DisplayStyle::Background ) continue;
|
||||
if ( styles[si]->getName() == DisplayStyle::Foreground ) continue;
|
||||
if ( styles[si]->getName() == DisplayStyle::SelectionDraw ) continue;
|
||||
if ( styles[si]->getName() == DisplayStyle::SelectionFill ) continue;
|
||||
if ( styles[si]->getName() == DisplayStyle::Foreground ) continue;
|
||||
|
||||
ViewerPaletteEntry* entry = ViewerPaletteEntry::create ( this, styles[si]->getName() );
|
||||
layout->addWidget ( entry, 0, Qt::AlignLeft );
|
||||
_entries.push_back ( entry );
|
||||
}
|
||||
gentry->setChecked ( false );
|
||||
|
||||
DataBase* database = getDataBase();
|
||||
if ( database ) {
|
||||
Technology* technology = database->getTechnology();
|
||||
if ( technology ) {
|
||||
for ( size_t gi=1 ; gi<groups.size() ; gi++ ) {
|
||||
gentry = GroupPaletteEntry::create ( this, groups[gi]->getName() );
|
||||
layout->addWidget ( gentry, 0, Qt::AlignLeft );
|
||||
layout->addSpacing ( -5 );
|
||||
_entries.push_back ( gentry );
|
||||
|
||||
styles = groups[gi]->getDrawingStyles();
|
||||
for ( size_t si=0 ; si<styles.size() ; si++ ) {
|
||||
BasicLayer* basicLayer = technology->getBasicLayer ( styles[si]->getName() );
|
||||
|
||||
if ( basicLayer ) {
|
||||
LayerPaletteEntry* entry = LayerPaletteEntry::create ( this, basicLayer );
|
||||
layout->addWidget ( entry, 0, Qt::AlignLeft );
|
||||
_entries.push_back ( entry );
|
||||
}
|
||||
}
|
||||
gentry->setChecked ( false );
|
||||
}
|
||||
bool unmatched = false;
|
||||
for_each_basic_layer ( basicLayer, technology->getBasicLayers() ) {
|
||||
if ( !find(basicLayer->getName()) ) {
|
||||
if ( !unmatched ) {
|
||||
unmatched = true;
|
||||
gentry = GroupPaletteEntry::create ( this, "Unmatcheds" );
|
||||
layout->addWidget ( gentry, 0, Qt::AlignLeft );
|
||||
layout->addSpacing ( -5 );
|
||||
_entries.push_back ( gentry );
|
||||
}
|
||||
LayerPaletteEntry* entry = LayerPaletteEntry::create ( this, basicLayer );
|
||||
layout->addWidget ( entry, 0, Qt::AlignLeft );
|
||||
_entries.push_back ( entry );
|
||||
|
||||
cerr << "[WARNING] BasicLayer \"" << basicLayer->getName()
|
||||
<< "\" has no associated DisplayStyle." << endl;
|
||||
}
|
||||
end_for;
|
||||
}
|
||||
if ( unmatched )
|
||||
gentry->setChecked ( false );
|
||||
}
|
||||
}
|
||||
|
||||
_showAll = new QPushButton ( this );
|
||||
_showAll->setIcon ( QIcon(":/images/palette_show_all.png") );
|
||||
_showAll->setFlat ( true );
|
||||
|
||||
_hideAll = new QPushButton ( this );
|
||||
_hideAll->setIcon ( QIcon(":/images/palette_hide_all.png") );
|
||||
_hideAll->setFlat ( true );
|
||||
|
||||
connect ( _showAll, SIGNAL(clicked()), this, SLOT(showAll()) );
|
||||
connect ( _hideAll, SIGNAL(clicked()), this, SLOT(hideAll()) );
|
||||
|
||||
QHBoxLayout* bottomEntry = new QHBoxLayout ();
|
||||
bottomEntry->setContentsMargins ( 0, 0, 0, 0 );
|
||||
bottomEntry->addWidget ( _showAll );
|
||||
bottomEntry->addWidget ( _hideAll );
|
||||
layout->addLayout ( bottomEntry );
|
||||
layout->addStretch ();
|
||||
|
||||
adaptator->setLayout ( layout );
|
||||
setWidget ( adaptator );
|
||||
setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
|
||||
setVerticalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
|
||||
setFrameStyle ( QFrame::Plain );
|
||||
}
|
||||
|
||||
|
||||
bool Palette::isDrawable ( size_t index )
|
||||
{
|
||||
if ( index < _entries.size() )
|
||||
return _entries[index]->isChecked ();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void Palette::showAll ()
|
||||
{
|
||||
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||
if ( !_entries[i]->isGroup() )
|
||||
_entries[i]->setChecked ( true );
|
||||
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
void Palette::hideAll ()
|
||||
{
|
||||
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||
if ( !_entries[i]->isGroup() )
|
||||
_entries[i]->setChecked ( false );
|
||||
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
void Palette::redrawCellWidget ()
|
||||
{
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
PaletteEntry* Palette::find ( const Name& name )
|
||||
{
|
||||
for ( size_t i=0 ; i<_entries.size() ; i++ ) {
|
||||
if ( _entries[i]->getName() == name )
|
||||
return _entries[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __PALETTET__
|
||||
# define __PALETTE__
|
||||
|
||||
# include <vector>
|
||||
# include <QWidget>
|
||||
# include <QScrollArea>
|
||||
# include <QPixmap>
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class Name;
|
||||
class BasicLayer;
|
||||
class PaletteEntry;
|
||||
class CellWidget;
|
||||
|
||||
|
||||
class Palette : public QScrollArea {
|
||||
Q_OBJECT;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
Palette ( CellWidget* cellWidget );
|
||||
// Methods.
|
||||
bool isDrawable ( size_t index );
|
||||
inline CellWidget* getCellWidget ();
|
||||
inline vector<PaletteEntry*>& getEntries ();
|
||||
void redrawCellWidget ();
|
||||
PaletteEntry* find ( const Name& name );
|
||||
// Slots.
|
||||
public slots:
|
||||
void showAll ();
|
||||
void hideAll ();
|
||||
|
||||
// Internal - Attributes.
|
||||
protected:
|
||||
CellWidget* _cellWidget;
|
||||
vector<PaletteEntry*> _entries;
|
||||
QPushButton* _showAll;
|
||||
QPushButton* _hideAll;
|
||||
// Internal - Constructors.
|
||||
Palette ( const Palette& );
|
||||
Palette& operator= ( const Palette& );
|
||||
|
||||
};
|
||||
|
||||
|
||||
// Inline Functions.
|
||||
inline CellWidget* Palette::getCellWidget () { return _cellWidget; }
|
||||
inline vector<PaletteEntry*>& Palette::getEntries () { return _entries; }
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,54 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QPainter>
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "PaletteEntry.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
PaletteSample::PaletteSample ( PaletteEntry* entry )
|
||||
: QWidget()
|
||||
, _sample(QSize(20,20))
|
||||
, _entry(entry)
|
||||
{
|
||||
setAttribute ( Qt::WA_StaticContents );
|
||||
setSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
setFixedSize ( 20, 20 );
|
||||
|
||||
redraw ();
|
||||
}
|
||||
|
||||
|
||||
void PaletteSample::redraw ()
|
||||
{
|
||||
QPainter painter ( &_sample );
|
||||
|
||||
painter.setPen ( Qt::NoPen );
|
||||
painter.setBackground ( Graphics::getBrush("background") );
|
||||
painter.eraseRect ( 0, 0, 20, 20 );
|
||||
painter.setPen ( Graphics::getPen (_entry->getName()) );
|
||||
painter.setBrush ( Graphics::getBrush(_entry->getName()) );
|
||||
painter.drawRect ( 2, 2, 16, 16 );
|
||||
}
|
||||
|
||||
|
||||
void PaletteSample::paintEvent ( QPaintEvent* )
|
||||
{
|
||||
QPainter painter ( this );
|
||||
painter.drawPixmap ( 0, 0, _sample );
|
||||
}
|
||||
|
||||
|
||||
PaletteEntry::PaletteEntry ( Palette* palette )
|
||||
: QWidget()
|
||||
, _palette(palette)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,78 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __PALETTE_ENTRY_H__
|
||||
# define __PALETTE_ENTRY_H__
|
||||
|
||||
# include <QPixmap>
|
||||
# include <QWidget>
|
||||
# include <QFont>
|
||||
|
||||
class QPaintEvent;
|
||||
class QCheckBox;
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class Name;
|
||||
class BasicLayer;
|
||||
class Palette;
|
||||
class PaletteEntry;
|
||||
|
||||
|
||||
class PaletteSample : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
PaletteSample ( PaletteEntry* entry );
|
||||
|
||||
// Internals - Attributes.
|
||||
protected:
|
||||
QPixmap _sample;
|
||||
PaletteEntry* _entry;
|
||||
|
||||
// Internals - Methods.
|
||||
void redraw ();
|
||||
void paintEvent ( QPaintEvent* );
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PaletteEntry : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
||||
// Methods.
|
||||
public:
|
||||
virtual const Name& getName () const = 0;
|
||||
virtual bool isGroup () const = 0;
|
||||
virtual bool isBasicLayer () const = 0;
|
||||
virtual BasicLayer* getBasicLayer () = 0;
|
||||
virtual bool isChecked () const = 0;
|
||||
virtual void setChecked ( bool state ) = 0;
|
||||
|
||||
// Slots.
|
||||
public slots:
|
||||
virtual void toggle () = 0;
|
||||
|
||||
// Internal - Attributes.
|
||||
protected:
|
||||
Palette* _palette;
|
||||
|
||||
// Internal - Constructor.
|
||||
PaletteEntry ( Palette* palette );
|
||||
PaletteEntry ( const PaletteEntry& );
|
||||
PaletteEntry& operator= ( const PaletteEntry& );
|
||||
virtual void _postCreate () = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,84 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QBitmap>
|
||||
|
||||
# include "BasicLayer.h"
|
||||
|
||||
# include "ScreenUtilities.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
inline bool charToBits ( uchar& b, char c, bool low=true )
|
||||
{
|
||||
bool isValid = true;
|
||||
uchar value = 0xF;
|
||||
|
||||
if ( (c >= '0') && (c <= '9') ) value = (uchar)( c - '0' );
|
||||
else {
|
||||
if ( (c >= 'a') && (c <= 'f') ) value = (uchar)( c - 'a' + 10 );
|
||||
else {
|
||||
if ( (c >= 'A') && (c <= 'F') ) value = (uchar)( c - 'A' + 10 );
|
||||
else
|
||||
isValid = false;
|
||||
}
|
||||
}
|
||||
|
||||
b &= (low) ? 0xF0 : 0x0F;
|
||||
b += (low) ? value : (value<<4);
|
||||
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
bool getPattern ( uchar bits[], const string& pattern )
|
||||
{
|
||||
bool isValid = true;
|
||||
|
||||
for ( size_t i=0 ; i<pattern.size() ; i++ ) {
|
||||
if ( i > 15 ) { isValid = false; break; }
|
||||
isValid &= charToBits ( bits[i/2], pattern[i], i%2 );
|
||||
}
|
||||
return isValid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
QBrush getBrush ( const string& pattern, int red, int green, int blue )
|
||||
{
|
||||
if ( pattern != "FFFFFFFFFFFFFFFF" ) {
|
||||
uchar bits[8];
|
||||
|
||||
if ( !getPattern(bits,pattern) )
|
||||
cerr << "[WARNING] Invalid stipple pattern: \"0x" << pattern << "\"." << endl;
|
||||
|
||||
return QBrush ( QColor(red,green,blue), QBitmap::fromData(QSize(8,8),bits,QImage::Format_Mono) );
|
||||
}
|
||||
|
||||
return QBrush ( QColor(red,green,blue), Qt::SolidPattern );
|
||||
}
|
||||
|
||||
|
||||
QBrush getBrush ( const BasicLayer* layer )
|
||||
{
|
||||
return getBrush ( layer->getFillPattern()
|
||||
, layer->getRedValue()
|
||||
, layer->getGreenValue()
|
||||
, layer->getBlueValue()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,35 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __SCREENUTILITIES_H__
|
||||
# define __SCREENUTILITIES_H__
|
||||
|
||||
# include <string>
|
||||
# include <QBrush>
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class BasicLayer;
|
||||
|
||||
|
||||
// Constants.
|
||||
const size_t InvalidIndex = (size_t)-1;
|
||||
|
||||
|
||||
// Functions.
|
||||
|
||||
QBrush getBrush ( const string& pattern, int red, int green, int blue );
|
||||
QBrush getBrush ( const BasicLayer* layer );
|
||||
|
||||
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QCheckBox>
|
||||
# include <QHBoxLayout>
|
||||
|
||||
# include "BasicLayer.h"
|
||||
|
||||
# include "Graphics.h"
|
||||
# include "ViewerPaletteEntry.h"
|
||||
# include "Palette.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
ViewerPaletteEntry::ViewerPaletteEntry ( Palette* entry, const Name& name )
|
||||
: PaletteEntry(entry)
|
||||
, _name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ViewerPaletteEntry* ViewerPaletteEntry::create ( Palette* palette, const Name& name )
|
||||
{
|
||||
ViewerPaletteEntry* entry = new ViewerPaletteEntry ( palette, name );
|
||||
|
||||
entry->_postCreate ();
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
void ViewerPaletteEntry::_postCreate ()
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout ();
|
||||
layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||
|
||||
layout->addWidget ( new PaletteSample(this) );
|
||||
|
||||
_checkBox = new QCheckBox ( this );
|
||||
_checkBox->setChecked ( true );
|
||||
_checkBox->setText ( getString(getName()).c_str() );
|
||||
layout->addWidget ( _checkBox );
|
||||
|
||||
setLayout ( layout );
|
||||
|
||||
connect ( _checkBox, SIGNAL(clicked()), this, SLOT(toggle()) );
|
||||
}
|
||||
|
||||
|
||||
bool ViewerPaletteEntry::isGroup () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ViewerPaletteEntry::isBasicLayer () const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const Name& ViewerPaletteEntry::getName () const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
|
||||
BasicLayer* ViewerPaletteEntry::getBasicLayer ()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool ViewerPaletteEntry::isChecked () const
|
||||
{
|
||||
return _checkBox->isChecked ();
|
||||
}
|
||||
|
||||
|
||||
void ViewerPaletteEntry::setChecked ( bool state )
|
||||
{
|
||||
_checkBox->setChecked ( state );
|
||||
}
|
||||
|
||||
|
||||
void ViewerPaletteEntry::toggle ()
|
||||
{
|
||||
_palette->redrawCellWidget();
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __VIEWER_PALETTE_ENTRY_H__
|
||||
# define __VIEWER_PALETTE_ENTRY_H__
|
||||
|
||||
|
||||
class QCheckBox;
|
||||
|
||||
# include "Name.h"
|
||||
# include "PaletteEntry.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class ViewerPaletteEntry : public PaletteEntry {
|
||||
Q_OBJECT;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
static ViewerPaletteEntry* create ( Palette* palette, const Name& name );
|
||||
|
||||
// Methods.
|
||||
public:
|
||||
virtual bool isGroup () const;
|
||||
virtual bool isBasicLayer () const;
|
||||
virtual const Name& getName () const;
|
||||
virtual BasicLayer* getBasicLayer ();
|
||||
virtual bool isChecked () const;
|
||||
virtual void setChecked ( bool state );
|
||||
|
||||
// Slots.
|
||||
public slots:
|
||||
virtual void toggle ();
|
||||
|
||||
// Internal - Attributes.
|
||||
protected:
|
||||
const Name _name;
|
||||
QCheckBox* _checkBox;
|
||||
|
||||
// Internal - Constructor.
|
||||
ViewerPaletteEntry ( Palette* palette, const Name& name );
|
||||
ViewerPaletteEntry ( const ViewerPaletteEntry& );
|
||||
ViewerPaletteEntry& operator= ( const ViewerPaletteEntry& );
|
||||
virtual void _postCreate ();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,78 @@
|
|||
<?xml version="1.0"?>
|
||||
<graphicsconfiguration>
|
||||
<displaystyles>
|
||||
<displaystyle name="Alliance">
|
||||
<group name="viewer">
|
||||
<drawingstyle name="fallback" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="background" color="50,50,50" border="1"/>
|
||||
<drawingstyle name="foreground" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="rubber" color="192,0,192" border="1"/>
|
||||
<drawingstyle name="phantom" color="139,134,130" border="1"/>
|
||||
<drawingstyle name="boundaries" color="208,199,192" border="1" pattern="0000000000000000"/>
|
||||
<drawingstyle name="marker" color="80,250,80" border="1"/>
|
||||
<drawingstyle name="selectionDraw" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="selectionFill" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="grid" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="spot" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="gost" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="text" color="255,255,255" border="0" pattern="8822441188224411"/>
|
||||
<drawingstyle name="undef" color="238,130,238" border="0" pattern="2244118822441188"/>
|
||||
</group>
|
||||
<group name="Active Layers">
|
||||
<drawingstyle name="NWELL" color="210,180,140" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="PWELL" color="255,255,224" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="ntie" color="0,255,127" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="ptie" color="238,221,130" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="ndif" color="124,252,0" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="pdif" color="255,255,0" pattern="55AA55AA55AA55AA" threshold="1.50"/>
|
||||
<drawingstyle name="ntrans" color="255,0,0" pattern="55AA55AA55AA55AA" threshold="1.20"/>
|
||||
<drawingstyle name="ptrans" color="255,0,0" pattern="55AA55AA55AA55AA" threshold="1.20"/>
|
||||
<drawingstyle name="poly" color="255,0,0" pattern="55AA55AA55AA55AA" threshold="1.20"/>
|
||||
</group>
|
||||
<group name="Routing Layers">
|
||||
<drawingstyle name="ALU1" color="0,0,255" pattern="AA55AA55AA55AA55" threshold="0.80"/>
|
||||
<drawingstyle name="ALU2" color="0,255,255" pattern="8822882288228822" threshold="0.80"/>
|
||||
<drawingstyle name="ALU3" color="255,182,193" pattern="4411441144114411" threshold="0.80"/>
|
||||
<drawingstyle name="ALU4" color="0,255,0" pattern="2288228822882288" threshold="0.80"/>
|
||||
<drawingstyle name="ALU5" color="255,255,0" pattern="1144114411441144" threshold="0.80"/>
|
||||
<drawingstyle name="ALU6" color="238,130,238" pattern="8822882288228822" threshold="0.80"/>
|
||||
</group>
|
||||
<group name="VIA Holes">
|
||||
<drawingstyle name="VIA1" color="0,255,255" threshold="0.40"/>
|
||||
<drawingstyle name="VIA2" color="255,182,193" threshold="0.40"/>
|
||||
<drawingstyle name="VIA3" color="0,255,0" threshold="0.40"/>
|
||||
<drawingstyle name="VIA4" color="255,255,0" threshold="0.40"/>
|
||||
<drawingstyle name="VIA5" color="238,130,238" threshold="0.40"/>
|
||||
</group>
|
||||
<group name="Obstacles">
|
||||
<drawingstyle name="TALU1" color="0,0,255" pattern="006070381c0e0703" threshold="0.80" border="2"/>
|
||||
<drawingstyle name="TALU2" color="0,255,255" pattern="8103060c183060c0" threshold="0.80" border="2"/>
|
||||
<drawingstyle name="TALU3" color="255,182,193" pattern="8800220088002200" threshold="0.80" border="2"/>
|
||||
<drawingstyle name="TALU4" color="0,255,0" pattern="2288228822882288" threshold="0.80" border="2"/>
|
||||
<drawingstyle name="TALU5" color="255,255,0" pattern="1144114411441144" threshold="0.80" border="2"/>
|
||||
<drawingstyle name="TALU6" color="238,130,238" pattern="8822882288228822" threshold="0.80" border="2"/>
|
||||
</group>
|
||||
<group name="Knick & Kite">
|
||||
<drawingstyle name="SPL1" color="255,0,0"/>
|
||||
<drawingstyle name="AutoLayer" color="255,0,255"/>
|
||||
<drawingstyle name="GALU2" color="128,255,200" pattern="8822882288228822"/>
|
||||
<drawingstyle name="GALU3" color="200,200,255" pattern="4411441144114411"/>
|
||||
<drawingstyle name="GCONTACT" color="255,255,190"/>
|
||||
</group>
|
||||
</displaystyle>
|
||||
<displaystyle name="Compass" inherit="Alliance">
|
||||
<group name="viewer">
|
||||
<drawingstyle name="fallback" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="background" color="255,255,255" border="1"/>
|
||||
<drawingstyle name="foreground" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="selectionDraw" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="selectionFill" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="grid" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="spot" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="gost" color="0,0,0" border="1"/>
|
||||
<drawingstyle name="text" color="0,0,0" border="0" pattern="8822441188224411"/>
|
||||
<drawingstyle name="undef" color="0,0,0" border="0" pattern="2244118822441188"/>
|
||||
</group>
|
||||
</displaystyle>
|
||||
</displaystyles>
|
||||
</graphicsconfiguration>
|
After Width: | Height: | Size: 536 B |
After Width: | Height: | Size: 522 B |
After Width: | Height: | Size: 523 B |
After Width: | Height: | Size: 605 B |
After Width: | Height: | Size: 923 B |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 394 B |
After Width: | Height: | Size: 850 B |
|
@ -0,0 +1,134 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <vector>
|
||||
|
||||
# include <QBitmap>
|
||||
# include <QPainter>
|
||||
# include <QHBoxLayout>
|
||||
# include <QVBoxLayout>
|
||||
# include <QCheckBox>
|
||||
# include <QPushButton>
|
||||
|
||||
# include "Name.h"
|
||||
|
||||
# include "ScreenLayer.h"
|
||||
# include "LayersList.h"
|
||||
# include "CellWidget.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
ScreenLayerEntry::ScreenLayerEntry ( ScreenLayer* layer, LayersList* layersList )
|
||||
: QWidget()
|
||||
, _layersList(layersList)
|
||||
{
|
||||
QHBoxLayout* layout = new QHBoxLayout ();
|
||||
layout->setContentsMargins ( 0, 0, 0, 0 );
|
||||
|
||||
_sample = layer->getSample();
|
||||
layout->addWidget ( _sample );
|
||||
|
||||
_checkBox = new QCheckBox ( this );
|
||||
_checkBox->setText ( getString(layer->getName()).c_str() );
|
||||
_checkBox->setChecked ( true );
|
||||
layout->addWidget ( _checkBox );
|
||||
|
||||
setLayout ( layout );
|
||||
}
|
||||
|
||||
|
||||
void ScreenLayerEntry::setChecked ( bool state )
|
||||
{
|
||||
_checkBox->setChecked ( state );
|
||||
_sample ->setVisible ( state );
|
||||
}
|
||||
|
||||
|
||||
bool ScreenLayerEntry::isChecked () const
|
||||
{
|
||||
return _checkBox->isChecked ();
|
||||
}
|
||||
|
||||
|
||||
void ScreenLayerEntry::toggle ()
|
||||
{
|
||||
_sample->setVisible ( _checkBox->isChecked() );
|
||||
_layersList->getCellWidget()->redraw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
LayersList::LayersList ( CellWidget* cellWidget ) : QScrollArea()
|
||||
, _cellWidget(cellWidget)
|
||||
, _entries()
|
||||
, _showAll(NULL)
|
||||
, _hideAll(NULL)
|
||||
{
|
||||
QWidget* adaptator = new QWidget ();
|
||||
QVBoxLayout* layout = new QVBoxLayout ();
|
||||
|
||||
vector<ScreenLayer*>& screenLayers = _cellWidget->getScreenLayers ();
|
||||
|
||||
for ( size_t i=0 ; i < screenLayers.size() ; i++ ) {
|
||||
_entries.push_back ( new ScreenLayerEntry(screenLayers[i],this) );
|
||||
layout->addWidget ( _entries.back() );
|
||||
connect ( _entries.back()->getCheckBox(), SIGNAL(clicked()), _entries.back(), SLOT(toggle()) );
|
||||
}
|
||||
layout->addStretch ();
|
||||
|
||||
_showAll = new QPushButton ( this );
|
||||
_showAll->setIcon ( QIcon(":/images/palette_show_all.png") );
|
||||
_showAll->setFlat ( true );
|
||||
|
||||
_hideAll = new QPushButton ( this );
|
||||
_hideAll->setIcon ( QIcon(":/images/palette_hide_all.png") );
|
||||
_hideAll->setFlat ( true );
|
||||
|
||||
connect ( _showAll, SIGNAL(clicked()), this, SLOT(showAll()) );
|
||||
connect ( _hideAll, SIGNAL(clicked()), this, SLOT(hideAll()) );
|
||||
|
||||
QHBoxLayout* bottomEntry = new QHBoxLayout ();
|
||||
bottomEntry->setContentsMargins ( 0, 0, 0, 0 );
|
||||
bottomEntry->addWidget ( _showAll );
|
||||
bottomEntry->addWidget ( _hideAll );
|
||||
layout->addLayout ( bottomEntry );
|
||||
|
||||
adaptator->setLayout ( layout );
|
||||
setWidget ( adaptator );
|
||||
setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
|
||||
setVerticalScrollBarPolicy ( Qt::ScrollBarAsNeeded );
|
||||
setFrameStyle ( QFrame::Plain );
|
||||
}
|
||||
|
||||
|
||||
bool LayersList::isVisible ( size_t index )
|
||||
{
|
||||
if ( index < _entries.size() )
|
||||
return _entries[index]->isChecked ();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void LayersList::showAll ()
|
||||
{
|
||||
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||
_entries[i]->setChecked ( true );
|
||||
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
void LayersList::hideAll ()
|
||||
{
|
||||
for ( size_t i=0 ; i<_entries.size() ; i++ )
|
||||
_entries[i]->setChecked ( false );
|
||||
|
||||
_cellWidget->redraw ();
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,79 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __LAYERSLIST__
|
||||
# define __LAYERSLIST__
|
||||
|
||||
# include <vector>
|
||||
# include <QWidget>
|
||||
# include <QScrollArea>
|
||||
# include <QPixmap>
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
class QCheckBox;
|
||||
class QPushButton;
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
class LayerSample;
|
||||
class ScreenLayer;
|
||||
class LayersList;
|
||||
class CellWidget;
|
||||
|
||||
|
||||
class ScreenLayerEntry : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
||||
protected:
|
||||
LayersList* _layersList;
|
||||
LayerSample* _sample;
|
||||
QCheckBox* _checkBox;
|
||||
|
||||
public:
|
||||
ScreenLayerEntry ( ScreenLayer* layer, LayersList* layerList );
|
||||
|
||||
public:
|
||||
bool isChecked () const;
|
||||
void setChecked ( bool state );
|
||||
QCheckBox* getCheckBox () { return _checkBox; };
|
||||
|
||||
public slots:
|
||||
void toggle ();
|
||||
};
|
||||
|
||||
|
||||
class LayersList : public QScrollArea {
|
||||
Q_OBJECT;
|
||||
|
||||
protected:
|
||||
CellWidget* _cellWidget;
|
||||
vector<ScreenLayerEntry*> _entries;
|
||||
QPushButton* _showAll;
|
||||
QPushButton* _hideAll;
|
||||
|
||||
public:
|
||||
LayersList ( CellWidget* cellWidget );
|
||||
|
||||
public:
|
||||
CellWidget* getCellWidget () { return _cellWidget; };
|
||||
vector<ScreenLayerEntry*>& getEntries () { return _entries; };
|
||||
bool isVisible ( size_t index );
|
||||
|
||||
public slots:
|
||||
void showAll ();
|
||||
void hideAll ();
|
||||
};
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# include <QPainter>
|
||||
|
||||
# include "BasicLayer.h"
|
||||
|
||||
# include "ScreenUtilities.h"
|
||||
# include "ScreenLayer.h"
|
||||
# include "Graphics.h"
|
||||
|
||||
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
LayerSample::LayerSample ( ScreenLayer* layer )
|
||||
: QWidget()
|
||||
, _sample(QSize(20,20))
|
||||
, _layer(layer)
|
||||
{
|
||||
setAttribute ( Qt::WA_StaticContents );
|
||||
setSizePolicy ( QSizePolicy::Fixed, QSizePolicy::Fixed );
|
||||
setFixedSize ( 20, 20 );
|
||||
|
||||
redraw ();
|
||||
}
|
||||
|
||||
|
||||
void LayerSample::redraw ()
|
||||
{
|
||||
QPainter painter ( &_sample );
|
||||
|
||||
painter.setPen ( Qt::NoPen );
|
||||
painter.setBackground ( Graphics::getBrush("background") );
|
||||
painter.eraseRect ( 0, 0, 20, 20 );
|
||||
painter.setPen ( Graphics::getPen (_layer->getName()) );
|
||||
painter.setBrush ( Graphics::getBrush(_layer->getName()) );
|
||||
painter.drawRect ( 2, 2, 16, 16 );
|
||||
}
|
||||
|
||||
|
||||
void LayerSample::paintEvent ( QPaintEvent* )
|
||||
{
|
||||
QPainter painter ( this );
|
||||
painter.drawPixmap ( 0, 0, _sample );
|
||||
}
|
||||
|
||||
|
||||
ScreenLayer::ScreenLayer ( BasicLayer* basicLayer
|
||||
, size_t index
|
||||
, bool isVisible
|
||||
) : _layer(basicLayer)
|
||||
, _isVisible(isVisible)
|
||||
{}
|
||||
|
||||
|
||||
const Name& ScreenLayer::getName () const
|
||||
{
|
||||
return _layer->getName ();
|
||||
}
|
||||
|
||||
|
||||
LayerSample* ScreenLayer::getSample ()
|
||||
{
|
||||
return new LayerSample ( this );
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
|
@ -0,0 +1,86 @@
|
|||
|
||||
// -*- C++ -*-
|
||||
|
||||
|
||||
# ifndef __SCREENLAYER_H__
|
||||
# define __SCREENLAYER_H__
|
||||
|
||||
# include <string>
|
||||
# include <QBrush>
|
||||
# include <QPixmap>
|
||||
# include <QWidget>
|
||||
|
||||
class QPaintEvent;
|
||||
|
||||
# include "Commons.h"
|
||||
|
||||
|
||||
namespace Hurricane {
|
||||
|
||||
|
||||
class Name;
|
||||
class BasicLayer;
|
||||
class ScreenLayer;
|
||||
|
||||
|
||||
class LayerSample : public QWidget {
|
||||
Q_OBJECT;
|
||||
|
||||
protected:
|
||||
QPixmap _sample;
|
||||
ScreenLayer* _layer;
|
||||
|
||||
public:
|
||||
LayerSample ( ScreenLayer* layer );
|
||||
|
||||
protected:
|
||||
void redraw ();
|
||||
void paintEvent ( QPaintEvent* );
|
||||
|
||||
public:
|
||||
|
||||
inline void setVisible ( bool state );
|
||||
};
|
||||
|
||||
|
||||
class ScreenLayer {
|
||||
|
||||
protected:
|
||||
BasicLayer* _layer;
|
||||
bool _isVisible;
|
||||
QBrush _brush;
|
||||
|
||||
// Constructor.
|
||||
public:
|
||||
ScreenLayer ( BasicLayer* layer, size_t index, bool isVisible );
|
||||
|
||||
// Predicates.
|
||||
public:
|
||||
bool isVisible () const { return _isVisible; };
|
||||
// Accessors.
|
||||
public:
|
||||
BasicLayer* getBasicLayer () const { return _layer; };
|
||||
const Name& getName () const;
|
||||
|
||||
// Methods.
|
||||
public:
|
||||
LayerSample* getSample ();
|
||||
|
||||
// Modifiers.
|
||||
public:
|
||||
inline void setVisible ( bool state ) { _isVisible=state; };
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
inline void LayerSample::setVisible ( bool state )
|
||||
{
|
||||
_layer->setVisible ( state );
|
||||
}
|
||||
|
||||
|
||||
} // End of Hurricane namespace.
|
||||
|
||||
|
||||
# endif
|