#include <QPainter> #include "ImageProjector.h" ImageProjector::ImageProjector(void) { image = 0x0; mask = 0x0; maskOn = false; displayWidth = contentsRect().width(); displayHeight = contentsRect().height(); autoSize = true; } ImageProjector::~ImageProjector(void) { } void ImageProjector::setScale( double s ) { if ( !s ) { autoSize = true; setMinimumSize( 100, 100 ); setMaximumSize( 10000, 10000 ); resize( size() ); return; } scale = s; displayWidth = scale * image->width(); displayHeight = scale * image->height(); setFixedSize( displayWidth, displayHeight ); } void ImageProjector::enterEvent( QEvent* e ) { emit info( info_string ); } void ImageProjector::leaveEvent( QEvent* e ) { emit info( QString::null ); } void ImageProjector::resizeEvent( QResizeEvent* e ) { QWidget::resizeEvent( e ); if ( !image ) return; if ( !autoSize ) return; double woh = ( contentsRect().width() * 1.0 ) / contentsRect().height(); double iwoh = ( image->width() * 1.0 ) / image->height(); if ( woh > iwoh ) { displayWidth = contentsRect().height() * iwoh; displayHeight = contentsRect().height(); } else { displayWidth = contentsRect().width(); displayHeight = contentsRect().width() / iwoh; } emit resized( displayWidth, displayHeight ); } void ImageProjector::paintEvent( QPaintEvent* e ) { if ( !image || !image->width() || !displayWidth ) return; QPainter p( this ); drawFrame( &p ); p.setClipRect( contentsRect() ); if ( autoSize ) scale = displayWidth * 1.0 / image->width(); p.translate( ( contentsRect().width() - displayWidth ) / 2 + frameWidth(), ( contentsRect().height() - displayHeight ) / 2 + frameWidth() ); p.scale( scale, scale ); p.drawImage( 0, 0, *image ); if ( mask && maskOn ) { p.setPen( maskColor ); p.drawPixmap( 0, 0, *mask ); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 5516 | Sam Stafford | The M is for Merge. | ||
#3 | 5505 | Sam Stafford | Add "diff stencil". | ||
#2 | 5502 | Sam Stafford |
Status bar with handy information, and infrastructure to allow ImageProjectors to have frames. |
||
#1 | 5501 | Sam Stafford |
Codename CALAMARI. Built with Qt 4.1.3 - needs QtCore4.dll and QtGui4.dll to run. |