--- a/src/gui_editactions.cpp Sat Jul 06 03:24:39 2013 +0300 +++ b/src/gui_editactions.cpp Sat Jul 06 03:44:04 2013 +0300 @@ -33,6 +33,7 @@ #include "colors.h" #include "ui_replcoords.h" #include "ui_editraw.h" +#include "ui_flip.h" vector<str> g_Clipboard; @@ -617,46 +618,34 @@ g_win->fullRefresh(); } -// ================================================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ================================================================================================= -class FlipDialog : public QDialog { -public: - explicit FlipDialog (QWidget* parent = 0, Qt::WindowFlags f = 0) : QDialog (parent, f) { - cbg_axes = makeAxesBox (); +// ================================================================================================ +MAKE_ACTION( flip, "Flip", "flip", "Flip coordinates", CTRL_SHIFT( F )) +{ + QDialog* dlg = new QDialog; + Ui::FlipUI ui; + ui.setupUi( dlg ); + + if( !dlg->exec() ) + return; + + vector<Axis> sel; + 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); - QVBoxLayout* layout = new QVBoxLayout; - layout->addWidget (cbg_axes); - layout->addWidget (makeButtonBox (*this)); - setLayout (layout); + for( Axis ax : sel ) + v[ax] *= -1; + + obj->setVertex (i, v); + g_win->R()->compileObject( obj ); } - vector<int> axes () { return cbg_axes->checkedValues (); } - -private: - CheckBoxGroup* cbg_axes; -}; - -// ================================================================================================ -MAKE_ACTION (flip, "Flip", "flip", "Flip coordinates", CTRL_SHIFT (F)) { - FlipDialog dlg; - - if (!dlg.exec ()) - return; - - vector<int> sel = dlg.axes (); - - for (LDObject* obj : g_win->sel ()) - for (short i = 0; i < obj->vertices (); ++i) { - vertex v = obj->getVertex (i); - - for (int ax : sel) - v[(Axis) ax] *= -1; - - obj->setVertex (i, v); - } - - g_win->fullRefresh (); + g_win->refresh(); } // ================================================================================================