38
38
#include " qgscomposerattributetable.h"
39
39
#include " qgscomposertablewidget.h"
40
40
#include " qgsexception.h"
41
+ #include " qgslogger.h"
41
42
#include " qgsproject.h"
42
43
#include " qgsmapcanvas.h"
43
44
#include " qgsmaprenderer.h"
46
47
#include " qgscursors.h"
47
48
48
49
#include < QCloseEvent>
50
+ #include < QCheckBox>
49
51
#include < QDesktopWidget>
50
52
#include < QFileDialog>
51
53
#include < QFileInfo>
54
+ #include < QIcon>
55
+ #include < QImageWriter>
52
56
#include < QMatrix>
53
57
#include < QMenuBar>
54
58
#include < QMessageBox>
55
59
#include < QPageSetupDialog>
56
60
#include < QPainter>
57
-
61
+ # include < QPixmap >
58
62
#include < QPrintDialog>
59
63
#include < QSettings>
60
- #include < QIcon>
61
- #include < QPixmap>
64
+ #include < QSizeGrip>
62
65
#include < QSvgGenerator>
63
66
#include < QToolBar>
64
67
#include < QToolButton>
65
- #include < QImageWriter>
66
- #include < QCheckBox>
67
- #include < QSizeGrip>
68
- #include " qgslogger.h"
68
+ // #include <QUndoView>
69
+
70
+
71
+
72
+
69
73
70
74
QgsComposer::QgsComposer ( QgisApp *qgis, const QString& title ): QMainWindow(), mTitle( title )
71
75
{
@@ -212,6 +216,10 @@ QgsComposer::QgsComposer( QgisApp *qgis, const QString& title ): QMainWindow(),
212
216
213
217
mCompositionNameComboBox ->insertItem ( 0 , tr ( " Map 1" ) );
214
218
219
+ // undo widget
220
+ /* QUndoView* undoWidget = new QUndoView( mComposition->undoStack(), this );
221
+ mOptionsTabWidget->addTab( undoWidget, tr( "Command history" ) );*/
222
+
215
223
// Create size grip (needed by Mac OS X for QMainWindow if QStatusBar is not visible)
216
224
mSizeGrip = new QSizeGrip ( this );
217
225
mSizeGrip ->resize ( mSizeGrip ->sizeHint () );
@@ -507,7 +515,7 @@ void QgsComposer::on_mActionPrint_triggered()
507
515
508
516
void QgsComposer::print ( QPrinter &printer )
509
517
{
510
- if ( !mComposition )
518
+ if ( !mComposition || ! mView )
511
519
return ;
512
520
513
521
if ( containsWMSLayer () )
@@ -530,6 +538,7 @@ void QgsComposer::print( QPrinter &printer )
530
538
QApplication::setOverrideCursor ( Qt::BusyCursor );
531
539
532
540
bool printAsRaster = mComposition ->printAsRaster ();
541
+ // mView->setScene( 0 );
533
542
534
543
if ( printAsRaster )
535
544
{
@@ -545,8 +554,9 @@ void QgsComposer::print( QPrinter &printer )
545
554
QPainter imagePainter ( &image );
546
555
QRectF sourceArea ( 0 , 0 , mComposition ->paperWidth (), mComposition ->paperHeight () );
547
556
QRectF targetArea ( 0 , 0 , width, height );
557
+ mView ->setPaintingEnabled ( false );
548
558
mComposition ->render ( &imagePainter, targetArea, sourceArea );
549
- imagePainter. end ( );
559
+ mView -> setPaintingEnabled ( true );
550
560
p.drawImage ( targetArea, image, targetArea );
551
561
}
552
562
else
@@ -574,7 +584,10 @@ void QgsComposer::print( QPrinter &printer )
574
584
// better in case of custom page size, but only possible with Qt>=4.4.0
575
585
QRectF paperRectMM = printer.pageRect ( QPrinter::Millimeter );
576
586
QRectF paperRectPixel = printer.pageRect ( QPrinter::DevicePixel );
587
+
588
+ mView ->setPaintingEnabled ( false );
577
589
mComposition ->render ( &p, paperRectPixel, paperRectMM );
590
+ mView ->setPaintingEnabled ( true );
578
591
}
579
592
580
593
mComposition ->setPlotStyle ( savedPlotStyle );
@@ -707,19 +720,18 @@ void QgsComposer::on_mActionExportAsImage_triggered()
707
720
}
708
721
709
722
mComposition ->setPlotStyle ( QgsComposition::Print );
710
- mView ->setScene ( 0 );
711
723
image.setDotsPerMeterX ( mComposition ->printResolution () / 25.4 * 1000 );
712
724
image.setDotsPerMeterY ( mComposition ->printResolution () / 25.4 * 1000 );
713
725
image.fill ( 0 );
714
726
QPainter p ( &image );
715
727
QRectF sourceArea ( 0 , 0 , mComposition ->paperWidth (), mComposition ->paperHeight () );
716
728
QRectF targetArea ( 0 , 0 , width, height );
729
+ mView ->setPaintingEnabled ( false );
717
730
mComposition ->render ( &p, targetArea, sourceArea );
718
731
p.end ();
719
-
720
732
mComposition ->setPlotStyle ( QgsComposition::Preview );
733
+ mView ->setPaintingEnabled ( true );
721
734
image.save ( myOutputFileNameQString, myFilterMap[myFilterString].toLocal8Bit ().data () );
722
- mView ->setScene ( mComposition );
723
735
}
724
736
725
737
@@ -779,8 +791,6 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
779
791
}
780
792
781
793
myQSettings.setValue ( " /UI/lastSaveAsSvgFile" , myOutputFileNameQString );
782
-
783
- // mView->setScene(0);//don't redraw the scene on the display while we render
784
794
mComposition ->setPlotStyle ( QgsComposition::Print );
785
795
786
796
QSvgGenerator generator;
@@ -799,12 +809,11 @@ void QgsComposer::on_mActionExportAsSVG_triggered()
799
809
800
810
QRectF sourceArea ( 0 , 0 , mComposition ->paperWidth (), mComposition ->paperHeight () );
801
811
QRectF targetArea ( 0 , 0 , width, height );
812
+ mView ->setPaintingEnabled ( false );
802
813
mComposition ->render ( &p, targetArea, sourceArea );
803
-
804
814
p.end ();
805
-
806
815
mComposition ->setPlotStyle ( QgsComposition::Preview );
807
- // mView->setScene(mComposition->canvas()); //now that we're done, set the view to show the scene again
816
+ mView ->setPaintingEnabled ( true );
808
817
}
809
818
810
819
void QgsComposer::on_mActionSelectMoveItem_triggered ()
0 commit comments