Skip to content
Permalink
Browse files
-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@9051 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
ersts committed Aug 12, 2008
1 parent 5f2d9f9 commit 2fef6ceb7241d2615c249e02830c99744907812b
@@ -165,85 +165,45 @@ void QgsGeorefPluginGui::on_mArrangeWindowsButton_clicked()
return;
}

int width, height; //width and height of screen
int myScreenWidth, myScreenHeight; //width and height of screen

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


//qt distinguishes between geometry with and without window frame
int widthIncrMainWindow, heightIncrMainWindow;
int widthIncrPointDialog, heightIncrPointDialog;
int widthIncrThis, heightIncrThis;

//read the desktop geometry
QDesktopWidget* desktop = QApplication::desktop();
QRect screenGeometry = desktop->availableGeometry();
width = screenGeometry.width();
height = screenGeometry.height();

int leftRightBorder; //border between plugin/point dialogs on the left and qgis main window on the right
int pluginPointDialogBorder; //border on y-axis between plugin dialog and point dialog

myScreenWidth = screenGeometry.width();
myScreenHeight = screenGeometry.height();

leftRightBorder = width/3;
pluginPointDialogBorder = height/5;

//consider minimum heights of plugin dialog and mPointDialog
int minPluginDialogHeight = minimumHeight() + (frameSize().height() - this->height());
int minPointDialogHeight = mPointDialog->minimumHeight() + \
(mPointDialog->frameSize().height() - mPointDialog->height());

if((height - pluginPointDialogBorder) < minPointDialogHeight)
{
pluginPointDialogBorder = (height - minPointDialogHeight);
}
if(pluginPointDialogBorder < minPluginDialogHeight)
{
pluginPointDialogBorder = minPluginDialogHeight;
}

//consider minimum widths of plugin/point dialogs and qgis main window
int minPluginDialogWidth = minimumWidth() + (frameSize().width() - this->width());
int minPointDialogWidth = mPointDialog->minimumWidth() + \
(mPointDialog->frameSize().width() - mPointDialog->width());
int minMainWindowWidth = mainWindow->minimumWidth() + \
(mainWindow->frameSize().width() - mainWindow->width());

if(leftRightBorder < minPointDialogWidth)
{
leftRightBorder = minPointDialogWidth;
}
if(leftRightBorder < minPluginDialogWidth)
{
leftRightBorder = minPluginDialogWidth;
}
if((width - leftRightBorder) < minMainWindowWidth)
{
leftRightBorder = width - minMainWindowWidth;
}
int newPluginDialogHeight = qMax(int(myScreenHeight * 0.2), minimumHeight());
int newPluginDialogWidth = qMax(int(myScreenWidth * 0.33), minimumWidth());
int newPointDialogHeight = qMax(int(myScreenHeight * 0.70), mPointDialog->minimumHeight());
int newPointDialogWidth = qMax(int(myScreenWidth * 0.33), mPointDialog->minimumWidth());
int newMainWindowHeight = qMax(int(myScreenHeight * 0.95), mainWindow->minimumHeight());
int newMainWindowWidth = qMax(int(myScreenWidth * 0.65), mainWindow->minimumHeight());

//place main window
widthIncrMainWindow = (width -leftRightBorder) - mainWindow->frameSize().width();
heightIncrMainWindow = height - mainWindow->frameSize().height();
mainWindow->setEnabled(false); //avoid getting two resize events for the main canvas
mainWindow->resize(mainWindow->width() + widthIncrMainWindow, mainWindow->height() + heightIncrMainWindow);
mainWindow->move(leftRightBorder, 0);
mainWindow->resize(newMainWindowWidth, newMainWindowHeight);
//Resize again to account for frame border width -- Probably a better way to do this.
mainWindow->resize(newMainWindowWidth - (mainWindow->width() - newMainWindowWidth), newMainWindowHeight - (mainWindow->height() - newMainWindowHeight));
mainWindow->move(myScreenWidth - newMainWindowWidth, 0);
mainWindow->setEnabled(true);

//place point dialog
widthIncrPointDialog = leftRightBorder - mPointDialog->frameSize().width();
heightIncrPointDialog = height - pluginPointDialogBorder - mPointDialog->frameSize().height();
mPointDialog->resize(mPointDialog->width() + widthIncrPointDialog, mPointDialog->height() + heightIncrPointDialog);
mPointDialog->move(0, pluginPointDialogBorder);


//place this dialog
widthIncrThis = leftRightBorder - frameSize().width();
heightIncrThis = pluginPointDialogBorder - frameSize().height();
resize(this->width() + widthIncrThis, this->height() + heightIncrThis);
resize(newPluginDialogWidth, newPluginDialogHeight);
resize(newPluginDialogWidth - (width() - newPluginDialogWidth), newPluginDialogHeight - (height() - newPluginDialogHeight));
move(0, 0);

//place point dialog
mPointDialog->resize(newPointDialogWidth, newPointDialogHeight);
mPointDialog->resize(newPointDialogWidth - (mPointDialog->width() - newPointDialogWidth), newPointDialogHeight - (mPointDialog->height() - newPointDialogHeight));
mPointDialog->move(0, int(myScreenHeight * 0.3));


}
}

@@ -6,78 +6,77 @@
<x>0</x>
<y>0</y>
<width>424</width>
<height>155</height>
<height>131</height>
</rect>
</property>
<property name="windowTitle" >
<string>Georeferencer</string>
</property>
<property name="windowIcon" >
<iconset resource="georeferencer.qrc" >:/icon.png</iconset>
<iconset/>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="1" colspan="2" >
<widget class="QPushButton" name="mArrangeWindowsButton" >
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Arrange plugin windows</string>
<string>Raster file:</string>
</property>
</widget>
</item>
<item row="0" column="2" >
<widget class="QPushButton" name="pbnSelectRaster" >
<item row="0" column="1" >
<widget class="QLineEdit" name="leSelectRaster" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" >
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="leSelectRaster" >
<item row="0" column="2" >
<widget class="QPushButton" name="pbnSelectRaster" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Raster file:</string>
<string>...</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3" >
<item row="1" column="0" colspan="3" >
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="pbnDescription" >
<property name="text" >
<string>Description...</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mArrangeWindowsButton" >
<property name="text" >
<string>Arrange plugin windows</string>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
@@ -22,9 +22,9 @@ QgsGeorefWarpOptionsDialog::QgsGeorefWarpOptionsDialog(QWidget* parent)
setupUi(this);
QStringList compressionMethods;
compressionMethods << "NONE";
compressionMethods << "LZW (" + tr("unstable") + ")";
compressionMethods << "PACKBITS (" + tr("unstable") + ")";
compressionMethods << "DEFLATE (" + tr("unstable") + ")";
compressionMethods << "LZW";
compressionMethods << "PACKBITS";
compressionMethods << "DEFLATE";
mCompressionComboBox->addItems(compressionMethods);
}

@@ -85,10 +85,11 @@ void QgsImageWarper::warp(const QString& input, const QString& output,
{
GDALRasterBandH hSrcBand = GDALGetRasterBand(hSrcDS,i+1);
GDALRasterBandH hDstBand = GDALGetRasterBand(hDstDS,i+1);
GDALColorTableH cTable = GDALGetRasterColorTable(hSrcDS);
GDALColorTableH cTable = GDALGetRasterColorTable(hSrcBand);
GDALSetRasterColorInterpretation (hDstBand, GDALGetRasterColorInterpretation(hSrcBand));
if (cTable)
{
GDALSetRasterColorTable(hDstDS,cTable);
GDALSetRasterColorTable(hDstBand,cTable);
}

double noData = GDALGetRasterNoDataValue(hSrcBand,NULL);
@@ -313,7 +313,14 @@ bool QgsPointDialog::generateWorldFile()
QgsImageWarper::ResamplingMethod resampling;
QgsImageWarper warper(-rotation);
d.getWarpOptions(resampling, useZeroForTrans, compressionMethod);
warper.warp(mLayer->source(), outputFileName,
//Closing the dialog by pressing the X button rather than clicking the OK button causes GDAL to barf and QGIS
//to crash because reasampling is not a valid option
//**not sure exactly what is going on in the case as the other two options are still correct but that could be coincidence
if(resampling != QgsImageWarper::NearestNeighbour && resampling != QgsImageWarper::Bilinear && resampling != QgsImageWarper::Cubic)
{
return false;
}
warper.warp(mLayer->source(), outputFileName,
xOffset, yOffset, resampling, useZeroForTrans, compressionMethod);
}

0 comments on commit 2fef6ce

Please sign in to comment.