Tue, 14 May 2013 01:22:40 +0300
Allow one of the dimensions be filled via aspect ratio
src/gldraw.cpp | file | annotate | diff | comparison | revisions | |
src/gldraw.h | file | annotate | diff | comparison | revisions |
--- a/src/gldraw.cpp Tue May 14 00:52:20 2013 +0300 +++ b/src/gldraw.cpp Tue May 14 01:22:40 2013 +0300 @@ -1272,16 +1272,22 @@ sb_ofsy = new QSpinBox; sb_ofsx->setRange (0, 10000); sb_ofsy->setRange (0, 10000); + sb_ofsx->setSuffix (" px"); + sb_ofsy->setSuffix (" px"); - QLabel* lb_dimens = new QLabel ("Dimensions (LDU):"); + QLabel* lb_dimens = new QLabel ("Dimensions:"); dsb_lwidth = new QDoubleSpinBox; dsb_lheight = new QDoubleSpinBox; dsb_lwidth->setRange (0.0f, 10000.0f); dsb_lheight->setRange (0.0f, 10000.0f); + dsb_lwidth->setSuffix (" LDU"); + dsb_lheight->setSuffix (" LDU"); + dsb_lwidth->setSpecialValueText ("Automatic"); + dsb_lheight->setSpecialValueText ("Automatic"); - QDialogButtonBox* bbx_buttons = makeButtonBox (*this); - bbx_buttons->addButton (QDialogButtonBox::Help); - connect (bbx_buttons, SIGNAL (helpRequested ()), this, SLOT (slot_help())); + dbb_buttons = makeButtonBox (*this); + dbb_buttons->addButton (QDialogButtonBox::Help); + connect (dbb_buttons, SIGNAL (helpRequested ()), this, SLOT (slot_help())); QHBoxLayout* fpathlayout = new QHBoxLayout; fpathlayout->addWidget (lb_fpath); @@ -1303,7 +1309,11 @@ QVBoxLayout* layout = new QVBoxLayout (this); layout->addWidget (rb_camera); layout->addWidget (gb_image); - layout->addWidget (bbx_buttons); + layout->addWidget (dbb_buttons); + + connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); + connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); + slot_dimensionsChanged (); } str OverlayDialog::fpath () const { return le_fpath->text (); } @@ -1313,14 +1323,19 @@ double OverlayDialog::lheight () const { return dsb_lheight->value (); } GL::Camera OverlayDialog::camera () const { return (GL::Camera) rb_camera->value (); } -void OverlayDialog::slot_fpath () const { +void OverlayDialog::slot_fpath () { le_fpath->setText (QFileDialog::getOpenFileName (null, "Overlay image")); } -void OverlayDialog::slot_help () const { +void OverlayDialog::slot_help () { showDocumentation (g_docs_overlays); } +void OverlayDialog::slot_dimensionsChanged () { + bool enable = (dsb_lwidth->value () != 0) || (dsb_lheight->value () != 0); + dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); +} + void GLRenderer::setupOverlay () { if (camera () == Free) return; @@ -1348,6 +1363,11 @@ info.oy = dlg.ofsy (); info.img = img; + if (info.lw == 0) + info.lw = (info.lh * img->width ()) / img->height (); + else if (info.lh == 0) + info.lh = (info.lw * img->height ()) / img->width (); + const Axis x2d = cameraAxis (false), y2d = cameraAxis (true); @@ -1374,4 +1394,5 @@ overlayMeta& info = g_overlays[camera ()]; delete info.img; + info.img = null; } \ No newline at end of file
--- a/src/gldraw.h Tue May 14 00:52:20 2013 +0300 +++ b/src/gldraw.h Tue May 14 01:22:40 2013 +0300 @@ -25,6 +25,7 @@ #include "common.h" #include "ldtypes.h" +class QDialogButtonBox; class RadioBox; class QDoubleSpinBox; class QSpinBox; @@ -143,16 +144,18 @@ double lheight () const; GL::Camera camera () const; -public slots: - void slot_fpath () const; - void slot_help () const; - private: RadioBox* rb_camera; QPushButton* btn_fpath; QLineEdit* le_fpath; QSpinBox* sb_ofsx, *sb_ofsy; QDoubleSpinBox* dsb_lwidth, *dsb_lheight; + QDialogButtonBox* dbb_buttons; + +private slots: + void slot_fpath (); + void slot_help (); + void slot_dimensionsChanged (); }; #endif // GLDRAW_H \ No newline at end of file