# HG changeset patch # User Santeri Piippo # Date 1372952484 -10800 # Node ID 76db02dc7f603fb6d09777a3974c3d23825d4042 # Parent b6a814a608c60ab23b6db023ca2365edc22eb707 Designerified the replace coordinates action diff -r b6a814a608c6 -r 76db02dc7f60 src/dialogs.cpp --- a/src/dialogs.cpp Thu Jul 04 18:03:22 2013 +0300 +++ b/src/dialogs.cpp Thu Jul 04 18:41:24 2013 +0300 @@ -153,65 +153,6 @@ dbb_buttons->button (QDialogButtonBox::Ok)->setEnabled (enable); } -ReplaceCoordsDialog::ReplaceCoordsDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { - cbg_axes = makeAxesBox (); - - lb_search = new QLabel ("Search:"); - lb_replacement = new QLabel ("Replacement:"); - - dsb_search = new QDoubleSpinBox; - dsb_search->setRange (-10000.0f, 10000.0f); - dsb_search->setDecimals (6); - - dsb_replacement = new QDoubleSpinBox; - dsb_replacement->setRange (-10000.0f, 10000.0f); - dsb_replacement->setDecimals (6); - - cb_any = new QCheckBox ("Any"); - cb_rel = new QCheckBox ("Relative"); - - connect (cb_any, SIGNAL (stateChanged (int)), this, SLOT (anyChanged (int))); - - QGridLayout* valueLayout = new QGridLayout; - valueLayout->setColumnStretch (1, 1); - valueLayout->addWidget (lb_search, 0, 0); - valueLayout->addWidget (dsb_search, 0, 1); - valueLayout->addWidget (cb_any, 0, 2); - valueLayout->addWidget (lb_replacement, 1, 0); - valueLayout->addWidget (dsb_replacement, 1, 1); - valueLayout->addWidget (cb_rel, 1, 2); - - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget (cbg_axes); - layout->addLayout (valueLayout); - layout->addWidget (makeButtonBox (*this)); - setLayout (layout); -} - -double ReplaceCoordsDialog::searchValue () const { - return dsb_search->value (); -} - -double ReplaceCoordsDialog::replacementValue () const { - return dsb_replacement->value (); -} - -vector ReplaceCoordsDialog::axes () const { - return cbg_axes->checkedValues (); -} - -void ReplaceCoordsDialog::anyChanged (int state) { - dsb_search->setEnabled (state != Qt::Checked); -} - -bool ReplaceCoordsDialog::any () const { - return cb_any->isChecked (); -} - -bool ReplaceCoordsDialog::rel () const { - return cb_rel->isChecked (); -} - // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= diff -r b6a814a608c6 -r 76db02dc7f60 src/dialogs.h --- a/src/dialogs.h Thu Jul 04 18:03:22 2013 +0300 +++ b/src/dialogs.h Thu Jul 04 18:41:24 2013 +0300 @@ -64,28 +64,6 @@ void fillDefaults (int newcam); }; -class ReplaceCoordsDialog : public QDialog { - Q_OBJECT - -public: - explicit ReplaceCoordsDialog (QWidget* parent = null, Qt::WindowFlags f = 0); - - vector axes () const; - double searchValue () const; - double replacementValue () const; - bool any () const; - bool rel () const; - -private: - CheckBoxGroup* cbg_axes; - QLabel* lb_search, *lb_replacement; - QDoubleSpinBox* dsb_search, *dsb_replacement; - QCheckBox* cb_any, *cb_rel; - -private slots: - void anyChanged (int state); -}; - // ============================================================================= // SetContentsDialog // diff -r b6a814a608c6 -r 76db02dc7f60 src/gui_editactions.cpp --- a/src/gui_editactions.cpp Thu Jul 04 18:03:22 2013 +0300 +++ b/src/gui_editactions.cpp Thu Jul 04 18:41:24 2013 +0300 @@ -31,6 +31,7 @@ #include "gldraw.h" #include "dialogs.h" #include "colors.h" +#include "ui_replcoords.h" vector g_Clipboard; @@ -532,37 +533,51 @@ } // ============================================================================= -MAKE_ACTION (replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL (R)) { - ReplaceCoordsDialog dlg; - - if (!dlg.exec ()) +MAKE_ACTION( replaceCoords, "Replace Coordinates", "replace-coords", "Find and replace coordinate values", CTRL( R )) +{ + QDialog* dlg = new QDialog( g_win ); + Ui::ReplaceCoordsUI ui; + ui.setupUi( dlg ); + + if( !dlg->exec() ) return; + + const double search = ui.search->value(), + replacement = ui.replacement->value(); + const bool any = ui.any->isChecked(), + rel = ui.relative->isChecked(); - const double search = dlg.searchValue (), - replacement = dlg.replacementValue (); - const bool any = dlg.any (), - rel = dlg.rel (); + vector sel; + int num = 0; - vector sel = dlg.axes (); + if( ui.x->isChecked() ) sel << X; + if( ui.y->isChecked() ) sel << Y; + if( ui.z->isChecked() ) sel << Z; - for (LDObject* obj : g_win->sel ()) - for (short i = 0; i < obj->vertices (); ++i) { - vertex v = obj->getVertex (i); - for (int ax : sel) { - double& coord = v[(Axis) ax]; + for( LDObject * obj : g_win->sel() ) + for( short i = 0; i < obj->vertices(); ++i ) + { + vertex v = obj->getVertex( i ); + + for( Axis ax : sel ) + { + double& coord = v[ax]; - if (any || coord == search) { - if (!rel) + if( any || coord == search ) + { + if( !rel ) coord = 0; coord += replacement; + num++; } } - obj->setVertex (i, v); + obj->setVertex( i, v ); } - g_win->fullRefresh (); + log( ForgeWindow::tr( "Altered %1 values" ), num ); + g_win->fullRefresh(); } // ================================================================================================= diff -r b6a814a608c6 -r 76db02dc7f60 src/ui/replcoords.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/replcoords.ui Thu Jul 04 18:41:24 2013 +0300 @@ -0,0 +1,196 @@ + + + ReplaceCoordsUI + + + + 0 + 0 + 239 + 153 + + + + Replace Coordinates + + + + + + Axes + + + + + + Replace X coordinates. + + + X + + + + + + + Replace Y coordinates. + + + Y + + + + + + + Replace Z coordinates. + + + Z + + + + + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + Search: + + + + + + + + + 4 + + + -10000.000000000000000 + + + 10000.000000000000000 + + + + + + + If this is checked, all of the coordinates of selected objects will be changed. If not, they have to match the search value. + +Use this with the Relative option to offset objects, or without to project or flatten. + + + Any + + + + + + + + + Replace: + + + + + + + + + 4 + + + -10000.000000000000000 + + + 10000.000000000000000 + + + + + + + If this is set, the replace value is added to the coordinates, rather than replaced with. + + + Relative + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ReplaceCoordsUI + accept() + + + 224 + 128 + + + 157 + 144 + + + + + buttonBox + rejected() + ReplaceCoordsUI + reject() + + + 246 + 134 + + + 252 + 144 + + + + + any + clicked(bool) + search + setDisabled(bool) + + + 207 + 13 + + + 125 + 12 + + + + +