3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 05/12/2010 Created this file. :-)
17 #include "dlgimageoptions.h"
19 #include "mathextra.h"
22 ImageOptionsDialog::ImageOptionsDialog(QWidget * parent/*= NULL*/, Qt::WindowFlags flags/*= 0*/):
23 QDialog(parent, flags)
27 graphicSize = Vector(0.0, 0.0);
30 settings.beginGroup("ExportImage");
31 ui.leWidth->setText(settings.value("Width", "640").toString());
32 ui.leHeight->setText(settings.value("Height", "480").toString());
33 ui.rbBlack->setChecked(settings.value("BlackBackground", false).toBool());
37 ImageOptionsDialog::~ImageOptionsDialog()
41 void ImageOptionsDialog::setGraphicSize(const Vector & s)
46 void ImageOptionsDialog::ok()
48 settings.beginGroup("ExportImage");
49 settings.setValue("Width", ui.leWidth->text());
50 settings.setValue("Height", ui.leHeight->text());
51 settings.setValue("BlackBackground", ui.rbBlack->isChecked());
52 //RS_SETTINGS->writeEntry("/Blackwhite", (int)rbBlackwhite->isChecked());
58 void ImageOptionsDialog::sizeChanged()
62 updateEnabled = false;
63 // ui.cbResolution->setCurrentText("auto");
64 ui.cbResolution->setItemText(ui.cbResolution->currentIndex(), "auto");
69 void ImageOptionsDialog::resolutionChanged()
73 updateEnabled = false;
75 double res = Math::eval(ui.cbResolution->currentText(), &ok);
80 int w = Math::round(res * graphicSize.x);
81 int h = Math::round(res * graphicSize.y);
82 ui.leWidth->setText(QString("%1").arg(w));
83 ui.leHeight->setText(QString("%1").arg(h));
88 QSize ImageOptionsDialog::getSize()
90 return QSize(Math::round(Math::eval(ui.leWidth->text())),
91 Math::round(Math::eval(ui.leHeight->text())));
94 bool ImageOptionsDialog::isBackgroundBlack()
96 return ui.rbBlack->isChecked();
99 /*bool ImageOptionsDialog::isBlackwhite() {
100 return rbBlackwhite->isChecked();