Sun, 04 Oct 2015 22:54:17 +0300
A bit more cleanup. Finally removed the PROPERTY macro. (now let's see about making a new one sometime that isn't so terrible?)
--- a/src/addObjectDialog.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/addObjectDialog.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -95,7 +95,7 @@ coordCount = 3; tw_subfileList = new QTreeWidget(); tw_subfileList->setHeaderLabel (tr ("Primitives")); - PopulatePrimitives (tw_subfileList, (obj ? static_cast<LDSubfile*> (obj)->fileInfo()->name() : "")); + populatePrimitivesTree (tw_subfileList, (obj ? static_cast<LDSubfile*> (obj)->fileInfo()->name() : "")); connect (tw_subfileList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_subfileTypeChanged())); lb_subfileName = new QLabel ("File:"); @@ -242,7 +242,7 @@ // ============================================================================= QString AddObjectDialog::currentSubfileName() { - SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem()); + PrimitiveTreeItem* item = static_cast<PrimitiveTreeItem*> (tw_subfileList->currentItem()); if (item->primitive() == nullptr) return ""; // selected a heading
--- a/src/basics.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/basics.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -298,20 +298,24 @@ m_vertex1.setX (qMax (vertex.x(), m_vertex1.x())); m_vertex1.setY (qMax (vertex.y(), m_vertex1.y())); m_vertex1.setZ (qMax (vertex.z(), m_vertex1.z())); - setEmpty (false); + m_isEmpty = false; } // ============================================================================= // +// Clears the bounding box +// void LDBoundingBox::reset() { m_vertex0 = Vertex (10000.0, 10000.0, 10000.0); m_vertex1 = Vertex (-10000.0, -10000.0, -10000.0); - setEmpty (true); + m_isEmpty = true; } // ============================================================================= // +// Returns the length of the bounding box on the longest measure. +// double LDBoundingBox::longestMeasurement() const { double xscale = (m_vertex0.x() - m_vertex1.x()); @@ -335,6 +339,8 @@ // ============================================================================= // +// Yields the center of the bounding box. +// Vertex LDBoundingBox::center() const { return Vertex ( @@ -342,3 +348,18 @@ (m_vertex0.y() + m_vertex1.y()) / 2, (m_vertex0.z() + m_vertex1.z()) / 2); } + +bool LDBoundingBox::isEmpty() const +{ + return m_isEmpty; +} + +const Vertex& LDBoundingBox::vertex0() const +{ + return m_vertex0; +} + +const Vertex& LDBoundingBox::vertex1() const +{ + return m_vertex1; +} \ No newline at end of file
--- a/src/basics.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/basics.h Sun Oct 04 22:54:17 2015 +0300 @@ -163,36 +163,25 @@ // class LDBoundingBox { - PROPERTY (private, bool, isEmpty, setEmpty, STOCK_WRITE) - PROPERTY (private, Vertex, vertex0, setVertex0, STOCK_WRITE) - PROPERTY (private, Vertex, vertex1, setVertex1, STOCK_WRITE) - public: - // Constructs an empty bounding box. LDBoundingBox(); - // Clears the bounding box - void reset(); - - // Returns the length of the bounding box on the longest measure. + void calcObject (LDObject* obj); + void calcVertex (const Vertex& vertex); + Vertex center() const; + bool isEmpty() const; double longestMeasurement() const; - - // Calculates the given \c obj to the bounding box, adjusting - // extremas if necessary. - void calcObject (LDObject* obj); + void reset(); + const Vertex& vertex0() const; + const Vertex& vertex1() const; - // Calculates the given \c vertex to the bounding box, adjusting - // extremas if necessary. - void calcVertex (const Vertex& vertex); + LDBoundingBox& operator<< (LDObject* obj); + LDBoundingBox& operator<< (const Vertex& v); - // Yields the center of the bounding box. - Vertex center() const; - - // An operator overload for calcObject() - LDBoundingBox& operator<< (LDObject* obj); - - // An operator overload for calcVertex() - LDBoundingBox& operator<< (const Vertex& v); +private: + bool m_isEmpty; + Vertex m_vertex0; + Vertex m_vertex1; }; extern const Vertex Origin;
--- a/src/dialogs/colorselector.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/dialogs/colorselector.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -34,11 +34,11 @@ ColorSelector::ColorSelector (QWidget* parent, LDColor defaultvalue) : QDialog (parent), HierarchyElement (parent), - ui (*new Ui_ColorSelUi) + ui (*new Ui_ColorSelUi), + m_selection (defaultvalue) { m_firstResize = true; ui.setupUi (this); - setSelection (defaultvalue); QGridLayout* layout = new QGridLayout (this); @@ -123,7 +123,7 @@ (*button)->setChecked (false); } - setSelection (color); + m_selection = color; button->setChecked (true); drawColorInfo(); } @@ -155,7 +155,7 @@ { qint32 colorIndex = (ui.transparentDirectColor->isChecked() ? 0x03000000 : 0x02000000); colorIndex |= (color.red() << 16) | (color.green() << 8) | (color.blue()); - setSelection (colorIndex); + m_selection = colorIndex; drawColorInfo(); } @@ -188,3 +188,8 @@ return false; } + +LDColor ColorSelector::selection() const +{ + return m_selection; +}
--- a/src/dialogs/colorselector.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/dialogs/colorselector.h Sun Oct 04 22:54:17 2015 +0300 @@ -24,18 +24,19 @@ class ColorSelector : public QDialog, public HierarchyElement { Q_OBJECT - PROPERTY (private, LDColor, selection, setSelection, STOCK_WRITE) public: explicit ColorSelector (QWidget* parent, LDColor defaultvalue = LDColor::nullColor()); virtual ~ColorSelector(); static bool selectColor (QWidget* parent, LDColor& val, LDColor defval = LDColor::nullColor()); + LDColor selection() const; private: class Ui_ColorSelUi& ui; QMap<int, QPushButton*> m_buttons; QMap<QPushButton*, int> m_buttonsReversed; bool m_firstResize; + LDColor m_selection; void drawColorInfo(); void selectDirectColor (QColor col);
--- a/src/dialogs/configdialog.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/dialogs/configdialog.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -47,6 +47,29 @@ #endif "All files (*.*)(*.*)"; +ShortcutListItem::ShortcutListItem (QListWidget* view, int type) : + QListWidgetItem (view, type) {} + +QAction* ShortcutListItem::action() const +{ + return m_action; +} + +void ShortcutListItem::setAction (QAction* action) +{ + m_action = action; +} + +QKeySequence ShortcutListItem::sequence() const +{ + return m_sequence; +} + +void ShortcutListItem::setSequence (const QKeySequence& sequence) +{ + m_sequence = sequence; +} + ConfigDialog::ConfigDialog (QWidget* parent, ConfigDialog::Tab defaulttab, Qt::WindowFlags f) : QDialog (parent, f), HierarchyElement (parent), @@ -308,7 +331,7 @@ // // Update the list of color toolbar items in the quick color tab. // -void ConfigDialog::updateQuickColorList (LDQuickColor* sel) +void ConfigDialog::updateQuickColorList (ColorToolbarItem* sel) { for (QListWidgetItem * item : quickColorItems) delete item; @@ -316,7 +339,7 @@ quickColorItems.clear(); // Init table items - for (LDQuickColor& entry : quickColors) + for (ColorToolbarItem& entry : quickColors) { QListWidgetItem* item = new QListWidgetItem; @@ -357,7 +380,7 @@ // void ConfigDialog::slot_setColor() { - LDQuickColor* entry = nullptr; + ColorToolbarItem* entry = nullptr; QListWidgetItem* item = nullptr; const bool isNew = static_cast<QPushButton*> (sender()) == ui.quickColor_add; @@ -387,7 +410,7 @@ } else { - LDQuickColor newentry (value, nullptr); + ColorToolbarItem newentry (value, nullptr); item = getSelectedQuickColor(); int idx = (item) ? getItemRow (item, quickColorItems) + 1 : quickColorItems.size(); quickColors.insert (idx, newentry); @@ -437,7 +460,7 @@ // void ConfigDialog::slot_addColorSeparator() { - quickColors << LDQuickColor::getSeparator(); + quickColors << ColorToolbarItem::makeSeparator(); updateQuickColorList (&quickColors[quickColors.size() - 1]); } @@ -631,7 +654,7 @@ { QString val; - for (const LDQuickColor& entry : quickColors) + for (const ColorToolbarItem& entry : quickColors) { if (val.length() > 0) val += ':';
--- a/src/dialogs/configdialog.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/dialogs/configdialog.h Sun Oct 04 22:54:17 2015 +0300 @@ -27,12 +27,17 @@ // ============================================================================= class ShortcutListItem : public QListWidgetItem { - PROPERTY (public, QAction*, action, setAction, STOCK_WRITE) - PROPERTY (public, QKeySequence, sequence, setSequence, STOCK_WRITE) +public: + explicit ShortcutListItem (QListWidget* view = nullptr, int type = Type); -public: - explicit ShortcutListItem (QListWidget* view = nullptr, int type = Type) : - QListWidgetItem (view, type) {} + QAction* action() const; + QKeySequence sequence() const; + void setAction (QAction* action); + void setSequence (const QKeySequence& sequence); + +private: + QAction* m_action; + QKeySequence m_sequence; }; struct ExternalProgramWidgets @@ -63,7 +68,7 @@ explicit ConfigDialog (QWidget* parent = nullptr, Tab defaulttab = (Tab) 0, Qt::WindowFlags f = 0); virtual ~ConfigDialog(); - QList<LDQuickColor> quickColors; + QList<ColorToolbarItem> quickColors; private: class Ui_ConfigDialog& ui; @@ -75,7 +80,7 @@ void applySettings(); void addShortcut (QAction* act); void setButtonBackground (QPushButton* button, QString value); - void updateQuickColorList (LDQuickColor* sel = nullptr); + void updateQuickColorList (ColorToolbarItem* sel = nullptr); void setShortcutText (ShortcutListItem* item); int getItemRow (QListWidgetItem* item, QList<QListWidgetItem*>& haystack); QString quickColorString();
--- a/src/format.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/format.h Sun Oct 04 22:54:17 2015 +0300 @@ -28,13 +28,13 @@ { public: StringFormatArg (const QString& a) : m_text (a) {} - StringFormatArg (const char& a) : m_text (a) {} - StringFormatArg (const uchar& a) : m_text (a) {} - StringFormatArg (const QChar& a) : m_text (a) {} + StringFormatArg (char a) : m_text (a) {} + StringFormatArg (uchar a) : m_text (a) {} + StringFormatArg (QChar a) : m_text (a) {} StringFormatArg (int a) : m_text (QString::number (a)) {} StringFormatArg (long a) : m_text (QString::number (a)) {} - StringFormatArg (const float& a) : m_text (QString::number (a)) {} - StringFormatArg (const double& a) : m_text (QString::number (a)) {} + StringFormatArg (float a) : m_text (QString::number (a)) {} + StringFormatArg (double a) : m_text (QString::number (a)) {} StringFormatArg (const Vertex& a) : m_text (a.toString()) {} StringFormatArg (const Matrix& a) : m_text (a.toString()) {} StringFormatArg (const char* a) : m_text (a) {}
--- a/src/glRenderer.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/glRenderer.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -1589,7 +1589,7 @@ { if (m_window and ev->source() == m_window->getPrimitivesTree()) { - SubfileListItem* item = static_cast<SubfileListItem*> (m_window->getPrimitivesTree()->currentItem()); + PrimitiveTreeItem* item = static_cast<PrimitiveTreeItem*> (m_window->getPrimitivesTree()->currentItem()); QString primitiveName = item->primitive()->name; LDSubfile* ref = LDSpawn<LDSubfile>(); ref->setColor (MainColor);
--- a/src/macros.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/macros.h Sun Oct 04 22:54:17 2015 +0300 @@ -27,27 +27,6 @@ char (&countofHelper (T(&)[N]))[N]; #define countof(x) ((int) sizeof (countofHelper(x))) -#define PROPERTY(ACCESS, TYPE, READ, WRITE, WRITETYPE) \ -private: \ - TYPE m_##READ; \ - \ -public: \ - inline TYPE const& READ() const \ - { \ - return m_##READ; \ - } \ - \ -ACCESS: \ - void WRITE (TYPE const& a) PROPERTY_##WRITETYPE (READ) \ - -#define PROPERTY_STOCK_WRITE(READ) \ - { \ - m_##READ = a; \ - } - -#define PROPERTY_CUSTOM_WRITE(READ) \ - ; - #define DEFINE_CLASS(SELF, SUPER) \ public: \ using Self = SELF; \
--- a/src/mainwindow.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/mainwindow.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -249,20 +249,20 @@ // --------------------------------------------------------------------------------------------------------------------- // -QList<LDQuickColor> LoadQuickColorList() +QList<ColorToolbarItem> LoadQuickColorList() { - QList<LDQuickColor> colors; + QList<ColorToolbarItem> colors; for (QString colorname : g_win->configBag()->quickColorToolbar().split (":")) { if (colorname == "|") - colors << LDQuickColor::getSeparator(); + colors << ColorToolbarItem::makeSeparator(); else { LDColor color = colorname.toInt(); if (color.isValid()) - colors << LDQuickColor (color, nullptr); + colors << ColorToolbarItem (color, nullptr); } } @@ -278,7 +278,7 @@ ui.toolBarColors->addAction (ui.actionUncolor); ui.toolBarColors->addSeparator(); - for (LDQuickColor& entry : m_quickColors) + for (ColorToolbarItem& entry : m_quickColors) { if (entry.isSeparator()) { @@ -568,7 +568,7 @@ QToolButton* button = static_cast<QToolButton*> (sender()); LDColor color = LDColor::nullColor(); - for (const LDQuickColor& entry : m_quickColors) + for (const ColorToolbarItem& entry : m_quickColors) { if (entry.toolButton() == button) { @@ -1060,7 +1060,7 @@ // --------------------------------------------------------------------------------------------------------------------- // -void MainWindow::setQuickColors (const QList<LDQuickColor>& colors) +void MainWindow::setQuickColors (const QList<ColorToolbarItem>& colors) { m_quickColors = colors; updateColorToolbar(); @@ -1070,7 +1070,7 @@ // void MainWindow::updatePrimitives() { - PopulatePrimitives (ui.primitives); + populatePrimitivesTree (ui.primitives); } // --------------------------------------------------------------------------------------------------------------------- @@ -1325,39 +1325,55 @@ // --------------------------------------------------------------------------------------------------------------------- // -LDQuickColor::LDQuickColor (LDColor color, QToolButton* toolButton) : +ColorToolbarItem::ColorToolbarItem (LDColor color, QToolButton* toolButton) : m_color (color), m_toolButton (toolButton) {} -// --------------------------------------------------------------------------------------------------------------------- -// -LDQuickColor LDQuickColor::getSeparator() +ColorToolbarItem ColorToolbarItem::makeSeparator() +{ + return ColorToolbarItem (LDColor::nullColor(), nullptr); +} + +bool ColorToolbarItem::isSeparator() const +{ + return color() == LDColor::nullColor(); +} + +LDColor ColorToolbarItem::color() const { - return LDQuickColor (LDColor::nullColor(), nullptr); + return m_color; +} + +void ColorToolbarItem::setColor (LDColor color) +{ + m_color = color; +} + +QToolButton* ColorToolbarItem::toolButton() const +{ + return m_toolButton; +} + +void ColorToolbarItem::setToolButton (QToolButton* value) +{ + m_toolButton = value; } // --------------------------------------------------------------------------------------------------------------------- // -bool LDQuickColor::isSeparator() const -{ - return color() == LDColor::nullColor(); -} - -// --------------------------------------------------------------------------------------------------------------------- -// -void PopulatePrimitives (QTreeWidget* tw, QString const& selectByDefault) +void populatePrimitivesTree (QTreeWidget* tw, QString const& selectByDefault) { tw->clear(); for (PrimitiveCategory* cat : g_PrimitiveCategories) { - SubfileListItem* parentItem = new SubfileListItem (tw, nullptr); + PrimitiveTreeItem* parentItem = new PrimitiveTreeItem (tw, nullptr); parentItem->setText (0, cat->name()); QList<QTreeWidgetItem*> subfileItems; for (Primitive& prim : cat->prims) { - SubfileListItem* item = new SubfileListItem (parentItem, &prim); + PrimitiveTreeItem* item = new PrimitiveTreeItem (parentItem, &prim); item->setText (0, format ("%1 - %2", prim.name, prim.title)); subfileItems << item; @@ -1370,3 +1386,16 @@ tw->addTopLevelItem (parentItem); } } + +PrimitiveTreeItem::PrimitiveTreeItem (QTreeWidgetItem* parent, Primitive* info) : + QTreeWidgetItem (parent), + m_primitive (info) {} + +PrimitiveTreeItem::PrimitiveTreeItem (QTreeWidget* parent, Primitive* info) : + QTreeWidgetItem (parent), + m_primitive (info) {} + +Primitive* PrimitiveTreeItem::primitive() const +{ + return m_primitive; +}
--- a/src/mainwindow.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/mainwindow.h Sun Oct 04 22:54:17 2015 +0300 @@ -39,16 +39,21 @@ struct Primitive; class Toolset; -class LDQuickColor +class ColorToolbarItem { - PROPERTY (public, LDColor, color, setColor, STOCK_WRITE) - PROPERTY (public, QToolButton*, toolButton, setToolButton, STOCK_WRITE) +public: + ColorToolbarItem (LDColor color, QToolButton* toolButton); + LDColor color() const; + bool isSeparator() const; + void setColor (LDColor color); + void setToolButton (QToolButton* value); + QToolButton* toolButton() const; -public: - LDQuickColor (LDColor color, QToolButton* toolButton); - bool isSeparator() const; + static ColorToolbarItem makeSeparator(); - static LDQuickColor getSeparator(); +private: + LDColor m_color; + QToolButton* m_toolButton; }; // Object list class for MainWindow @@ -102,7 +107,7 @@ void saveShortcuts(); void scrollToSelection(); const LDObjectList& selectedObjects(); - void setQuickColors (const QList<LDQuickColor>& colors); + void setQuickColors (const QList<ColorToolbarItem>& colors); void spawnContextMenu (const QPoint pos); int suggestInsertPoint(); void syncSettings(); @@ -135,7 +140,7 @@ class GuiUtilities* m_guiUtilities; GLRenderer* m_renderer; LDObjectList m_sel; - QList<LDQuickColor> m_quickColors; + QList<ColorToolbarItem> m_quickColors; QList<QToolButton*> m_colorButtons; QList<QAction*> m_recentFiles; class Ui_MainWindow& ui; @@ -167,7 +172,7 @@ QPixmap GetIcon (QString iconName); // Returns a list of quick colors based on the configuration entry. -QList<LDQuickColor> LoadQuickColorList(); +QList<ColorToolbarItem> LoadQuickColorList(); // Asks the user a yes/no question with the given message and the given window title. // Returns true if the user answered yes, false if no. @@ -209,20 +214,15 @@ } } -// ============================================================================= -// -class SubfileListItem : public QTreeWidgetItem +class PrimitiveTreeItem : public QTreeWidgetItem { - PROPERTY (public, Primitive*, primitive, setPrimitive, STOCK_WRITE) - public: - SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : - QTreeWidgetItem (parent), - m_primitive (info) {} + PrimitiveTreeItem (QTreeWidgetItem* parent, Primitive* info); + PrimitiveTreeItem (QTreeWidget* parent, Primitive* info); + Primitive* primitive() const; - SubfileListItem (QTreeWidget* parent, Primitive* info) : - QTreeWidgetItem (parent), - m_primitive (info) {} +private: + Primitive* m_primitive; }; -void PopulatePrimitives (QTreeWidget* tw, const QString& selectByDefault = QString()); +void populatePrimitivesTree (QTreeWidget* tw, const QString& selectByDefault = QString());
--- a/src/messageLog.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/messageLog.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -121,6 +121,16 @@ return m_lines; } +GLRenderer* MessageManager::renderer() const +{ + return m_renderer; +} + +void MessageManager::setRenderer (GLRenderer* renderer) +{ + m_renderer = renderer; +} + // ============================================================================= // void PrintToLog (const QString& msg)
--- a/src/messageLog.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/messageLog.h Sun Oct 04 22:54:17 2015 +0300 @@ -38,28 +38,27 @@ // class MessageManager : public QObject { -Q_OBJECT -PROPERTY (public, GLRenderer*, renderer, setRenderer, STOCK_WRITE) + Q_OBJECT public: // A single line of the message log. class Line { - public: - // Constructs a line with the given \c text - Line (QString text); + public: + // Constructs a line with the given \c text + Line (QString text); - // Check this line's expiry and update alpha accordingly. @changed - // is updated to whether the line has somehow changed since the - // last update. - // - // Returns true if the line is to still stick around, false if it - // expired. - bool update (bool& changed); + // Check this line's expiry and update alpha accordingly. @changed + // is updated to whether the line has somehow changed since the + // last update. + // + // Returns true if the line is to still stick around, false if it + // expired. + bool update (bool& changed); - QString text; - float alpha; - QDateTime expiry; + QString text; + float alpha; + QDateTime expiry; }; // Constructs the message manager. @@ -71,9 +70,13 @@ // Returns all active lines in the message manager. const QList<Line>& getLines() const; + GLRenderer* renderer() const; + void setRenderer (GLRenderer* renderer); + private: - QList<Line> m_lines; - QTimer* m_ticker; + QList<Line> m_lines; + QTimer* m_ticker; + GLRenderer* m_renderer; private slots: void tick();
--- a/src/primitives.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/primitives.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -362,6 +362,11 @@ return true; } +QString PrimitiveCategory::name() const +{ + return m_name; +} + // ============================================================================= // bool IsPrimitiveLoaderBusy()
--- a/src/primitives.h Sun Oct 04 16:55:26 2015 +0300 +++ b/src/primitives.h Sun Oct 04 22:54:17 2015 +0300 @@ -36,7 +36,6 @@ class PrimitiveCategory : public QObject { Q_OBJECT - PROPERTY (public, QString, name, setName, STOCK_WRITE) public: enum RegexType @@ -56,9 +55,13 @@ explicit PrimitiveCategory (QString name, QObject* parent = 0); bool isValidToInclude(); + QString name() const; static void loadCategories(); static void populateCategories(); + +private: + QString m_name; }; //
--- a/src/toolsets/filetoolset.cpp Sun Oct 04 16:55:26 2015 +0300 +++ b/src/toolsets/filetoolset.cpp Sun Oct 04 22:54:17 2015 +0300 @@ -200,7 +200,7 @@ void FileToolset::makePrimitive() { - PrimitivePrompt* dlg = new PrimitivePrompt (g_win); + PrimitivePrompt* dlg = new PrimitivePrompt (m_window); if (not dlg->exec()) return;