return anImage;
}
+ bool GraphicsView_ViewPort::dumpViewToFormat(const QString& fileName, const QString& format)
+ {
+ if( format!="PS" && format!="EPS" )
+ return false;
+
+ QPrinter printer(QPrinter::ScreenResolution);
++#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ printer.setOutputFormat(QPrinter::PostScriptFormat);
++#else
++ printer.setOutputFormat(QPrinter::PdfFormat);
++#endif
+ printer.setOutputFileName(fileName);
+ QPainter painter;
+ if (!painter.begin(&printer))
+ return false;
+
+ QRect view( 0, 0, printer.pageRect().width(), printer.paperRect().height() );
+ QRectF bounds = myScene->itemsBoundingRect();
+
+ if( !view.isEmpty() && !bounds.isEmpty() )
+ {
+ float SCALE = 0.5;//qMin( view.width()/bounds.width(), view.height()/bounds.height() );
+ painter.setViewport( view );
+ painter.scale( SCALE, SCALE );
+ }
+ myScene->render( &painter, QRectF( view ), bounds );
+
+ if (!painter.end())
+ return false;
+ return true;
+ }
+
//================================================================
// Function : setSceneGap
// Purpose :
aTransform.scale( aZoom, aZoom );
double aM11 = aTransform.m11();
double aM22 = aTransform.m22();
+
+
+ QGraphicsView::ViewportAnchor old_anchor = transformationAnchor();
+ setTransformationAnchor( QGraphicsView::AnchorUnderMouse );
+
// increasing of diagonal coefficients (>300) leads to a crash sometimes
// at the values of 100 some primitives are drawn incorrectly
- if( qMax( aM11, aM22 ) < 100 )
+ if( myZoomCoeff < 0 || qMax( aM11, aM22 ) < myZoomCoeff )
setTransform( aTransform );
myIsTransforming = false;
anObject->setViewTransform( transform() );
}
+ //================================================================
+ // Function : setZoomCoeff
+ // Purpose :
+ //================================================================
+ void GraphicsView_ViewPort::setZoomCoeff( const int& theZoomCoeff )
+ {
+ myZoomCoeff = theZoomCoeff;
+ }
+
+ //================================================================
+ // Function : setUnlimitedPanning
+ // Purpose :
+ //================================================================
+ void GraphicsView_ViewPort::setUnlimitedPanning( const bool& theValue )
+ {
++ if ( myUnlimitedPanning == theValue )
++ return;
++
+ myUnlimitedPanning = theValue;
+
+ if( myUnlimitedPanning )
+ {
+ myHBarPolicy = horizontalScrollBarPolicy();
+ myVBarPolicy = verticalScrollBarPolicy();
+
+ setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
+ setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOn );
+ }
+ else
+ {
+ setHorizontalScrollBarPolicy( myHBarPolicy );
+ setVerticalScrollBarPolicy( myVBarPolicy );
+ }
+ }
+
//================================================================
// Function : currentBlock
// Purpose :