* ./hurricane/src/hviewer :
- Grid & Spot support (adjusted display threshold). - Added new copyToScreen() functions for _drawingBuffer to screen refreshment or partial copy (useful for Spot).
This commit is contained in:
parent
686b97f1ec
commit
a743cf53a3
|
@ -135,6 +135,10 @@ namespace Hurricane {
|
||||||
// addDockWidget ( Qt::RightDockWidgetArea, mapViewDock );
|
// addDockWidget ( Qt::RightDockWidgetArea, mapViewDock );
|
||||||
|
|
||||||
QDockWidget* layerMapDock = new QDockWidget ( tr("Layers") );
|
QDockWidget* layerMapDock = new QDockWidget ( tr("Layers") );
|
||||||
|
layerMapDock->setFeatures ( QDockWidget::DockWidgetVerticalTitleBar
|
||||||
|
| QDockWidget::DockWidgetMovable
|
||||||
|
| QDockWidget::DockWidgetFloatable
|
||||||
|
);
|
||||||
layerMapDock->setObjectName ( "Palette" );
|
layerMapDock->setObjectName ( "Palette" );
|
||||||
layerMapDock->setWidget ( _palette );
|
layerMapDock->setWidget ( _palette );
|
||||||
layerMapDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
layerMapDock->setAllowedAreas ( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
|
||||||
|
|
|
@ -34,11 +34,58 @@
|
||||||
namespace Hurricane {
|
namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Class : "Hurricane::CellWidget::Spot".
|
||||||
|
|
||||||
|
|
||||||
|
CellWidget::Spot::Spot ( CellWidget* cw )
|
||||||
|
: _cellWidget(cw)
|
||||||
|
, _spotPoint()
|
||||||
|
, _restore(false)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
|
||||||
|
void CellWidget::Spot::restore ()
|
||||||
|
{
|
||||||
|
if ( _restore ) {
|
||||||
|
_cellWidget->copyToScreen ( _spotPoint.x()-5, _spotPoint.y()-5, 10, 10 );
|
||||||
|
_restore = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CellWidget::Spot::setRestore ( bool state )
|
||||||
|
{
|
||||||
|
_restore = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void CellWidget::Spot::moveTo ( const QPoint& screenPoint )
|
||||||
|
{
|
||||||
|
QPainter& screenPainter = _cellWidget->getScreenPainter();
|
||||||
|
|
||||||
|
Point mousePoint = _cellWidget->screenToDbuPoint ( screenPoint );
|
||||||
|
Point spotPoint = Point ( DbU::getOnSnapGrid(mousePoint.getX())
|
||||||
|
, DbU::getOnSnapGrid(mousePoint.getY())
|
||||||
|
);
|
||||||
|
QPoint center = _cellWidget->dbuToScreenPoint(spotPoint);
|
||||||
|
|
||||||
|
restore ();
|
||||||
|
_restore = true;
|
||||||
|
|
||||||
|
screenPainter.setPen ( Graphics::getPen("spot") );
|
||||||
|
screenPainter.drawRect ( center.x()-3, center.y()-3, 6, 6 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Class : "Hurricane::CellWidget".
|
||||||
|
|
||||||
|
|
||||||
const int CellWidget::_stripWidth = 100;
|
const int CellWidget::_stripWidth = 100;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CellWidget::CellWidget ( QWidget* parent ) : QWidget(parent)
|
CellWidget::CellWidget ( QWidget* parent ) : QWidget(parent)
|
||||||
, _statusBar(NULL)
|
, _statusBar(NULL)
|
||||||
, _palette(NULL)
|
, _palette(NULL)
|
||||||
|
@ -49,8 +96,10 @@ namespace Hurricane {
|
||||||
, _scale(1.0)
|
, _scale(1.0)
|
||||||
, _offsetVA(_stripWidth,_stripWidth)
|
, _offsetVA(_stripWidth,_stripWidth)
|
||||||
, _drawingBuffer(6*_stripWidth,6*_stripWidth)
|
, _drawingBuffer(6*_stripWidth,6*_stripWidth)
|
||||||
, _painter()
|
, _drawingPainter()
|
||||||
|
, _screenPainter()
|
||||||
, _lastMousePosition(0,0)
|
, _lastMousePosition(0,0)
|
||||||
|
, _spot(this)
|
||||||
, _cell(NULL)
|
, _cell(NULL)
|
||||||
, _mouseGo(false)
|
, _mouseGo(false)
|
||||||
, _showBoundaries(true)
|
, _showBoundaries(true)
|
||||||
|
@ -121,20 +170,21 @@ namespace Hurricane {
|
||||||
|
|
||||||
pushCursor ( Qt::BusyCursor );
|
pushCursor ( Qt::BusyCursor );
|
||||||
|
|
||||||
_painter.begin ( &_drawingBuffer );
|
_spot.setRestore ( false );
|
||||||
|
_drawingPainter.begin ( &_drawingBuffer );
|
||||||
|
|
||||||
_painter.setPen ( Qt::NoPen );
|
_drawingPainter.setPen ( Qt::NoPen );
|
||||||
_painter.setBackground ( Graphics::getBrush("background") );
|
_drawingPainter.setBackground ( Graphics::getBrush("background") );
|
||||||
_painter.setClipRect ( redrawArea );
|
_drawingPainter.setClipRect ( redrawArea );
|
||||||
_painter.eraseRect ( redrawArea );
|
_drawingPainter.eraseRect ( redrawArea );
|
||||||
|
|
||||||
if ( _cell ) {
|
if ( _cell ) {
|
||||||
Box redrawBox = displayToDbuBox ( redrawArea );
|
Box redrawBox = displayToDbuBox ( redrawArea );
|
||||||
|
|
||||||
vector<PaletteEntry*>& paletteEntries = _palette->getEntries ();
|
vector<PaletteEntry*>& paletteEntries = _palette->getEntries ();
|
||||||
for ( size_t i=0 ; i<paletteEntries.size() ; i++ ) {
|
for ( size_t i=0 ; i<paletteEntries.size() ; i++ ) {
|
||||||
_painter.setPen ( Graphics::getPen (paletteEntries[i]->getName()) );
|
_drawingPainter.setPen ( Graphics::getPen (paletteEntries[i]->getName()) );
|
||||||
_painter.setBrush ( Graphics::getBrush(paletteEntries[i]->getName()) );
|
_drawingPainter.setBrush ( Graphics::getBrush(paletteEntries[i]->getName()) );
|
||||||
|
|
||||||
if ( paletteEntries[i]->isBasicLayer() && isDrawable(paletteEntries[i]) ) {
|
if ( paletteEntries[i]->isBasicLayer() && isDrawable(paletteEntries[i]) ) {
|
||||||
drawCell ( _cell, paletteEntries[i]->getBasicLayer(), redrawBox, Transformation() );
|
drawCell ( _cell, paletteEntries[i]->getBasicLayer(), redrawBox, Transformation() );
|
||||||
|
@ -145,7 +195,7 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_painter.end ();
|
_drawingPainter.end ();
|
||||||
|
|
||||||
update ();
|
update ();
|
||||||
popCursor ();
|
popCursor ();
|
||||||
|
@ -303,32 +353,41 @@ namespace Hurricane {
|
||||||
void CellWidget::drawBox ( const Box& box )
|
void CellWidget::drawBox ( const Box& box )
|
||||||
{
|
{
|
||||||
_redrawRectCount++;
|
_redrawRectCount++;
|
||||||
_painter.drawRect ( dbuToDisplayRect(box) );
|
_drawingPainter.drawRect ( dbuToDisplayRect(box) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CellWidget::drawLine ( const Point& p1, const Point& p2 )
|
void CellWidget::drawLine ( const Point& p1, const Point& p2 )
|
||||||
{
|
{
|
||||||
_painter.drawLine ( dbuToDisplayPoint(p1), dbuToDisplayPoint(p2) );
|
_drawingPainter.drawLine ( dbuToDisplayPoint(p1), dbuToDisplayPoint(p2) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CellWidget::drawGrid ()
|
void CellWidget::drawGrid ()
|
||||||
{
|
{
|
||||||
cerr << "drawGrid()" << endl;
|
_screenPainter.setPen ( Graphics::getPen("grid") );
|
||||||
|
|
||||||
QPainter painter ( this );
|
DbU::Unit gridStep = DbU::getSnapGridStep();
|
||||||
|
DbU::Unit superGridStep = gridStep*5;
|
||||||
|
DbU::Unit xGrid;
|
||||||
|
DbU::Unit yGrid;
|
||||||
|
QPoint center;
|
||||||
|
|
||||||
painter.setPen ( Graphics::getPen("grid") );
|
for ( yGrid = DbU::getOnSnapGrid(_visibleArea.getYMin())
|
||||||
|
; yGrid < _visibleArea.getYMax()
|
||||||
DbU::Unit gridStep = DbU::getSnapGridStep();
|
; yGrid += gridStep
|
||||||
DbU::Unit xGrid = DbU::getOnSnapGrid(_visibleArea.getXMin());
|
) {
|
||||||
DbU::Unit yGrid = DbU::getOnSnapGrid(_visibleArea.getYMin());
|
for ( xGrid = DbU::getOnSnapGrid(_visibleArea.getXMin())
|
||||||
|
; xGrid < _visibleArea.getXMax()
|
||||||
for ( ; yGrid < _visibleArea.getYMax() ; yGrid += gridStep ) {
|
; xGrid += gridStep
|
||||||
for ( ; xGrid < _visibleArea.getXMax() ; xGrid += gridStep ) {
|
) {
|
||||||
cerr << xGrid << " " << yGrid << " -> " << dbuToScreenX(xGrid) << " " << dbuToScreenY(yGrid) << endl;
|
center = dbuToScreenPoint(xGrid,yGrid);
|
||||||
painter.drawPoint ( dbuToScreenPoint(xGrid,yGrid) );
|
if ( (xGrid % superGridStep) || (yGrid % superGridStep) )
|
||||||
|
_screenPainter.drawPoint ( center );
|
||||||
|
else {
|
||||||
|
_screenPainter.drawLine ( center.x()-3, center.y() , center.x()+3, center.y() );
|
||||||
|
_screenPainter.drawLine ( center.x() , center.y()-3, center.x() , center.y()+3 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,6 +396,9 @@ namespace Hurricane {
|
||||||
void CellWidget::goLeft ( int dx )
|
void CellWidget::goLeft ( int dx )
|
||||||
{
|
{
|
||||||
if ( !dx ) dx = geometry().size().width() / 4;
|
if ( !dx ) dx = geometry().size().width() / 4;
|
||||||
|
|
||||||
|
_visibleArea.translate ( - (DbU::Unit)( dx / _scale ) , 0 );
|
||||||
|
|
||||||
if ( _offsetVA.rx() - dx >= 0 ) {
|
if ( _offsetVA.rx() - dx >= 0 ) {
|
||||||
_offsetVA.rx() -= dx;
|
_offsetVA.rx() -= dx;
|
||||||
update ();
|
update ();
|
||||||
|
@ -351,6 +413,7 @@ namespace Hurricane {
|
||||||
if ( !dx ) dx = geometry().size().width() / 4;
|
if ( !dx ) dx = geometry().size().width() / 4;
|
||||||
|
|
||||||
//cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl;
|
//cerr << "CellWidget::goRight() - dx: " << dx << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||||
|
_visibleArea.translate ( (DbU::Unit)( dx / _scale ) , 0 );
|
||||||
|
|
||||||
if ( _offsetVA.rx() + dx < 2*_stripWidth ) {
|
if ( _offsetVA.rx() + dx < 2*_stripWidth ) {
|
||||||
_offsetVA.rx() += dx;
|
_offsetVA.rx() += dx;
|
||||||
|
@ -364,6 +427,9 @@ namespace Hurricane {
|
||||||
void CellWidget::goUp ( int dy )
|
void CellWidget::goUp ( int dy )
|
||||||
{
|
{
|
||||||
if ( !dy ) dy = geometry().size().height() / 4;
|
if ( !dy ) dy = geometry().size().height() / 4;
|
||||||
|
|
||||||
|
_visibleArea.translate ( 0, (DbU::Unit)( dy / _scale ) );
|
||||||
|
|
||||||
if ( _offsetVA.ry() - dy >= 0 ) {
|
if ( _offsetVA.ry() - dy >= 0 ) {
|
||||||
_offsetVA.ry() -= dy;
|
_offsetVA.ry() -= dy;
|
||||||
update ();
|
update ();
|
||||||
|
@ -376,6 +442,9 @@ namespace Hurricane {
|
||||||
void CellWidget::goDown ( int dy )
|
void CellWidget::goDown ( int dy )
|
||||||
{
|
{
|
||||||
if ( !dy ) dy = geometry().size().height() / 4;
|
if ( !dy ) dy = geometry().size().height() / 4;
|
||||||
|
|
||||||
|
_visibleArea.translate ( 0, - (DbU::Unit)( dy / _scale ) );
|
||||||
|
|
||||||
if ( _offsetVA.ry() + dy < 2*_stripWidth ) {
|
if ( _offsetVA.ry() + dy < 2*_stripWidth ) {
|
||||||
_offsetVA.ry() += dy;
|
_offsetVA.ry() += dy;
|
||||||
update ();
|
update ();
|
||||||
|
@ -385,7 +454,7 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CellWidget::screenReframe ()
|
void CellWidget::displayReframe ()
|
||||||
{
|
{
|
||||||
_offsetVA.rx() = _stripWidth;
|
_offsetVA.rx() = _stripWidth;
|
||||||
_offsetVA.ry() = _stripWidth;
|
_offsetVA.ry() = _stripWidth;
|
||||||
|
@ -417,7 +486,7 @@ namespace Hurricane {
|
||||||
//cerr << "_visibleArea: " << _visibleArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
//cerr << "_visibleArea: " << _visibleArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
||||||
//cerr << " " << center << endl;
|
//cerr << " " << center << endl;
|
||||||
|
|
||||||
screenReframe ();
|
displayReframe ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -443,7 +512,7 @@ namespace Hurricane {
|
||||||
, (DbU::Unit)( center.getX() + width / _scale )
|
, (DbU::Unit)( center.getX() + width / _scale )
|
||||||
, (DbU::Unit)( center.getY() + height / _scale )
|
, (DbU::Unit)( center.getY() + height / _scale )
|
||||||
);
|
);
|
||||||
screenReframe ();
|
displayReframe ();
|
||||||
|
|
||||||
//cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
//cerr << " _displayArea: " << _displayArea << " (offset: " << _offsetVA.x() << ")" << endl;
|
||||||
}
|
}
|
||||||
|
@ -462,20 +531,19 @@ namespace Hurricane {
|
||||||
int leftShift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth;
|
int leftShift = ( 1 + ( dx - _offsetVA.rx() ) / _stripWidth ) * _stripWidth;
|
||||||
|
|
||||||
_displayArea.translate ( - (DbU::Unit)( leftShift / _scale ) , 0 );
|
_displayArea.translate ( - (DbU::Unit)( leftShift / _scale ) , 0 );
|
||||||
_visibleArea.translate ( - (DbU::Unit)( leftShift / _scale ) , 0 );
|
|
||||||
_offsetVA.rx() -= dx - leftShift;
|
_offsetVA.rx() -= dx - leftShift;
|
||||||
|
|
||||||
if ( leftShift >= _drawingBuffer.width() ) {
|
if ( leftShift >= _drawingBuffer.width() ) {
|
||||||
redraw ();
|
redraw ();
|
||||||
} else {
|
} else {
|
||||||
//cerr << "Left Shift " << leftShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
//cerr << "Left Shift " << leftShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||||
_painter.begin ( &_drawingBuffer );
|
_drawingPainter.begin ( &_drawingBuffer );
|
||||||
_painter.drawPixmap ( leftShift, 0
|
_drawingPainter.drawPixmap ( leftShift, 0
|
||||||
, _drawingBuffer
|
, _drawingBuffer
|
||||||
, 0, 0
|
, 0, 0
|
||||||
, _drawingBuffer.width()-leftShift, _drawingBuffer.height()
|
, _drawingBuffer.width()-leftShift, _drawingBuffer.height()
|
||||||
);
|
);
|
||||||
_painter.end ();
|
_drawingPainter.end ();
|
||||||
|
|
||||||
redraw ( QRect ( QPoint ( 0, 0 )
|
redraw ( QRect ( QPoint ( 0, 0 )
|
||||||
, QSize ( leftShift, _drawingBuffer.height() )) );
|
, QSize ( leftShift, _drawingBuffer.height() )) );
|
||||||
|
@ -492,7 +560,6 @@ namespace Hurricane {
|
||||||
int rightShift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth;
|
int rightShift = ( ( _offsetVA.rx() + dx ) / _stripWidth ) * _stripWidth;
|
||||||
|
|
||||||
_displayArea.translate ( (DbU::Unit)( rightShift / _scale ) , 0 );
|
_displayArea.translate ( (DbU::Unit)( rightShift / _scale ) , 0 );
|
||||||
_visibleArea.translate ( (DbU::Unit)( rightShift / _scale ) , 0 );
|
|
||||||
_offsetVA.rx() += dx - rightShift;
|
_offsetVA.rx() += dx - rightShift;
|
||||||
|
|
||||||
//cerr << " _displayArea: " << _displayArea << endl;
|
//cerr << " _displayArea: " << _displayArea << endl;
|
||||||
|
@ -501,13 +568,13 @@ namespace Hurricane {
|
||||||
redraw ();
|
redraw ();
|
||||||
} else {
|
} else {
|
||||||
//cerr << " Right Shift " << rightShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
//cerr << " Right Shift " << rightShift << " (offset: " << _offsetVA.rx() << ")" << endl;
|
||||||
_painter.begin ( &_drawingBuffer );
|
_drawingPainter.begin ( &_drawingBuffer );
|
||||||
_painter.drawPixmap ( 0, 0
|
_drawingPainter.drawPixmap ( 0, 0
|
||||||
, _drawingBuffer
|
, _drawingBuffer
|
||||||
, rightShift, 0
|
, rightShift, 0
|
||||||
, _drawingBuffer.width()-rightShift, _drawingBuffer.height()
|
, _drawingBuffer.width()-rightShift, _drawingBuffer.height()
|
||||||
);
|
);
|
||||||
_painter.end ();
|
_drawingPainter.end ();
|
||||||
|
|
||||||
redraw ( QRect ( QPoint ( _drawingBuffer.width()-rightShift, 0 )
|
redraw ( QRect ( QPoint ( _drawingBuffer.width()-rightShift, 0 )
|
||||||
, QSize ( rightShift, _drawingBuffer.height() )) );
|
, QSize ( rightShift, _drawingBuffer.height() )) );
|
||||||
|
@ -524,20 +591,19 @@ namespace Hurricane {
|
||||||
int upShift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth;
|
int upShift = ( 1 + ( dy - _offsetVA.ry() ) / _stripWidth ) * _stripWidth;
|
||||||
|
|
||||||
_displayArea.translate ( 0, (DbU::Unit)( upShift / _scale ) );
|
_displayArea.translate ( 0, (DbU::Unit)( upShift / _scale ) );
|
||||||
_visibleArea.translate ( 0, (DbU::Unit)( upShift / _scale ) );
|
|
||||||
_offsetVA.ry() -= dy - upShift;
|
_offsetVA.ry() -= dy - upShift;
|
||||||
|
|
||||||
if ( upShift >= _drawingBuffer.height() ) {
|
if ( upShift >= _drawingBuffer.height() ) {
|
||||||
redraw ();
|
redraw ();
|
||||||
} else {
|
} else {
|
||||||
//cerr << "Left Shift " << upShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
//cerr << "Left Shift " << upShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||||
_painter.begin ( &_drawingBuffer );
|
_drawingPainter.begin ( &_drawingBuffer );
|
||||||
_painter.drawPixmap ( 0, upShift
|
_drawingPainter.drawPixmap ( 0, upShift
|
||||||
, _drawingBuffer
|
, _drawingBuffer
|
||||||
, 0, 0
|
, 0, 0
|
||||||
, _drawingBuffer.width(), _drawingBuffer.height()-upShift
|
, _drawingBuffer.width(), _drawingBuffer.height()-upShift
|
||||||
);
|
);
|
||||||
_painter.end ();
|
_drawingPainter.end ();
|
||||||
|
|
||||||
redraw ( QRect ( QPoint ( 0, 0 )
|
redraw ( QRect ( QPoint ( 0, 0 )
|
||||||
, QSize ( _drawingBuffer.width(), upShift )) );
|
, QSize ( _drawingBuffer.width(), upShift )) );
|
||||||
|
@ -554,20 +620,19 @@ namespace Hurricane {
|
||||||
int downShift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth;
|
int downShift = ( ( _offsetVA.ry() + dy ) / _stripWidth ) * _stripWidth;
|
||||||
|
|
||||||
_displayArea.translate ( 0, - (DbU::Unit)( downShift / _scale ) );
|
_displayArea.translate ( 0, - (DbU::Unit)( downShift / _scale ) );
|
||||||
_visibleArea.translate ( 0, - (DbU::Unit)( downShift / _scale ) );
|
|
||||||
_offsetVA.ry() += dy - downShift;
|
_offsetVA.ry() += dy - downShift;
|
||||||
|
|
||||||
if ( downShift >= _drawingBuffer.height() ) {
|
if ( downShift >= _drawingBuffer.height() ) {
|
||||||
redraw ();
|
redraw ();
|
||||||
} else {
|
} else {
|
||||||
//cerr << "Right Shift " << downShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
//cerr << "Right Shift " << downShift << " (offset: " << _offsetVA.ry() << ")" << endl;
|
||||||
_painter.begin ( &_drawingBuffer );
|
_drawingPainter.begin ( &_drawingBuffer );
|
||||||
_painter.drawPixmap ( 0, 0
|
_drawingPainter.drawPixmap ( 0, 0
|
||||||
, _drawingBuffer
|
, _drawingBuffer
|
||||||
, 0, downShift
|
, 0, downShift
|
||||||
, _drawingBuffer.width(), _drawingBuffer.height()-downShift
|
, _drawingBuffer.width(), _drawingBuffer.height()-downShift
|
||||||
);
|
);
|
||||||
_painter.end ();
|
_drawingPainter.end ();
|
||||||
|
|
||||||
redraw ( QRect ( QPoint ( 0, _drawingBuffer.height()-downShift )
|
redraw ( QRect ( QPoint ( 0, _drawingBuffer.height()-downShift )
|
||||||
, QSize ( _drawingBuffer.width(), downShift )) );
|
, QSize ( _drawingBuffer.width(), downShift )) );
|
||||||
|
@ -579,12 +644,14 @@ namespace Hurricane {
|
||||||
|
|
||||||
void CellWidget::paintEvent ( QPaintEvent* )
|
void CellWidget::paintEvent ( QPaintEvent* )
|
||||||
{
|
{
|
||||||
//cerr << "CellWidget::paintEvent()" << endl;
|
_screenPainter.begin ( this );
|
||||||
|
|
||||||
QPainter painter ( this );
|
copyToScreen ();
|
||||||
painter.drawPixmap ( 0, 0, _drawingBuffer, _offsetVA.rx(), _offsetVA.ry(), width(), height() );
|
|
||||||
|
|
||||||
drawGrid ();
|
if ( isDrawable(_palette->find("grid")) ) drawGrid ();
|
||||||
|
if ( isDrawable(_palette->find("spot")) ) _spot.moveTo ( _lastMousePosition );
|
||||||
|
|
||||||
|
_screenPainter.end ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -656,6 +723,10 @@ namespace Hurricane {
|
||||||
//cerr << "x:" << event->x() << " y:" << event->y() << endl;
|
//cerr << "x:" << event->x() << " y:" << event->y() << endl;
|
||||||
_xPosition->setDynamicText ( screenToDbuX(event->x()) );
|
_xPosition->setDynamicText ( screenToDbuX(event->x()) );
|
||||||
_yPosition->setDynamicText ( screenToDbuY(event->y()) );
|
_yPosition->setDynamicText ( screenToDbuY(event->y()) );
|
||||||
|
|
||||||
|
_lastMousePosition = event->pos();
|
||||||
|
|
||||||
|
update ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ namespace Hurricane {
|
||||||
void drawBox ( const Box& );
|
void drawBox ( const Box& );
|
||||||
void drawLine ( const Point&, const Point& );
|
void drawLine ( const Point&, const Point& );
|
||||||
void drawGrid ();
|
void drawGrid ();
|
||||||
|
void drawSpot ();
|
||||||
// Geometric conversions.
|
// Geometric conversions.
|
||||||
QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2 ) const;
|
QRect dbuToDisplayRect ( DbU::Unit x1, DbU::Unit y1, DbU::Unit x2, DbU::Unit y2 ) const;
|
||||||
QRect dbuToDisplayRect ( const Box& box ) const;
|
QRect dbuToDisplayRect ( const Box& box ) const;
|
||||||
|
@ -89,12 +90,14 @@ namespace Hurricane {
|
||||||
inline int dbuToScreenX ( DbU::Unit x ) const;
|
inline int dbuToScreenX ( DbU::Unit x ) const;
|
||||||
inline int dbuToScreenY ( DbU::Unit y ) const;
|
inline int dbuToScreenY ( DbU::Unit y ) const;
|
||||||
QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const;
|
QPoint dbuToScreenPoint ( DbU::Unit x, DbU::Unit y ) const;
|
||||||
|
inline QPoint dbuToScreenPoint ( const Point& point ) const;
|
||||||
inline DbU::Unit displayToDbuX ( int x ) const;
|
inline DbU::Unit displayToDbuX ( int x ) const;
|
||||||
inline DbU::Unit displayToDbuY ( int y ) const;
|
inline DbU::Unit displayToDbuY ( int y ) const;
|
||||||
inline DbU::Unit displayToDbuLength ( int length ) const;
|
inline DbU::Unit displayToDbuLength ( int length ) const;
|
||||||
inline Box displayToDbuBox ( const QRect& rect ) const;
|
inline Box displayToDbuBox ( const QRect& rect ) const;
|
||||||
inline DbU::Unit screenToDbuX ( int x ) const;
|
inline DbU::Unit screenToDbuX ( int x ) const;
|
||||||
inline DbU::Unit screenToDbuY ( int y ) const;
|
inline DbU::Unit screenToDbuY ( int y ) const;
|
||||||
|
inline Point screenToDbuPoint ( const QPoint& point ) const;
|
||||||
// Qt QWidget Functions Overloads.
|
// Qt QWidget Functions Overloads.
|
||||||
void pushCursor ( Qt::CursorShape cursor );
|
void pushCursor ( Qt::CursorShape cursor );
|
||||||
void popCursor ();
|
void popCursor ();
|
||||||
|
@ -107,8 +110,11 @@ namespace Hurricane {
|
||||||
void mouseReleaseEvent ( QMouseEvent* );
|
void mouseReleaseEvent ( QMouseEvent* );
|
||||||
public slots:
|
public slots:
|
||||||
// Qt QWidget Slots Overload & CellWidget Specifics.
|
// Qt QWidget Slots Overload & CellWidget Specifics.
|
||||||
|
inline QPainter& getScreenPainter ();
|
||||||
void redraw ( QRect redrawArea );
|
void redraw ( QRect redrawArea );
|
||||||
inline void redraw ();
|
inline void redraw ();
|
||||||
|
inline void copyToScreen ( int sx, int sy, int h, int w );
|
||||||
|
inline void copyToScreen ();
|
||||||
void goLeft ( int dx = 0 );
|
void goLeft ( int dx = 0 );
|
||||||
void goRight ( int dx = 0 );
|
void goRight ( int dx = 0 );
|
||||||
void goUp ( int dy = 0 );
|
void goUp ( int dy = 0 );
|
||||||
|
@ -117,12 +123,25 @@ namespace Hurricane {
|
||||||
void setScale ( float scale );
|
void setScale ( float scale );
|
||||||
void setShowBoundaries ( bool state );
|
void setShowBoundaries ( bool state );
|
||||||
void reframe ( const Box& box );
|
void reframe ( const Box& box );
|
||||||
void screenReframe ();
|
void displayReframe ();
|
||||||
void shiftLeft ( int dx );
|
void shiftLeft ( int dx );
|
||||||
void shiftRight ( int dx );
|
void shiftRight ( int dx );
|
||||||
void shiftUp ( int dy );
|
void shiftUp ( int dy );
|
||||||
void shiftDown ( int dy );
|
void shiftDown ( int dy );
|
||||||
|
|
||||||
|
private:
|
||||||
|
class Spot {
|
||||||
|
public:
|
||||||
|
Spot ( CellWidget* cw );
|
||||||
|
void setRestore ( bool restore );
|
||||||
|
void restore ();
|
||||||
|
void moveTo ( const QPoint& point );
|
||||||
|
private:
|
||||||
|
CellWidget* _cellWidget;
|
||||||
|
QPoint _spotPoint;
|
||||||
|
bool _restore;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Internal: Attributes.
|
// Internal: Attributes.
|
||||||
static const int _stripWidth;
|
static const int _stripWidth;
|
||||||
|
@ -137,8 +156,10 @@ namespace Hurricane {
|
||||||
float _scale;
|
float _scale;
|
||||||
QPoint _offsetVA;
|
QPoint _offsetVA;
|
||||||
QPixmap _drawingBuffer;
|
QPixmap _drawingBuffer;
|
||||||
QPainter _painter;
|
QPainter _drawingPainter;
|
||||||
|
QPainter _screenPainter;
|
||||||
QPoint _lastMousePosition;
|
QPoint _lastMousePosition;
|
||||||
|
Spot _spot;
|
||||||
Cell* _cell;
|
Cell* _cell;
|
||||||
bool _mouseGo;
|
bool _mouseGo;
|
||||||
bool _showBoundaries;
|
bool _showBoundaries;
|
||||||
|
@ -148,6 +169,18 @@ namespace Hurricane {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inline QPainter& CellWidget::getScreenPainter ()
|
||||||
|
{ return _screenPainter; }
|
||||||
|
|
||||||
|
|
||||||
|
inline void CellWidget::copyToScreen ( int sx, int sy, int w, int h )
|
||||||
|
{ _screenPainter.drawPixmap ( sx, sy, _drawingBuffer, _offsetVA.rx()+sx, _offsetVA.ry()+sy, w, h ); }
|
||||||
|
|
||||||
|
|
||||||
|
inline void CellWidget::copyToScreen ()
|
||||||
|
{ copyToScreen ( 0, 0, width(), height() ); }
|
||||||
|
|
||||||
|
|
||||||
inline void CellWidget::redraw ()
|
inline void CellWidget::redraw ()
|
||||||
{ redraw ( QRect(QPoint(0,0),_drawingBuffer.size()) ); }
|
{ redraw ( QRect(QPoint(0,0),_drawingBuffer.size()) ); }
|
||||||
|
|
||||||
|
@ -172,6 +205,10 @@ inline int CellWidget::dbuToScreenY ( DbU::Unit y ) const
|
||||||
{ return (int)rint ( (float)( _displayArea.getYMax() - y ) * _scale ) - _offsetVA.y(); }
|
{ return (int)rint ( (float)( _displayArea.getYMax() - y ) * _scale ) - _offsetVA.y(); }
|
||||||
|
|
||||||
|
|
||||||
|
inline QPoint CellWidget::dbuToScreenPoint ( const Point& point ) const
|
||||||
|
{ return QPoint ( dbuToScreenX(point.getX()), dbuToScreenY(point.getY()) ); }
|
||||||
|
|
||||||
|
|
||||||
inline DbU::Unit CellWidget::displayToDbuX ( int x ) const
|
inline DbU::Unit CellWidget::displayToDbuX ( int x ) const
|
||||||
{ return (DbU::Unit)(x/_scale) + _displayArea.getXMin(); }
|
{ return (DbU::Unit)(x/_scale) + _displayArea.getXMin(); }
|
||||||
|
|
||||||
|
@ -202,6 +239,10 @@ inline DbU::Unit CellWidget::screenToDbuY ( int y ) const
|
||||||
{ return displayToDbuY(y+_offsetVA.y()); }
|
{ return displayToDbuY(y+_offsetVA.y()); }
|
||||||
|
|
||||||
|
|
||||||
|
inline Point CellWidget::screenToDbuPoint ( const QPoint& point ) const
|
||||||
|
{ return Point ( screenToDbuX(point.x()), screenToDbuY(point.y()) ); }
|
||||||
|
|
||||||
|
|
||||||
inline Cell* CellWidget::getCell () const
|
inline Cell* CellWidget::getCell () const
|
||||||
{ return _cell; }
|
{ return _cell; }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
|
|
||||||
|
|
||||||
# ifndef __PALETTET__
|
# ifndef __PALETTE__
|
||||||
# define __PALETTE__
|
# define __PALETTE__
|
||||||
|
|
||||||
# include <vector>
|
# include <vector>
|
||||||
|
|
Loading…
Reference in New Issue