[QGIS Commit] r9039 - in branches/advanced_printing_branch/src:
app/composer ui
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Aug 9 06:09:30 EDT 2008
Author: mhugent
Date: 2008-08-09 06:09:29 -0400 (Sat, 09 Aug 2008)
New Revision: 9039
Modified:
branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposermap.h
branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h
branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
branches/advanced_printing_branch/src/ui/qgscomposermapwidgetbase.ui
Log:
Show live updates for move map content, disable render preview mode of composer map because of frequent crashes
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermap.cpp 2008-08-09 10:09:29 UTC (rev 9039)
@@ -49,6 +49,10 @@
mCacheUpdated = false;
mDrawing = false;
+ //Offset
+ mXOffset = 0.0;
+ mYOffset = 0.0;
+
//calculate mExtent based on width/height ratio and map canvas extent
mExtent = mMapCanvas->extent();
setSceneRect(QRectF(x, y, width, height));
@@ -65,10 +69,14 @@
QgsComposerMap::QgsComposerMap ( QgsComposition *composition)
: QgsComposerItem(0, 0, 10, 10, composition)
{
- mComposition = composition;
- mMapCanvas = mComposition->mapCanvas();
- mId = mCurrentComposerId++;
- QGraphicsRectItem::show();
+ //Offset
+ mXOffset = 0.0;
+ mYOffset = 0.0;
+
+ mComposition = composition;
+ mMapCanvas = mComposition->mapCanvas();
+ mId = mCurrentComposerId++;
+ QGraphicsRectItem::show();
}
QgsComposerMap::~QgsComposerMap()
@@ -184,7 +192,7 @@
painter->save();
painter->scale(scale,scale);
- painter->drawPixmap(0,0, mCachePixmap);
+ painter->drawPixmap(mXOffset / scale, mYOffset / scale, mCachePixmap);
painter->restore();
}
else if ( mComposition->plotStyle() == QgsComposition::Print ||
@@ -309,6 +317,12 @@
update();
}
+void QgsComposerMap::setOffset(double xOffset, double yOffset)
+{
+ mXOffset = xOffset;
+ mYOffset = yOffset;
+}
+
double QgsComposerMap::horizontalViewScaleFactor() const
{
double result = 1;
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermap.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermap.h 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermap.h 2008-08-09 10:09:29 UTC (rev 9039)
@@ -74,6 +74,9 @@
/** \brief Get identification number*/
int id() const {return mId;}
+ /**True if a draw is already in progress*/
+ bool isDrawing() const {return mDrawing;}
+
/** resizes an item in x- and y direction (canvas coordinates)*/
void resize(double dx, double dy);
@@ -104,6 +107,9 @@
const QgsMapCanvas* mapCanvas() const {return mMapCanvas;}
+ /**Sets offset values to shift image (useful for live updates when moving item content)*/
+ void setOffset(double xOffset, double yOffset);
+
/** stores state in DOM node
* @param elem is DOM element corresponding to 'Composer' tag
* @param temp write template file
@@ -161,11 +167,14 @@
/**Store the last map extent to decide if cache needs to be updatet*/
QgsRect mCachedMapExtent;
+ /**Offset in x direction for showing map cache image*/
+ double mXOffset;
+ /**Offset in y direction for showing map cache image*/
+ double mYOffset;
+
/**For the generation of new unique ids*/
static int mCurrentComposerId;
-
-
/**Returns the zoom factor of the graphics view. If no
graphics view exists, the default 1 is returned*/
double horizontalViewScaleFactor() const;
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.cpp 2008-08-09 10:09:29 UTC (rev 9039)
@@ -32,7 +32,8 @@
mYMaxLineEdit->setValidator(new QDoubleValidator(0));
mPreviewModeComboBox->insertItem(0, tr("Cache"));
- mPreviewModeComboBox->insertItem(1, tr("Render"));
+ //MH: disabled because this option leads to frequent crashes with Qt 4.4.0 and 4.4.1
+ //mPreviewModeComboBox->insertItem(1, tr("Render"));
mPreviewModeComboBox->insertItem(2, tr("Rectangle"));
mFrameCheckBox->setCheckState(Qt::Checked);
@@ -97,14 +98,17 @@
if(comboText == tr("Cache"))
{
mComposerMap->setPreviewMode(QgsComposerMap::Cache);
+ mUpdatePreviewButton->setEnabled(true);
}
else if(comboText == tr("Render"))
{
mComposerMap->setPreviewMode(QgsComposerMap::Render);
+ mUpdatePreviewButton->setEnabled(true);
}
else if(comboText == tr("Rectangle"))
{
mComposerMap->setPreviewMode(QgsComposerMap::Rectangle);
+ mUpdatePreviewButton->setEnabled(false);
}
mComposerMap->update();
@@ -233,6 +237,7 @@
else if(previewMode == QgsComposerMap::Rectangle)
{
index = mPreviewModeComboBox->findText(tr("Rectangle"));
+ mUpdatePreviewButton->setEnabled(false);
}
if(index != -1)
{
@@ -271,4 +276,18 @@
mComposerMap->setNewExtent(newExtent);
}
+void QgsComposerMapWidget::on_mUpdatePreviewButton_clicked()
+{
+ if(!mComposerMap)
+ {
+ return;
+ }
+ if(mComposerMap->isDrawing())
+ {
+ return;
+ }
+
+ mComposerMap->setCacheUpdated(false);
+ mComposerMap->update();
+}
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposermapwidget.h 2008-08-09 10:09:29 UTC (rev 9039)
@@ -39,6 +39,7 @@
void on_mFrameCheckBox_stateChanged(int state);
void on_mScaleLineEdit_editingFinished();
void on_mSetToMapCanvasExtentButton_clicked();
+ void on_mUpdatePreviewButton_clicked();
void on_mXMinLineEdit_editingFinished();
void on_mXMaxLineEdit_editingFinished();
Modified: branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp
===================================================================
--- branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/app/composer/qgscomposerview.cpp 2008-08-09 10:09:29 UTC (rev 9039)
@@ -167,6 +167,13 @@
{
if(mMoveContentItem)
{
+ //update map preview if composer map
+ QgsComposerMap* composerMap = dynamic_cast<QgsComposerMap*>(mMoveContentItem);
+ if(composerMap)
+ {
+ composerMap->setOffset(0, 0);
+ }
+
double moveX = scenePoint.x() - mMoveContentStartPos.x();
double moveY = scenePoint.y() - mMoveContentStartPos.y();
mMoveContentItem->moveContent(-moveX, -moveY);
@@ -237,9 +244,19 @@
newWidth = scenePoint.x() - mRubberBandItem->transform().dx();
newHeight = scenePoint.y() - mRubberBandItem->transform().dy();
mRubberBandItem->setRect(0, 0, newWidth, newHeight);
-
break;
-
+
+ case MoveItemContent:
+ {
+ //update map preview if composer map
+ QgsComposerMap* composerMap = dynamic_cast<QgsComposerMap*>(mMoveContentItem);
+ if(composerMap)
+ {
+ composerMap->setOffset(scenePoint.x() - mMoveContentStartPos.x(), scenePoint.y() - mMoveContentStartPos.y());
+ composerMap->update();
+ }
+ break;
+ }
default:
break;
}
@@ -382,3 +399,6 @@
{
emit itemRemoved(item);
}
+
+
+
Modified: branches/advanced_printing_branch/src/ui/qgscomposermapwidgetbase.ui
===================================================================
--- branches/advanced_printing_branch/src/ui/qgscomposermapwidgetbase.ui 2008-08-09 05:59:41 UTC (rev 9038)
+++ branches/advanced_printing_branch/src/ui/qgscomposermapwidgetbase.ui 2008-08-09 10:09:29 UTC (rev 9039)
@@ -19,14 +19,14 @@
<string>Map options</string>
</property>
<layout class="QGridLayout" >
- <item row="0" column="0" colspan="3" >
+ <item row="0" column="0" colspan="4" >
<widget class="QLabel" name="mNameLabel" >
<property name="text" >
<string><b>Map</b></string>
</property>
</widget>
</item>
- <item row="1" column="0" colspan="3" >
+ <item row="1" column="0" colspan="4" >
<widget class="Line" name="line1" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
@@ -52,7 +52,7 @@
</property>
</widget>
</item>
- <item row="2" column="2" >
+ <item row="2" column="2" colspan="2" >
<widget class="QLineEdit" name="mWidthLineEdit" />
</item>
<item row="3" column="0" >
@@ -68,7 +68,7 @@
</property>
</widget>
</item>
- <item row="3" column="2" >
+ <item row="3" column="2" colspan="2" >
<widget class="QLineEdit" name="mHeightLineEdit" />
</item>
<item row="4" column="0" >
@@ -97,10 +97,10 @@
</property>
</widget>
</item>
- <item row="4" column="2" >
+ <item row="4" column="2" colspan="2" >
<widget class="QLineEdit" name="mScaleLineEdit" />
</item>
- <item row="5" column="0" colspan="3" >
+ <item row="5" column="0" colspan="4" >
<widget class="QGroupBox" name="mMapExtentGroupBox" >
<property name="title" >
<string>Map extent</string>
@@ -191,7 +191,7 @@
</layout>
</widget>
</item>
- <item row="6" column="0" colspan="3" >
+ <item row="6" column="0" colspan="4" >
<widget class="QCheckBox" name="mFrameCheckBox" >
<property name="text" >
<string>Frame</string>
@@ -199,7 +199,7 @@
</widget>
</item>
<item row="7" column="0" colspan="2" >
- <widget class="QLabel" name="textLabel1_5" >
+ <widget class="QLabel" name="mPreviewModeLabel" >
<property name="text" >
<string>Preview</string>
</property>
@@ -221,15 +221,22 @@
</property>
</widget>
</item>
- <item row="8" column="2" >
+ <item row="7" column="3" >
+ <widget class="QPushButton" name="mUpdatePreviewButton" >
+ <property name="text" >
+ <string>Update preview</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
- <width>402</width>
- <height>31</height>
+ <width>438</width>
+ <height>61</height>
</size>
</property>
</spacer>
More information about the QGIS-commit
mailing list