Skip to content

Commit 0c976f8

Browse files
author
ersts
committed
-Fixed color error when creating new file, closes ticket #1034
-Updated the auto arrange -Fixed an issue that caused qgis to segfault git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9051 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d8601c4 commit 0c976f8

File tree

5 files changed

+69
-102
lines changed

5 files changed

+69
-102
lines changed

src/plugins/georeferencer/plugingui.cpp

+23-63
Original file line numberDiff line numberDiff line change
@@ -165,85 +165,45 @@ void QgsGeorefPluginGui::on_mArrangeWindowsButton_clicked()
165165
return;
166166
}
167167

168-
int width, height; //width and height of screen
168+
int myScreenWidth, myScreenHeight; //width and height of screen
169169

170170
//store initial size and position of qgis window
171171
mPluginWindowsArranged = true;
172172
origSize = mainWindow->size();
173173
origPos = mainWindow->pos();
174174

175-
176-
//qt distinguishes between geometry with and without window frame
177-
int widthIncrMainWindow, heightIncrMainWindow;
178-
int widthIncrPointDialog, heightIncrPointDialog;
179-
int widthIncrThis, heightIncrThis;
180-
181175
//read the desktop geometry
182176
QDesktopWidget* desktop = QApplication::desktop();
183177
QRect screenGeometry = desktop->availableGeometry();
184-
width = screenGeometry.width();
185-
height = screenGeometry.height();
186-
187-
int leftRightBorder; //border between plugin/point dialogs on the left and qgis main window on the right
188-
int pluginPointDialogBorder; //border on y-axis between plugin dialog and point dialog
189-
178+
myScreenWidth = screenGeometry.width();
179+
myScreenHeight = screenGeometry.height();
190180

191-
leftRightBorder = width/3;
192-
pluginPointDialogBorder = height/5;
193-
194-
//consider minimum heights of plugin dialog and mPointDialog
195-
int minPluginDialogHeight = minimumHeight() + (frameSize().height() - this->height());
196-
int minPointDialogHeight = mPointDialog->minimumHeight() + \
197-
(mPointDialog->frameSize().height() - mPointDialog->height());
198-
199-
if((height - pluginPointDialogBorder) < minPointDialogHeight)
200-
{
201-
pluginPointDialogBorder = (height - minPointDialogHeight);
202-
}
203-
if(pluginPointDialogBorder < minPluginDialogHeight)
204-
{
205-
pluginPointDialogBorder = minPluginDialogHeight;
206-
}
207-
208-
//consider minimum widths of plugin/point dialogs and qgis main window
209-
int minPluginDialogWidth = minimumWidth() + (frameSize().width() - this->width());
210-
int minPointDialogWidth = mPointDialog->minimumWidth() + \
211-
(mPointDialog->frameSize().width() - mPointDialog->width());
212-
int minMainWindowWidth = mainWindow->minimumWidth() + \
213-
(mainWindow->frameSize().width() - mainWindow->width());
214-
215-
if(leftRightBorder < minPointDialogWidth)
216-
{
217-
leftRightBorder = minPointDialogWidth;
218-
}
219-
if(leftRightBorder < minPluginDialogWidth)
220-
{
221-
leftRightBorder = minPluginDialogWidth;
222-
}
223-
if((width - leftRightBorder) < minMainWindowWidth)
224-
{
225-
leftRightBorder = width - minMainWindowWidth;
226-
}
181+
int newPluginDialogHeight = qMax(int(myScreenHeight * 0.2), minimumHeight());
182+
int newPluginDialogWidth = qMax(int(myScreenWidth * 0.33), minimumWidth());
183+
int newPointDialogHeight = qMax(int(myScreenHeight * 0.70), mPointDialog->minimumHeight());
184+
int newPointDialogWidth = qMax(int(myScreenWidth * 0.33), mPointDialog->minimumWidth());
185+
int newMainWindowHeight = qMax(int(myScreenHeight * 0.95), mainWindow->minimumHeight());
186+
int newMainWindowWidth = qMax(int(myScreenWidth * 0.65), mainWindow->minimumHeight());
227187

228188
//place main window
229-
widthIncrMainWindow = (width -leftRightBorder) - mainWindow->frameSize().width();
230-
heightIncrMainWindow = height - mainWindow->frameSize().height();
231189
mainWindow->setEnabled(false); //avoid getting two resize events for the main canvas
232-
mainWindow->resize(mainWindow->width() + widthIncrMainWindow, mainWindow->height() + heightIncrMainWindow);
233-
mainWindow->move(leftRightBorder, 0);
190+
mainWindow->resize(newMainWindowWidth, newMainWindowHeight);
191+
//Resize again to account for frame border width -- Probably a better way to do this.
192+
mainWindow->resize(newMainWindowWidth - (mainWindow->width() - newMainWindowWidth), newMainWindowHeight - (mainWindow->height() - newMainWindowHeight));
193+
mainWindow->move(myScreenWidth - newMainWindowWidth, 0);
234194
mainWindow->setEnabled(true);
235-
236-
//place point dialog
237-
widthIncrPointDialog = leftRightBorder - mPointDialog->frameSize().width();
238-
heightIncrPointDialog = height - pluginPointDialogBorder - mPointDialog->frameSize().height();
239-
mPointDialog->resize(mPointDialog->width() + widthIncrPointDialog, mPointDialog->height() + heightIncrPointDialog);
240-
mPointDialog->move(0, pluginPointDialogBorder);
241-
195+
242196
//place this dialog
243-
widthIncrThis = leftRightBorder - frameSize().width();
244-
heightIncrThis = pluginPointDialogBorder - frameSize().height();
245-
resize(this->width() + widthIncrThis, this->height() + heightIncrThis);
197+
resize(newPluginDialogWidth, newPluginDialogHeight);
198+
resize(newPluginDialogWidth - (width() - newPluginDialogWidth), newPluginDialogHeight - (height() - newPluginDialogHeight));
246199
move(0, 0);
200+
201+
//place point dialog
202+
mPointDialog->resize(newPointDialogWidth, newPointDialogHeight);
203+
mPointDialog->resize(newPointDialogWidth - (mPointDialog->width() - newPointDialogWidth), newPointDialogHeight - (mPointDialog->height() - newPointDialogHeight));
204+
mPointDialog->move(0, int(myScreenHeight * 0.3));
205+
206+
247207
}
248208
}
249209

src/plugins/georeferencer/pluginguibase.ui

+32-33
Original file line numberDiff line numberDiff line change
@@ -6,78 +6,77 @@
66
<x>0</x>
77
<y>0</y>
88
<width>424</width>
9-
<height>155</height>
9+
<height>131</height>
1010
</rect>
1111
</property>
1212
<property name="windowTitle" >
1313
<string>Georeferencer</string>
1414
</property>
1515
<property name="windowIcon" >
16-
<iconset resource="georeferencer.qrc" >:/icon.png</iconset>
16+
<iconset/>
1717
</property>
1818
<layout class="QGridLayout" >
19-
<property name="margin" >
20-
<number>9</number>
21-
</property>
22-
<property name="spacing" >
23-
<number>6</number>
24-
</property>
25-
<item row="1" column="1" colspan="2" >
26-
<widget class="QPushButton" name="mArrangeWindowsButton" >
19+
<item row="0" column="0" >
20+
<widget class="QLabel" name="textLabel1" >
2721
<property name="text" >
28-
<string>Arrange plugin windows</string>
22+
<string>Raster file:</string>
2923
</property>
3024
</widget>
3125
</item>
32-
<item row="0" column="2" >
33-
<widget class="QPushButton" name="pbnSelectRaster" >
26+
<item row="0" column="1" >
27+
<widget class="QLineEdit" name="leSelectRaster" >
3428
<property name="sizePolicy" >
35-
<sizepolicy>
36-
<hsizetype>0</hsizetype>
37-
<vsizetype>0</vsizetype>
29+
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
3830
<horstretch>0</horstretch>
3931
<verstretch>0</verstretch>
4032
</sizepolicy>
4133
</property>
42-
<property name="text" >
43-
<string>...</string>
44-
</property>
4534
</widget>
4635
</item>
47-
<item row="0" column="1" >
48-
<widget class="QLineEdit" name="leSelectRaster" >
36+
<item row="0" column="2" >
37+
<widget class="QPushButton" name="pbnSelectRaster" >
4938
<property name="sizePolicy" >
50-
<sizepolicy>
51-
<hsizetype>0</hsizetype>
52-
<vsizetype>0</vsizetype>
39+
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
5340
<horstretch>0</horstretch>
5441
<verstretch>0</verstretch>
5542
</sizepolicy>
5643
</property>
57-
</widget>
58-
</item>
59-
<item row="0" column="0" >
60-
<widget class="QLabel" name="textLabel1" >
6144
<property name="text" >
62-
<string>Raster file:</string>
45+
<string>...</string>
6346
</property>
6447
</widget>
6548
</item>
66-
<item row="2" column="0" colspan="3" >
49+
<item row="1" column="0" colspan="3" >
6750
<layout class="QHBoxLayout" >
68-
<property name="margin" >
69-
<number>0</number>
70-
</property>
7151
<property name="spacing" >
7252
<number>6</number>
7353
</property>
54+
<property name="leftMargin" >
55+
<number>0</number>
56+
</property>
57+
<property name="topMargin" >
58+
<number>0</number>
59+
</property>
60+
<property name="rightMargin" >
61+
<number>0</number>
62+
</property>
63+
<property name="bottomMargin" >
64+
<number>0</number>
65+
</property>
7466
<item>
7567
<widget class="QPushButton" name="pbnDescription" >
7668
<property name="text" >
7769
<string>Description...</string>
7870
</property>
7971
</widget>
8072
</item>
73+
<item>
74+
<widget class="QPushButton" name="mArrangeWindowsButton" >
75+
<property name="text" >
76+
<string>Arrange plugin windows</string>
77+
</property>
78+
</widget>
79+
</item>
8180
<item>
8281
<spacer>
8382
<property name="orientation" >

src/plugins/georeferencer/qgsgeorefwarpoptionsdialog.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ QgsGeorefWarpOptionsDialog::QgsGeorefWarpOptionsDialog(QWidget* parent)
2222
setupUi(this);
2323
QStringList compressionMethods;
2424
compressionMethods << "NONE";
25-
compressionMethods << "LZW (" + tr("unstable") + ")";
26-
compressionMethods << "PACKBITS (" + tr("unstable") + ")";
27-
compressionMethods << "DEFLATE (" + tr("unstable") + ")";
25+
compressionMethods << "LZW";
26+
compressionMethods << "PACKBITS";
27+
compressionMethods << "DEFLATE";
2828
mCompressionComboBox->addItems(compressionMethods);
2929
}
3030

src/plugins/georeferencer/qgsimagewarper.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,11 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
8585
{
8686
GDALRasterBandH hSrcBand = GDALGetRasterBand(hSrcDS,i+1);
8787
GDALRasterBandH hDstBand = GDALGetRasterBand(hDstDS,i+1);
88-
GDALColorTableH cTable = GDALGetRasterColorTable(hSrcDS);
88+
GDALColorTableH cTable = GDALGetRasterColorTable(hSrcBand);
89+
GDALSetRasterColorInterpretation (hDstBand, GDALGetRasterColorInterpretation(hSrcBand));
8990
if (cTable)
9091
{
91-
GDALSetRasterColorTable(hDstDS,cTable);
92+
GDALSetRasterColorTable(hDstBand,cTable);
9293
}
9394

9495
double noData = GDALGetRasterNoDataValue(hSrcBand,NULL);

src/plugins/georeferencer/qgspointdialog.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,14 @@ bool QgsPointDialog::generateWorldFile()
313313
QgsImageWarper::ResamplingMethod resampling;
314314
QgsImageWarper warper(-rotation);
315315
d.getWarpOptions(resampling, useZeroForTrans, compressionMethod);
316-
warper.warp(mLayer->source(), outputFileName,
316+
//Closing the dialog by pressing the X button rather than clicking the OK button causes GDAL to barf and QGIS
317+
//to crash because reasampling is not a valid option
318+
//**not sure exactly what is going on in the case as the other two options are still correct but that could be coincidence
319+
if(resampling != QgsImageWarper::NearestNeighbour && resampling != QgsImageWarper::Bilinear && resampling != QgsImageWarper::Cubic)
320+
{
321+
return false;
322+
}
323+
warper.warp(mLayer->source(), outputFileName,
317324
xOffset, yOffset, resampling, useZeroForTrans, compressionMethod);
318325
}
319326

0 commit comments

Comments
 (0)