Wed, 08 May 2013 13:19:07 +0300
Object editing dialog now can alter the matrix of subfiles and radials
zz_addObjectDialog.cpp | file | annotate | diff | comparison | revisions | |
zz_addObjectDialog.h | file | annotate | diff | comparison | revisions |
--- a/zz_addObjectDialog.cpp Wed May 08 04:10:31 2013 +0300 +++ b/zz_addObjectDialog.cpp Wed May 08 13:19:07 2013 +0300 @@ -49,6 +49,8 @@ AddObjectDialog::AddObjectDialog (const LDObject::Type type, LDObject* obj, QWidget* parent) : QDialog (parent) { + setlocale (LC_ALL, "C"); + short coordCount = 0; switch (type) { @@ -129,7 +131,9 @@ } connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ())); - le_subfileName = new QLineEdit (); + lb_subfileName = new QLabel ("File:"); + le_subfileName = new QLineEdit; + le_subfileName->setFocus (); if (obj) { LDSubfile* ref = static_cast<LDSubfile*> (obj); @@ -175,6 +179,7 @@ break; default: + assert (false); return; } @@ -230,12 +235,12 @@ break; case LDObject::Radial: - layout->addWidget (rb_radType, 1, 1, 3, 1); - layout->addWidget (cb_radHiRes, 1, 2); - layout->addWidget (lb_radSegments, 2, 2); - layout->addWidget (sb_radSegments, 2, 3); - layout->addWidget (lb_radRingNum, 3, 2); - layout->addWidget (sb_radRingNum, 3, 3); + layout->addWidget (rb_radType, 1, 1, 3, 2); + layout->addWidget (cb_radHiRes, 1, 3); + layout->addWidget (lb_radSegments, 2, 3); + layout->addWidget (sb_radSegments, 2, 4); + layout->addWidget (lb_radRingNum, 3, 3); + layout->addWidget (sb_radRingNum, 3, 4); if (obj) for (short i = 0; i < 3; ++i) @@ -243,8 +248,9 @@ break; case LDObject::Subfile: - layout->addWidget (tw_subfileList, 1, 1); - layout->addWidget (le_subfileName, 2, 1); + layout->addWidget (tw_subfileList, 1, 1, 1, 2); + layout->addWidget (lb_subfileName, 2, 1); + layout->addWidget (le_subfileName, 2, 2); if (obj) for (short i = 0; i < 3; ++i) @@ -255,6 +261,24 @@ break; } + if (type == LDObject::Subfile || type == LDObject::Radial) { + QLabel* lb_matrix = new QLabel ("Matrix:"); + le_matrix = new QLineEdit; + // le_matrix->setValidator (new QDoubleValidator); + matrix<3> defval = g_identity; + + if (obj) { + if (obj->getType () == LDObject::Subfile) + defval = static_cast<LDSubfile*> (obj)->mMatrix; + else + defval = static_cast<LDRadial*> (obj)->mMatrix; + } + + le_matrix->setText (defval.stringRep ()); + layout->addWidget (lb_matrix, 4, 1); + layout->addWidget (le_matrix, 4, 2, 1, 3); + } + if (defaults->isColored ()) layout->addWidget (pb_color, 1, 0); @@ -326,8 +350,6 @@ } // ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= template<class T> T* initObj (LDObject*& obj) { if (obj == null) obj = new T; @@ -339,6 +361,8 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void AddObjectDialog::staticDialog (const LDObject::Type type, LDObject* obj) { + setlocale (LC_ALL, "C"); + // Redirect editing of gibberish to the set contents dialog if (obj && obj->getType () == LDObject::Gibberish) { SetContentsDialog::staticDialog (obj); @@ -361,6 +385,21 @@ if (!newObject) backup = obj->clone (); + matrix<3> transform = g_identity; + if (type == LDObject::Subfile || type == LDObject::Radial) { + vector<str> matrixstrvals = str (dlg.le_matrix->text ()).split (" ", true); + + if (matrixstrvals.size () == 9) { + double matrixvals[9]; + int i = 0; + + for (str val : matrixstrvals) + matrixvals[i++] = atof (val); + + transform = matrix<3> (matrixvals); + } + } + switch (type) { case LDObject::Comment: { @@ -430,7 +469,7 @@ pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions); pRad->eRadialType = (LDRadial::Type) dlg.rb_radType->value (); pRad->dRingNum = dlg.sb_radRingNum->value (); - pRad->mMatrix = g_identity; + pRad->mMatrix = transform; } break; @@ -440,6 +479,10 @@ if (~name == 0) return; // no subfile filename + OpenFile* file = loadSubfile (name); + if (!file) + return; + LDSubfile* ref = initObj<LDSubfile> (obj); ref->dColor = dlg.dColor; @@ -447,8 +490,8 @@ ref->vPosition[ax] = dlg.dsb_coords[ax]->value (); ref->zFileName = name; - ref->mMatrix = g_identity; - ref->pFile = loadSubfile (name); + ref->mMatrix = transform; + ref->pFile = file; } break;
--- a/zz_addObjectDialog.h Wed May 08 04:10:31 2013 +0300 +++ b/zz_addObjectDialog.h Wed May 08 13:19:07 2013 +0300 @@ -55,6 +55,7 @@ // Subfile stuff QTreeWidget* tw_subfileList; QLineEdit* le_subfileName; + QLabel* lb_subfileName; // Radial stuff QCheckBox* cb_radHiRes; @@ -63,6 +64,8 @@ QLabel* lb_radType, *lb_radResolution, *lb_radSegments, *lb_radRingNum; + QLineEdit* le_matrix; + QDialogButtonBox* bbx_buttons; private: