--- a/src/gldraw.cpp Tue May 14 02:28:28 2013 +0300 +++ b/src/gldraw.cpp Tue May 14 03:23:01 2013 +0300 @@ -17,13 +17,9 @@ */ #include <QGLWidget> -#include <qdialog.h> -#include <qlineedit.h> -#include <qspinbox.h> -#include <qdialogbuttonbox.h> -#include <QFileDialog> #include <qevent.h> #include <GL/glu.h> + #include "common.h" #include "config.h" #include "file.h" @@ -33,8 +29,7 @@ #include "gui.h" #include "misc.h" #include "history.h" -#include "radiobox.h" -#include "docs.h" +#include "dialogs.h" static double g_objOffset[3]; @@ -51,13 +46,7 @@ { { 0, -1, 0 }, Z, Y, false, true }, }; -struct overlayMeta { - vertex v0, v1; - ushort ox, oy; - double lw, lh; - str fname; - QImage* img; -} g_overlays[6]; +overlayMeta g_overlays[6]; cfg (str, gl_bgcolor, "#CCCCD9"); cfg (str, gl_maincolor, "#707078"); @@ -75,19 +64,19 @@ struct CameraIcon { QPixmap* img; QRect srcRect, destRect, selRect; - GLRenderer::Camera cam; + GL::Camera cam; } g_CameraIcons[7]; const char* g_CameraNames[7] = { "Top", "Front", "Left", "Bottom", "Back", "Right", "Free" }; -const GLRenderer::Camera g_Cameras[7] = { - GLRenderer::Top, - GLRenderer::Front, - GLRenderer::Left, - GLRenderer::Bottom, - GLRenderer::Back, - GLRenderer::Right, - GLRenderer::Free +const GL::Camera g_Cameras[7] = { + GL::Top, + GL::Front, + GL::Left, + GL::Bottom, + GL::Back, + GL::Right, + GL::Free }; const struct GLAxis { @@ -105,7 +94,7 @@ GLRenderer::GLRenderer (QWidget* parent) : QGLWidget (parent) { resetAngles (); m_picking = m_rangepick = false; - m_camera = (GLRenderer::Camera) gl_camera.value; + m_camera = (GL::Camera) gl_camera.value; m_drawToolTip = false; m_planeDraw = false; @@ -118,7 +107,7 @@ m_thinBorderPen.setWidth (1); // Init camera icons - for (const GLRenderer::Camera cam : g_Cameras) { + for (const GL::Camera cam : g_Cameras) { str iconname; iconname.format ("camera-%s", str (g_CameraNames[cam]).lower ().c ()); @@ -948,7 +937,7 @@ } // ============================================================================= -void GLRenderer::setCamera (const GLRenderer::Camera cam) { +void GLRenderer::setCamera (const GL::Camera cam) { m_camera = cam; gl_camera = (int) cam; } @@ -1243,120 +1232,6 @@ } // ============================================================================= -OverlayDialog::OverlayDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { - rb_camera = new RadioBox ("Camera", {}, 0, Qt::Horizontal, this); - - for (int i = 0; i < 6; ++i) { - if (i == 3) - rb_camera->rowBreak (); - - rb_camera->addButton (g_CameraNames[i]); - } - - GL::Camera cam = g_win->R ()->camera (); - if (cam != GL::Free) - rb_camera->setValue ((int) cam); - - QGroupBox* gb_image = new QGroupBox ("Image", this); - - QLabel* lb_fpath = new QLabel ("File:"); - le_fpath = new QLineEdit; - le_fpath->setFocus (); - - QLabel* lb_ofs = new QLabel ("Origin:"); - btn_fpath = new QPushButton; - btn_fpath->setIcon (getIcon ("folder")); - connect (btn_fpath, SIGNAL (clicked ()), this, SLOT (slot_fpath ())); - - sb_ofsx = new QSpinBox; - 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:"); - 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"); - - 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); - fpathlayout->addWidget (le_fpath); - fpathlayout->addWidget (btn_fpath); - - QGridLayout* metalayout = new QGridLayout; - metalayout->addWidget (lb_ofs, 0, 0); - metalayout->addWidget (sb_ofsx, 0, 1); - metalayout->addWidget (sb_ofsy, 0, 2); - metalayout->addWidget (lb_dimens, 1, 0); - metalayout->addWidget (dsb_lwidth, 1, 1); - metalayout->addWidget (dsb_lheight, 1, 2); - - QVBoxLayout* imagelayout = new QVBoxLayout (gb_image); - imagelayout->addLayout (fpathlayout); - imagelayout->addLayout (metalayout); - - QVBoxLayout* layout = new QVBoxLayout (this); - layout->addWidget (rb_camera); - layout->addWidget (gb_image); - layout->addWidget (dbb_buttons); - - connect (dsb_lwidth, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); - connect (dsb_lheight, SIGNAL (valueChanged (double)), this, SLOT (slot_dimensionsChanged ())); - connect (rb_camera, SIGNAL (valueChanged (int)), this, SLOT (fillDefaults (int))); - - slot_dimensionsChanged (); - fillDefaults (cam); -} - -void OverlayDialog::fillDefaults (int newcam) { - overlayMeta& info = g_overlays[newcam]; - - if (info.img != null) { - le_fpath->setText (info.fname); - sb_ofsx->setValue (info.ox); - sb_ofsy->setValue (info.oy); - dsb_lwidth->setValue (info.lw); - dsb_lheight->setValue (info.lh); - } else { - le_fpath->setText (""); - sb_ofsx->setValue (0); - sb_ofsy->setValue (0); - dsb_lwidth->setValue (0.0f); - dsb_lheight->setValue (0.0f); - } -} - -str OverlayDialog::fpath () const { return le_fpath->text (); } -ushort OverlayDialog::ofsx () const { return sb_ofsx->value (); } -ushort OverlayDialog::ofsy () const { return sb_ofsy->value (); } -double OverlayDialog::lwidth () const { return dsb_lwidth->value (); } -double OverlayDialog::lheight () const { return dsb_lheight->value (); } -GL::Camera OverlayDialog::camera () const { return (GL::Camera) rb_camera->value (); } - -void OverlayDialog::slot_fpath () { - le_fpath->setText (QFileDialog::getOpenFileName (null, "Overlay image")); -} - -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;