Sat, 06 Jul 2013 03:44:04 +0300
Converted flip prompt to Designer UI
src/gui_editactions.cpp | file | annotate | diff | comparison | revisions | |
src/ui/flip.ui | file | annotate | diff | comparison | revisions |
--- 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(); } // ================================================================================================
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/flip.ui Sat Jul 06 03:44:04 2013 +0300 @@ -0,0 +1,94 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>FlipUI</class> + <widget class="QDialog" name="FlipUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>178</width> + <height>93</height> + </rect> + </property> + <property name="windowTitle"> + <string>Flip</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Axes</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QCheckBox" name="x"> + <property name="text"> + <string>X</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="y"> + <property name="text"> + <string>Y</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="z"> + <property name="text"> + <string>Z</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>FlipUI</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>FlipUI</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>