Prior to new hviewer

This commit is contained in:
Jean-Paul Chaput 2008-05-16 15:27:43 +00:00
parent 5d092e27c0
commit 26b932683c
27 changed files with 54 additions and 1880 deletions

View File

@ -1,4 +1,4 @@
add_subdirectory(hurricane)
add_subdirectory(hinspector)
add_subdirectory(hviewer)
add_subdirectory(viewer)
add_subdirectory(pyext)

View File

@ -61,6 +61,8 @@ class BasicLayer : public Layer {
private: unsigned short _blueValue;
private: string _fillPattern;
private: double _displayThreshold;
private: BasicLayer* _connectorLayer;
private: BasicLayer* _obstructionLayer;
// Constructors
// ************
@ -80,6 +82,8 @@ class BasicLayer : public Layer {
public: const string& getFillPattern() const {return _fillPattern;};
public: double getDisplayThreshold() const {return _displayThreshold;};
public: virtual BasicLayers getBasicLayers() const;
public: virtual BasicLayer* getConnectorLayer() const {return _connectorLayer;};
public: virtual BasicLayer* getObstructionLayer() const {return _obstructionLayer;};
// Updators
// ********
@ -87,6 +91,8 @@ class BasicLayer : public Layer {
public: void setColor(unsigned short redValue, unsigned short greenValue, unsigned short blueValue);
public: void setFillPattern(const string& fillPattern);
public: void setDisplayThreshold(double threshold) {_displayThreshold = threshold;};
public: void setConnectorLayer(BasicLayer* layer) {_connectorLayer = layer;};
public: void setObstructionLayer(BasicLayer* layer) {_obstructionLayer = layer;};
// Others
// ******

View File

@ -104,6 +104,48 @@ void CompositeLayer::add(BasicLayer* basicLayer, const Unit& contactSize, const
_maximalPadSize = max(padSize, _maximalPadSize);
}
void CompositeLayer::setContactSize(BasicLayer* basicLayer, const Unit& contactSize)
// *********************************************************************************
{
if (!basicLayer)
throw Error("Can't add basic layer : null basic layer");
if (!contains(basicLayer))
throw Error("Basic layer not part of composite layer");
if (contactSize != 0) _contactSizeMap[basicLayer] = contactSize;
_maximalContactSize = max(contactSize, _maximalContactSize);
}
void CompositeLayer::setSegmentSize(BasicLayer* basicLayer, const Unit& segmentSize)
// *********************************************************************************
{
if (!basicLayer)
throw Error("Can't add basic layer : null basic layer");
if (!contains(basicLayer))
throw Error("Basic layer not part of composite layer");
if (segmentSize != 0) _segmentSizeMap[basicLayer] = segmentSize;
_maximalSegmentSize = max(segmentSize, _maximalSegmentSize);
}
void CompositeLayer::setSegmentExtention(BasicLayer* basicLayer, const Unit& segmentExtention)
// *********************************************************************************
{
if (!basicLayer)
throw Error("Can't add basic layer : null basic layer");
if (!contains(basicLayer))
throw Error("Basic layer not part of composite layer");
if (segmentExtention != 0) _segmentExtentionMap[basicLayer] = segmentExtention;
_maximalSegmentExtention = max(segmentExtention, _maximalSegmentExtention);
}
void CompositeLayer::remove(BasicLayer* basicLayer)
// ************************************************
{

View File

@ -92,6 +92,9 @@ class CompositeLayer : public Layer {
// ********
public: void add(BasicLayer* basicLayer, const Unit& contactSize, const Unit& segmentSize, const Unit& segmentExtention, const Unit& padSize);
public: void setContactSize(BasicLayer* basicLayer, const Unit& contactSize);
public: void setSegmentSize(BasicLayer* basicLayer, const Unit& segmentSize);
public: void setSegmentExtention(BasicLayer* basicLayer, const Unit& segmentExtention);
public: void remove(BasicLayer* basicLayer);
// Others

View File

@ -60,6 +60,8 @@ class Layer : public DBo {
public: const Unit& getMinimalSpacing() const {return _minimalSpacing;};
public: Unit getPitch() const {return (_pitch==0?(_minimalSize + _minimalSpacing):_pitch);};
public: virtual BasicLayers getBasicLayers() const = 0;
public: virtual Layer* getConnectorLayer() const {return NULL;};
public: virtual Layer* getObstructionLayer() const {return NULL;};
// Predicates
// **********

View File

@ -1,17 +0,0 @@
include(${QT_USE_FILE})
include_directories(${HURRICANE_SOURCE_DIR}/src/hurricane)
set(includes ScreenUtilities.h DisplayStyle.h)
set(mocincludes ScreenLayer.h LayersList.h CellWidget.h CellViewer.h)
set(exports CellViewer.h)
set(cpps ScreenUtilities.cpp DisplayStyle.cpp ScreenLayer.cpp LayersList.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)

View File

@ -1,144 +0,0 @@
// -*- C++ -*-
# include <QAction>
# include <QMenu>
# include <QMenuBar>
# include <QDockWidget>
# include "Cell.h"
# include "CellWidget.h"
//# include "MapView.h"
# include "LayersList.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)
, _layersList(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 );
_layersList = _cellWidget->getLayersList ();
//_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 ( "LayersList" );
layerMapDock->setWidget ( _layersList );
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.

View File

@ -1,64 +0,0 @@
// -*- C++ -*-
# ifndef __CELLVIEWER_H__
# define __CELLVIEWER_H__
using namespace std;
# include <QMainWindow>
class QKeyEvent;
class QAction;
class QMenu;
# include "Commons.h"
namespace Hurricane {
class Cell;
class LayersList;
//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;
LayersList* _layersList;
CellWidget* _cellWidget;
public:
CellViewer ( Cell* cell );
protected:
void createActions ();
void createMenus ();
void createLayout ( Cell* cell );
};
} // End of Hurricane namespace.
# endif

View File

@ -1,12 +0,0 @@
<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>

View File

@ -1,722 +0,0 @@
// -*- 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 "ScreenLayer.h"
# include "LayersList.h"
// # include "MapView.h"
# include "CellWidget.h"
namespace Hurricane {
const int CellWidget::_stripWidth = 100;
CellWidget::CellWidget ( Cell* cell ) : QWidget()
, _styles()
, _activeStyle(NULL)
, _screenLayers()
, _layersList(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 );
// Build ScreenLayer vector here from BasicLayers.
DataBase* database = getDataBase();
if (database) {
Technology* technology = database->getTechnology();
if (technology) {
for_each_basic_layer ( layer, technology->getBasicLayers() ) {
_screenLayers.push_back ( new ScreenLayer(layer,_screenLayers.size(),true) );
end_for;
}
}
}
//_mapView = new MapView ( this );
_layersList = new LayersList ( this );
_styles [ "Alliance" ] = DisplayStyle ();
_activeStyle = &_styles [ "Alliance" ];
fitToContents ();
_openCell = false;
}
CellWidget::~CellWidget ()
{
cerr << "CellWidget::~CellWidget()" << endl;
for ( size_t i=0 ; i < _screenLayers.size() ; i++ )
delete _screenLayers[i];
}
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 )
{
//cerr << "CellWidget::redraw ()" << endl;
_redrawRectCount = 0;
pushCursor ( Qt::BusyCursor );
_painter.begin ( &_drawingBuffer );
_painter.setPen ( Qt::NoPen );
_painter.setBackground ( _activeStyle->getBrush("background") );
_painter.setClipRect ( redrawArea );
_painter.eraseRect ( redrawArea );
Box redrawBox = getBox ( redrawArea );
// cerr << " Box: " << redrawBox << endl;
// cerr << " Rect: " << redrawArea.x() << ","
// << redrawArea.y() << " "
// << redrawArea.width() << "x"
// << redrawArea.height() << endl;
for ( size_t i=0 ; i<_screenLayers.size() ; i++ ) {
if ( isDrawable(_screenLayers[i]) ) {
_painter.setBrush ( _screenLayers[i]->getBrush() );
drawCell ( _cell, _screenLayers[i]->getBasicLayer(), redrawBox, Transformation() );
}
}
if ( _showBoundaries ) {
_painter.setPen ( getPen ("boundaries") );
_painter.setBrush ( getBrush("boundaries") );
drawBoundaries ( _cell, redrawBox, Transformation() );
}
_painter.end ();
update ();
popCursor ();
cerr << "Redrawed rectangles: " << _redrawRectCount << endl;
//cerr << "*******************************************************" << endl;
}
void CellWidget::addStyle ( const string& key, DisplayStyle& displayStyle )
{
if ( _styles.find(key) != _styles.end() )
cerr << "[WARNING] CellWidget::addStyle(): overriding style \"" << key << "\"." << endl;
_styles [ key ] = displayStyle;
_activeStyle = & _styles [ key ];
}
void CellWidget::setStyle ( const string& key )
{
if ( _styles.find(key) == _styles.end() ) {
cerr << "[WARNING] CellWidget::setStyle(): no style named \"" << key << "\"." << endl;
return;
}
_activeStyle = & _styles [ key ];
}
void CellWidget::drawBoundaries ( const Cell* cell
, const Box& redrawArea
, const Transformation& transformation
)
{
// cerr << "CellWidget::drawBoudaries ()" << endl;
// QRect rect = getScreenRect(transformation.getBox(cell->getAbutmentBox()));
// cerr << " Box: " << transformation.getBox(cell->getAbutmentBox()) << endl;
// cerr << " Rect: " << rect.x() << "+" << rect.y()
// << "," << rect.width() << "x" << rect.height() << endl;
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 ( const ScreenLayer* screenLayer )
{
return screenLayer->isVisible()
&& ( screenLayer->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.

View File

@ -1,236 +0,0 @@
// -*- C++ -*-
# ifndef __CELLWIDGET_H__
# define __CELLWIDGET_H__
# include <math.h>
# include <vector>
# include <map>
# 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 ScreenLayer;
class LayersList;
//class MapView;
class CellWidget : public QWidget {
Q_OBJECT;
// Attributes.
protected:
static const int _stripWidth;
map<string,DisplayStyle> _styles;
DisplayStyle* _activeStyle;
vector<ScreenLayer*> _screenLayers;
vector<Qt::CursorShape> _cursors;
// MapView* _mapView;
LayersList* _layersList;
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 addStyle ( const string& key, DisplayStyle& displayStyle );
void setStyle ( const string& key );
inline const QPen& getPen ( const string& key );
inline const QBrush& getBrush ( const string& key );
void drawBoundaries ( const Cell* , const Box&, const Transformation& );
void drawBoundaries ( const Instance*, const Box&, const Transformation& );
bool isDrawable ( const ScreenLayer* screenLayer );
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; };
LayersList* getLayersList () { return _layersList; };
vector<ScreenLayer*>& getScreenLayers () { return _screenLayers; };
inline Cell* getCell () const;
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 const QPen& CellWidget::getPen ( const string& key )
{
return _activeStyle->getPen ( key );
}
inline const QBrush& CellWidget::getBrush ( const string& key )
{
return _activeStyle->getBrush ( key );
}
inline Cell* CellWidget::getCell () const
{
return _cell;
}
inline bool CellWidget::showBoundaries () const
{
return _showBoundaries;
}
} // End of Hurricane namespace.
# endif

View File

@ -1,94 +0,0 @@
// -*- C++ -*-
# include "DisplayStyle.h"
namespace Hurricane {
DisplayStyle::DrawingStyle::DrawingStyle ( const string& pattern
, int red
, int green
, int blue
, int borderWidth
) : _pattern(pattern)
, _color(QColor(red,green,blue))
, _pen(_color)
, _brush(Hurricane::getBrush(_pattern,red,green,blue))
{
if ( borderWidth ) {
_pen.setWidth ( borderWidth );
} else {
_pen.setStyle ( Qt::NoPen );
}
}
DisplayStyle::DisplayStyle () : _drawingStyles()
{
addDrawingStyle ( "fallback" , "FFFFFFFFFFFFFFFF", 0, 0, 0, 1 );
addDrawingStyle ( "background" , "FFFFFFFFFFFFFFFF", 50, 50, 50, 1 );
addDrawingStyle ( "foreground" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
addDrawingStyle ( "rubber" , "FFFFFFFFFFFFFFFF", 192, 0, 192, 1 );
addDrawingStyle ( "phantom" , "FFFFFFFFFFFFFFFF", 139, 134, 130, 1 );
addDrawingStyle ( "boundaries" , "0000000000000000", 208, 199, 192, 1 );
addDrawingStyle ( "marker" , "FFFFFFFFFFFFFFFF", 80, 250, 80, 1 );
addDrawingStyle ( "selectionDraw", "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
addDrawingStyle ( "selectionFill", "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
addDrawingStyle ( "grid" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
addDrawingStyle ( "spot" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
addDrawingStyle ( "ghost" , "FFFFFFFFFFFFFFFF", 255, 255, 255, 1 );
}
const string& DisplayStyle::getPattern ( const string& key ) const
{
return findDrawingStyle(key).getPattern();
}
const QColor& DisplayStyle::getColor ( const string& key ) const
{
return findDrawingStyle(key).getColor();
}
const QPen& DisplayStyle::getPen ( const string& key ) const
{
return findDrawingStyle(key).getPen();
}
const QBrush& DisplayStyle::getBrush ( const string& key ) const
{
return findDrawingStyle(key).getBrush();
}
const DisplayStyle::DrawingStyle& DisplayStyle::findDrawingStyle ( const string& key ) const
{
StyleIterator it = _drawingStyles.find ( key );
if ( it != _drawingStyles.end() ) return it->second;
return _drawingStyles.find("fallback")->second;
}
void DisplayStyle::addDrawingStyle ( const string& key
, const string& pattern
, int red
, int green
, int blue
, int borderWidth
)
{
_drawingStyles [ key ] = DrawingStyle ( pattern, red, green, blue, borderWidth );
}
}

View File

@ -1,101 +0,0 @@
// -*- C++ -*-
# ifndef __DISPLAYSTYLE_H__
# define __DISPLAYSTYLE_H__
# include <string>
# include <map>
# include <QColor>
# include <QPen>
# include <QBrush>
# include "Commons.h"
# include "ScreenUtilities.h"
namespace Hurricane {
class DisplayStyle {
// Sub-Class.
protected:
class DrawingStyle {
// Attributes.
protected:
string _pattern;
QColor _color;
QPen _pen;
QBrush _brush;
// Constructor.
public:
DrawingStyle ( const string& pattern ="FFFFFFFFFFFFFFFF"
, int red =0
, int green =0
, int blue =0
, int borderWidth=0
);
// Accessors.
public:
inline const string& getPattern () const;
inline const QColor& getColor () const;
inline const QPen& getPen () const;
inline const QBrush& getBrush () const;
};
typedef map<string,DrawingStyle> StyleMap;
typedef map<string,DrawingStyle>::const_iterator StyleIterator;
// Attributes.
protected:
StyleMap _drawingStyles;
// Constructor.
public:
DisplayStyle ();
// Accessors.
public:
const string& getPattern ( const string& key ) const;
const QColor& getColor ( const string& key ) const;
const QPen& getPen ( const string& key ) const;
const QBrush& getBrush ( const string& key ) const;
// Methods.
protected:
const DrawingStyle& findDrawingStyle ( const string& key ) const;
// Modifiers.
public:
void addDrawingStyle ( const string& key
, const string& pattern
, int red
, int green
, int blue
, int borderWidth
);
};
// Functions.
inline const string& DisplayStyle::DrawingStyle::getPattern () const { return _pattern; }
inline const QColor& DisplayStyle::DrawingStyle::getColor () const { return _color; }
inline const QPen& DisplayStyle::DrawingStyle::getPen () const { return _pen; }
inline const QBrush& DisplayStyle::DrawingStyle::getBrush () const { return _brush; }
}
# endif

View File

@ -1,134 +0,0 @@
// -*- 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.

View File

@ -1,79 +0,0 @@
// -*- 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

View File

@ -1,72 +0,0 @@
// -*- C++ -*-
# include <QPainter>
# include "BasicLayer.h"
# include "ScreenUtilities.h"
# include "ScreenLayer.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 ( QBrush(Qt::black,Qt::SolidPattern) );
painter.eraseRect ( 0, 0, 20, 20 );
painter.setBrush ( _layer->getBrush() );
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)
, _index(index)
, _isVisible(isVisible)
, _brush(Hurricane::getBrush(_layer))
{}
const Name& ScreenLayer::getName () const
{
return _layer->getName ();
}
LayerSample* ScreenLayer::getSample ()
{
return new LayerSample ( this );
}
} // End of Hurricane namespace.

View File

@ -1,89 +0,0 @@
// -*- 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;
size_t _index;
bool _isVisible;
QBrush _brush;
// Constructor.
public:
ScreenLayer ( BasicLayer* layer, size_t index, bool isVisible );
// Predicates.
public:
bool isVisible () const { return _isVisible; };
// Accessors.
public:
size_t getIndex () const { return _index; };
BasicLayer* getBasicLayer () const { return _layer; };
const Name& getName () const;
// Methods.
public:
const QBrush& getBrush () const { return _brush; };
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

View File

@ -1,84 +0,0 @@
// -*- 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.

View File

@ -1,31 +0,0 @@
// -*- C++ -*-
# ifndef __SCREENUTILITIES_H__
# define __SCREENUTILITIES_H__
# include <string>
# include <QBrush>
# include "Commons.h"
namespace Hurricane {
class BasicLayer;
// Functions.
QBrush getBrush ( const string& pattern, int red, int green, int blue );
QBrush getBrush ( const BasicLayer* layer );
} // End of Hurricane namespace.
# endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 522 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 523 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 923 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 850 B