Wed, 06 Aug 2014 16:18:24 +0300
- major identifier renaming
--- a/codegen/codegen.cpp Mon Aug 04 13:43:54 2014 +0300 +++ b/codegen/codegen.cpp Wed Aug 06 16:18:24 2014 +0300 @@ -33,38 +33,39 @@ using std::cout; using std::endl; -struct entry_type +struct EntryType { string name; string type; string defvalue; - inline bool operator< (entry_type const& other) const + inline bool operator< (EntryType const& other) const { return name < other.name; } - inline bool operator== (entry_type const& other) const + inline bool operator== (EntryType const& other) const { return name == other.name and type == other.type; } - inline bool operator!= (entry_type const& other) const + inline bool operator!= (EntryType const& other) const { return not operator== (other); } }; -char advance_pointer (char const*& ptr) +char AdvancePointer (char const*& ptr) { char a = *ptr++; + if (*ptr == '\0') throw false; return a; } -void read_cfgentries (string const& filename, vector<entry_type>& entries, const char* macroname) +void ReadConfigEntries (string const& filename, vector<EntryType>& entries, const char* macroname) { ifstream is (filename.c_str()); string line; @@ -78,38 +79,38 @@ continue; char const* ptr = &line[macrolen]; - entry_type entry; + EntryType entry; // Skip to paren while (*ptr != '(') - advance_pointer (ptr); + AdvancePointer (ptr); // Skip whitespace while (isspace (*ptr)) - advance_pointer (ptr); + AdvancePointer (ptr); // Skip paren - advance_pointer (ptr); + AdvancePointer (ptr); // Read type while (*ptr != ',') - entry.type += advance_pointer (ptr); + entry.type += AdvancePointer (ptr); // Skip comma and whitespace - for (advance_pointer (ptr); isspace (*ptr); advance_pointer (ptr)) + for (AdvancePointer (ptr); isspace (*ptr); AdvancePointer (ptr)) ; // Read name while (*ptr != ',') - entry.name += advance_pointer (ptr); + entry.name += AdvancePointer (ptr); // Skip comma and whitespace - for (advance_pointer (ptr); isspace (*ptr); advance_pointer (ptr)) + for (AdvancePointer (ptr); isspace (*ptr); AdvancePointer (ptr)) ; // Read default while (*ptr != ')') - entry.defvalue += advance_pointer (ptr); + entry.defvalue += AdvancePointer (ptr); entries.push_back (entry); } @@ -117,7 +118,7 @@ } } -bool check_equality (vector<entry_type> a, vector<entry_type> b) +bool CheckEquality (vector<EntryType> a, vector<EntryType> b) { if (a.size() != b.size()) return false; @@ -136,45 +137,45 @@ int main (int argc, char* argv[]) { - vector<entry_type> entries; - vector<entry_type> oldentries; - read_cfgentries (argv[argc - 1], oldentries, "CODEGEN_CACHE"); + vector<EntryType> entries; + vector<EntryType> oldentries; + ReadConfigEntries (argv[argc - 1], oldentries, "CODEGEN_CACHE"); for (int arg = 1; arg < argc - 1; ++arg) - read_cfgentries (argv[arg], entries, "CFGENTRY"); + ReadConfigEntries (argv[arg], entries, "CFGENTRY"); - if (check_equality (entries, oldentries)) + if (CheckEquality (entries, oldentries)) { cout << "Configuration options unchanged" << endl; + return 0; } - else - { - std::ofstream os (argv[argc - 1]); - os << "#pragma once" << endl; - os << "#define CODEGEN_CACHE(A,B,C)" << endl; - - for (vector<entry_type>::const_iterator it = entries.begin(); it != entries.end(); ++it) - os << "CODEGEN_CACHE (" << it->type << ", " << it->name << ", " << it->defvalue << ")" << endl; - - os << endl; - for (vector<entry_type>::const_iterator it = entries.begin(); it != entries.end(); ++it) - os << "EXTERN_CFGENTRY (" << it->type << ", " << it->name << ")" << endl; - os << endl; - os << "static void InitConfigurationEntry (AbstractConfigEntry* entry);" << endl; - os << "static void SetupConfigurationLists()" << endl; - os << "{" << endl; + std::ofstream os (argv[argc - 1]); + os << "#pragma once" << endl; + os << "#define CODEGEN_CACHE(A,B,C)" << endl; - for (vector<entry_type>::const_iterator it = entries.begin(); it != entries.end(); ++it) - { - os << "\tInitConfigurationEntry (new " << it->type << "ConfigEntry (&cfg::" << - it->name << ", \"" << it->name << "\", " << it->defvalue << "));" << endl; - } - - os << "}" << endl; - - cout << "Wrote configuration options list to " << argv[argc - 1] << "." << endl; + for (vector<EntryType>::const_iterator it = entries.begin(); it != entries.end(); ++it) + { + os << "CODEGEN_CACHE (" << it->type << ", " << it->name << ", " << + it->defvalue << ")" << endl; } + os << endl; + for (vector<EntryType>::const_iterator it = entries.begin(); it != entries.end(); ++it) + os << "EXTERN_CFGENTRY (" << it->type << ", " << it->name << ")" << endl; + + os << endl; + os << "static void InitConfigurationEntry (AbstractConfigEntry* entry);" << endl; + os << "static void SetupConfigurationLists()" << endl; + os << "{" << endl; + + for (vector<EntryType>::const_iterator it = entries.begin(); it != entries.end(); ++it) + { + os << "\tInitConfigurationEntry (new " << it->type << "ConfigEntry (&cfg::" << + it->name << ", \"" << it->name << "\", " << it->defvalue << "));" << endl; + } + + os << "}" << endl; + cout << "Wrote configuration options list to " << argv[argc - 1] << "." << endl; return 0; }
--- a/src/actions.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/actions.cc Wed Aug 06 16:18:24 2014 +0300 @@ -78,18 +78,18 @@ QString const license = ui.caLicense->isChecked() ? CALicenseText : ""; LDObjectList objs; - objs << spawn<LDComment> (ui.le_title->text()); - objs << spawn<LDComment> ("Name: <untitled>.dat"); - objs << spawn<LDComment> (format ("Author: %1", ui.le_author->text())); - objs << spawn<LDComment> (format ("!LDRAW_ORG Unofficial_Part")); + objs << LDSpawn<LDComment> (ui.le_title->text()); + objs << LDSpawn<LDComment> ("Name: <untitled>.dat"); + objs << LDSpawn<LDComment> (format ("Author: %1", ui.le_author->text())); + objs << LDSpawn<LDComment> (format ("!LDRAW_ORG Unofficial_Part")); if (not license.isEmpty()) - objs << spawn<LDComment> (license); + objs << LDSpawn<LDComment> (license); - objs << spawn<LDEmpty>(); - objs << spawn<LDBFC> (bfctype); - objs << spawn<LDEmpty>(); - getCurrentDocument()->addObjects (objs); + objs << LDSpawn<LDEmpty>(); + objs << LDSpawn<LDBFC> (bfctype); + objs << LDSpawn<LDEmpty>(); + CurrentDocument()->addObjects (objs); doFullRefresh(); } @@ -109,21 +109,21 @@ if (name.isEmpty()) return; - openMainFile (name); + OpenMainModel (name); } // ============================================================================= // void MainWindow::slot_actionSave() { - save (getCurrentDocument(), false); + save (CurrentDocument(), false); } // ============================================================================= // void MainWindow::slot_actionSaveAs() { - save (getCurrentDocument(), true); + save (CurrentDocument(), true); } // ============================================================================= @@ -138,20 +138,20 @@ // void MainWindow::slot_actionClose() { - if (not getCurrentDocument()->isSafeToClose()) + if (not CurrentDocument()->isSafeToClose()) return; - getCurrentDocument()->dismiss(); + CurrentDocument()->dismiss(); } // ============================================================================= // void MainWindow::slot_actionCloseAll() { - if (not safeToCloseAll()) + if (not IsSafeToCloseAll()) return; - closeAll(); + CloseAllDocuments(); } // ============================================================================= @@ -235,10 +235,10 @@ // void MainWindow::slot_actionEdit() { - if (selection().size() != 1) + if (Selection().size() != 1) return; - LDObjectPtr obj = selection() [0]; + LDObjectPtr obj = Selection() [0]; AddObjectDialog::staticDialog (obj->type(), obj); } @@ -266,7 +266,7 @@ // void MainWindow::slot_actionSelectAll() { - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) obj->select(); ui->objectList->selectAll(); @@ -277,21 +277,21 @@ // void MainWindow::slot_actionSelectByColor() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return; QList<LDColor> colors; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (obj->isColored()) colors << obj->color(); } - removeDuplicates (colors); - getCurrentDocument()->clearSelection(); + RemoveDuplicates (colors); + CurrentDocument()->clearSelection(); - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (colors.contains (obj->color())) obj->select(); @@ -305,13 +305,13 @@ // void MainWindow::slot_actionSelectByType() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return; QList<LDObjectType> types; QStringList subfilenames; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { types << obj->type(); @@ -319,11 +319,11 @@ subfilenames << obj.staticCast<LDSubfile>()->fileInfo()->name(); } - removeDuplicates (types); - removeDuplicates (subfilenames); - getCurrentDocument()->clearSelection(); + RemoveDuplicates (types); + RemoveDuplicates (subfilenames); + CurrentDocument()->clearSelection(); - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { LDObjectType type = obj->type(); @@ -383,17 +383,17 @@ if (not f.open (QIODevice::ReadOnly)) { - critical (format ("Couldn't open %1 (%2)", fname, f.errorString())); + CriticalError (format ("Couldn't open %1 (%2)", fname, f.errorString())); return; } - LDObjectList objs = loadFileContents (&f, null); + LDObjectList objs = LoadFileContents (&f, null); - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); for (LDObjectPtr obj : objs) { - getCurrentDocument()->insertObj (idx, obj); + CurrentDocument()->insertObj (idx, obj); obj->select(); R()->compileObject (obj); @@ -408,7 +408,7 @@ // void MainWindow::slot_actionExportTo() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return; QString fname = QFileDialog::getSaveFileName(); @@ -420,11 +420,11 @@ if (not file.open (QIODevice::WriteOnly | QIODevice::Text)) { - critical (format ("Unable to open %1 for writing (%2)", fname, file.errorString())); + CriticalError (format ("Unable to open %1 for writing (%2)", fname, file.errorString())); return; } - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { QString contents = obj->asText(); QByteArray data = contents.toUtf8(); @@ -454,13 +454,13 @@ if (dlg->exec() == QDialog::Rejected) return; - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); for (QString line : QString (te_edit->toPlainText()).split ("\n")) { - LDObjectPtr obj = parseLine (line); + LDObjectPtr obj = ParseLine (line); - getCurrentDocument()->insertObj (idx, obj); + CurrentDocument()->insertObj (idx, obj); obj->select(); idx++; } @@ -477,9 +477,9 @@ int w, h; uchar* imgdata = R()->getScreencap (w, h); - QImage img = imageFromScreencap (imgdata, w, h); + QImage img = GetImageFromScreencap (imgdata, w, h); - QString root = basename (getCurrentDocument()->name()); + QString root = Basename (CurrentDocument()->name()); if (root.right (4) == ".dat") root.chop (4); @@ -489,7 +489,7 @@ "PNG images (*.png);;JPG images (*.jpg);;BMP images (*.bmp);;All Files (*.*)"); if (not fname.isEmpty() and not img.save (fname)) - critical (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); + CriticalError (format ("Couldn't open %1 for writing to save screencap: %2", fname, strerror (errno))); delete[] imgdata; } @@ -507,7 +507,7 @@ // void MainWindow::slot_actionVisibilityToggle() { - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->setHidden (not obj->isHidden()); refresh(); @@ -517,7 +517,7 @@ // void MainWindow::slot_actionVisibilityHide() { - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->setHidden (true); refresh(); @@ -527,7 +527,7 @@ // void MainWindow::slot_actionVisibilityReveal() { - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->setHidden (false); refresh(); } @@ -696,16 +696,16 @@ int defval = 0; LDObjectPtr obj; - if (selection().size() == 1) - defval = selection()[0]->lineNumber(); + if (Selection().size() == 1) + defval = Selection()[0]->lineNumber(); int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, - 1, getCurrentDocument()->getObjectCount(), 1, &ok); + 1, CurrentDocument()->getObjectCount(), 1, &ok); - if (not ok or (obj = getCurrentDocument()->getObject (idx - 1)) == null) + if (not ok or (obj = CurrentDocument()->getObject (idx - 1)) == null) return; - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); obj->select(); updateSelection(); } @@ -714,22 +714,22 @@ // void MainWindow::slot_actionSubfileSelection() { - if (selection().size() == 0) + if (Selection().size() == 0) return; - QString parentpath (getCurrentDocument()->fullPath()); + QString parentpath (CurrentDocument()->fullPath()); // BFC type of the new subfile - it shall inherit the BFC type of the parent document BFCStatement bfctype (BFCStatement::NoCertify); // Dirname of the new subfile - QString subdirname (dirname (parentpath)); + QString subdirname (Dirname (parentpath)); // Title of the new subfile QString subtitle; // Comment containing the title of the parent document - LDCommentPtr titleobj (getCurrentDocument()->getObject (0).dynamicCast<LDComment>()); + LDCommentPtr titleobj (CurrentDocument()->getObject (0).dynamicCast<LDComment>()); // License text for the subfile QString license (PreferredLicenseText()); @@ -741,7 +741,7 @@ QString fullsubname; // Where to insert the subfile reference? - int refidx (selection()[0]->lineNumber()); + int refidx (Selection()[0]->lineNumber()); // Determine title of subfile if (titleobj != null) @@ -755,7 +755,7 @@ // If this the parent document isn't already in s/, we need to stuff it into // a subdirectory named s/. Ensure it exists! - QString topdirname = basename (dirname (getCurrentDocument()->fullPath())); + QString topdirname = Basename (Dirname (CurrentDocument()->fullPath())); if (topdirname != "s") { @@ -764,7 +764,7 @@ QString text = format (tr ("The directory <b>%1</b> is suggested for " "subfiles. This directory does not exist, create it?"), desiredPath); - if (QDir (desiredPath).exists() or confirm (title, text)) + if (QDir (desiredPath).exists() or Confirm (title, text)) { subdirname = desiredPath; QDir().mkpath (subdirname); @@ -801,15 +801,15 @@ if (digits.length() == 1) digits.prepend ("0"); - fullsubname = subdirname + "/" + basename (parentpath) + "s" + digits + ".dat"; - } while (findDocument ("s\\" + basename (fullsubname)) != null or QFile (fullsubname).exists()); + fullsubname = subdirname + "/" + Basename (parentpath) + "s" + digits + ".dat"; + } while (FindDocument ("s\\" + Basename (fullsubname)) != null or QFile (fullsubname).exists()); } // Determine the BFC winding type used in the main document - it is to // be carried over to the subfile. - LDIterate<LDBFC> (getCurrentDocument()->objects(), [&] (LDBFCPtr const& bfc) + LDIterate<LDBFC> (CurrentDocument()->objects(), [&] (LDBFCPtr const& bfc) { - if (eq (bfc->statement(), BFCStatement::CertifyCCW, BFCStatement::CertifyCW, + if (Eq (bfc->statement(), BFCStatement::CertifyCCW, BFCStatement::CertifyCW, BFCStatement::NoCertify)) { bfctype = bfc->statement(); @@ -818,7 +818,7 @@ }); // Get the body of the document in LDraw code - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) code << obj->asText(); // Create the new subfile document @@ -828,24 +828,24 @@ doc->setName (LDDocument::shortenName (fullsubname)); LDObjectList objs; - objs << spawn<LDComment> (subtitle); - objs << spawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved - objs << spawn<LDComment> (format ("Author: %1 [%2]", cfg::DefaultName, cfg::DefaultUser)); - objs << spawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); + objs << LDSpawn<LDComment> (subtitle); + objs << LDSpawn<LDComment> ("Name: "); // This gets filled in when the subfile is saved + objs << LDSpawn<LDComment> (format ("Author: %1 [%2]", cfg::DefaultName, cfg::DefaultUser)); + objs << LDSpawn<LDComment> ("!LDRAW_ORG Unofficial_Subpart"); if (not license.isEmpty()) - objs << spawn<LDComment> (license); + objs << LDSpawn<LDComment> (license); - objs << spawn<LDEmpty>(); - objs << spawn<LDBFC> (bfctype); - objs << spawn<LDEmpty>(); + objs << LDSpawn<LDEmpty>(); + objs << LDSpawn<LDBFC> (bfctype); + objs << LDSpawn<LDEmpty>(); doc->addObjects (objs); // Add the actual subfile code to the new document for (QString line : code) { - LDObjectPtr obj = parseLine (line); + LDObjectPtr obj = ParseLine (line); doc->addObject (obj); } @@ -854,16 +854,16 @@ { // Save was successful. Delete the original selection now from the // main document. - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->destroy(); // Add a reference to the new subfile to where the selection was - LDSubfilePtr ref (spawn<LDSubfile>()); - ref->setColor (maincolor()); + LDSubfilePtr ref (LDSpawn<LDSubfile>()); + ref->setColor (MainColor()); ref->setFileInfo (doc); - ref->setPosition (g_origin); - ref->setTransform (g_identity); - getCurrentDocument()->insertObj (refidx, ref); + ref->setPosition (Origin); + ref->setTransform (IdentityMatrix); + CurrentDocument()->insertObj (refidx, ref); // Refresh stuff updateDocumentList(); @@ -889,7 +889,7 @@ void MainWindow::slot_actionOpenSubfiles() { - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { LDSubfilePtr ref = obj.dynamicCast<LDSubfile>();
--- a/src/actionsEdit.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/actionsEdit.cc Wed Aug 06 16:18:24 2014 +0300 @@ -44,9 +44,9 @@ // ============================================================================= // -static int copyToClipboard() +static int CopyToClipboard() { - LDObjectList objs = selection(); + LDObjectList objs = Selection(); int num = 0; // Clear the clipboard first. @@ -72,7 +72,7 @@ // void MainWindow::slot_actionCut() { - int num = copyToClipboard(); + int num = CopyToClipboard(); deleteSelection(); print (tr ("%1 objects cut"), num); } @@ -81,7 +81,7 @@ // void MainWindow::slot_actionCopy() { - int num = copyToClipboard(); + int num = CopyToClipboard(); print (tr ("%1 objects copied"), num); } @@ -91,13 +91,13 @@ { const QString clipboardText = qApp->clipboard()->text(); int idx = getInsertionPoint(); - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); int num = 0; for (QString line : clipboardText.split ("\n")) { - LDObjectPtr pasted = parseLine (line); - getCurrentDocument()->insertObj (idx++, pasted); + LDObjectPtr pasted = ParseLine (line); + CurrentDocument()->insertObj (idx++, pasted); pasted->select(); ++num; } @@ -117,11 +117,11 @@ // ============================================================================= // -static void doInline (bool deep) +static void DoInline (bool deep) { - LDObjectList sel = selection(); + LDObjectList sel = Selection(); - LDIterate<LDSubfile> (selection(), [&](LDSubfilePtr const& ref) + LDIterate<LDSubfile> (Selection(), [&](LDSubfilePtr const& ref) { // Get the index of the subfile so we know where to insert the // inlined contents. @@ -135,8 +135,8 @@ { QString line = inlineobj->asText(); inlineobj->destroy(); - LDObjectPtr newobj = parseLine (line); - getCurrentDocument()->insertObj (idx++, newobj); + LDObjectPtr newobj = ParseLine (line); + CurrentDocument()->insertObj (idx++, newobj); newobj->select(); } @@ -149,12 +149,12 @@ void MainWindow::slot_actionInline() { - doInline (false); + DoInline (false); } void MainWindow::slot_actionInlineDeep() { - doInline (true); + DoInline (true); } // ============================================================================= @@ -163,7 +163,7 @@ { int num = 0; - LDIterate<LDQuad> (selection(), [&](LDQuadPtr const& quad) + LDIterate<LDQuad> (Selection(), [&](LDQuadPtr const& quad) { // Find the index of this quad long index = quad->lineNumber(); @@ -175,8 +175,8 @@ // Replace the quad with the first triangle and add the second triangle // after the first one. - getCurrentDocument()->setObject (index, triangles[0]); - getCurrentDocument()->insertObj (index + 1, triangles[1]); + CurrentDocument()->setObject (index, triangles[0]); + CurrentDocument()->insertObj (index + 1, triangles[1]); num++; }); @@ -188,10 +188,10 @@ // void MainWindow::slot_actionEditRaw() { - if (selection().size() != 1) + if (Selection().size() != 1) return; - LDObjectPtr obj = selection()[0]; + LDObjectPtr obj = Selection()[0]; QDialog* dlg = new QDialog; Ui::EditRawUI ui; @@ -210,7 +210,7 @@ return; // Reinterpret it from the text of the input field - LDObjectPtr newobj = parseLine (ui.code->text()); + LDObjectPtr newobj = ParseLine (ui.code->text()); obj->replace (newobj); refresh(); } @@ -219,10 +219,10 @@ // void MainWindow::slot_actionSetColor() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return; - LDObjectList objs = selection(); + LDObjectList objs = Selection(); // If all selected objects have the same color, said color is our default // value to the color selection dialog. @@ -246,7 +246,7 @@ // void MainWindow::slot_actionBorders() { - LDObjectList objs = selection(); + LDObjectList objs = Selection(); int num = 0; for (LDObjectPtr obj : objs) @@ -261,17 +261,17 @@ if (type == OBJ_Quad) { LDQuadPtr quad = obj.staticCast<LDQuad>(); - lines[0] = spawn<LDLine> (quad->vertex (0), quad->vertex (1)); - lines[1] = spawn<LDLine> (quad->vertex (1), quad->vertex (2)); - lines[2] = spawn<LDLine> (quad->vertex (2), quad->vertex (3)); - lines[3] = spawn<LDLine> (quad->vertex (3), quad->vertex (0)); + lines[0] = LDSpawn<LDLine> (quad->vertex (0), quad->vertex (1)); + lines[1] = LDSpawn<LDLine> (quad->vertex (1), quad->vertex (2)); + lines[2] = LDSpawn<LDLine> (quad->vertex (2), quad->vertex (3)); + lines[3] = LDSpawn<LDLine> (quad->vertex (3), quad->vertex (0)); } else { LDTrianglePtr tri = obj.staticCast<LDTriangle>(); - lines[0] = spawn<LDLine> (tri->vertex (0), tri->vertex (1)); - lines[1] = spawn<LDLine> (tri->vertex (1), tri->vertex (2)); - lines[2] = spawn<LDLine> (tri->vertex (2), tri->vertex (0)); + lines[0] = LDSpawn<LDLine> (tri->vertex (0), tri->vertex (1)); + lines[1] = LDSpawn<LDLine> (tri->vertex (1), tri->vertex (2)); + lines[2] = LDSpawn<LDLine> (tri->vertex (2), tri->vertex (0)); } for (int i = 0; i < countof (lines); ++i) @@ -280,7 +280,7 @@ continue; long idx = obj->lineNumber() + i + 1; - getCurrentDocument()->insertObj (idx, lines[i]); + CurrentDocument()->insertObj (idx, lines[i]); } num += countof (lines); @@ -296,7 +296,7 @@ { int num = 0; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (obj->numVertices() < 2) continue; @@ -305,10 +305,10 @@ for (int i = 0; i < obj->numVertices(); ++i) { - QSharedPointer<LDVertex> vert (spawn<LDVertex>()); + QSharedPointer<LDVertex> vert (LDSpawn<LDVertex>()); vert->pos = obj->vertex (i); vert->setColor (obj->color()); - getCurrentDocument()->insertObj (++ln, vert); + CurrentDocument()->insertObj (++ln, vert); ++num; } } @@ -319,9 +319,9 @@ // ============================================================================= // -static void doMoveSelection (const bool up) +static void MoveSelection (const bool up) { - LDObjectList objs = selection(); + LDObjectList objs = Selection(); LDObject::moveObjects (objs, up); g_win->buildObjList(); } @@ -330,34 +330,34 @@ // void MainWindow::slot_actionMoveUp() { - doMoveSelection (true); + MoveSelection (true); } void MainWindow::slot_actionMoveDown() { - doMoveSelection (false); + MoveSelection (false); } // ============================================================================= // void MainWindow::slot_actionUndo() { - getCurrentDocument()->undo(); + CurrentDocument()->undo(); } void MainWindow::slot_actionRedo() { - getCurrentDocument()->redo(); + CurrentDocument()->redo(); } // ============================================================================= // -void doMoveObjects (Vertex vect) +static void MoveObjects (Vertex vect) { // Apply the grid values vect *= *CurrentGrid().coordinateSnap; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->move (vect); g_win->refresh(); @@ -367,39 +367,39 @@ // void MainWindow::slot_actionMoveXNeg() { - doMoveObjects ({-1, 0, 0}); + MoveObjects ({-1, 0, 0}); } void MainWindow::slot_actionMoveYNeg() { - doMoveObjects ({0, -1, 0}); + MoveObjects ({0, -1, 0}); } void MainWindow::slot_actionMoveZNeg() { - doMoveObjects ({0, 0, -1}); + MoveObjects ({0, 0, -1}); } void MainWindow::slot_actionMoveXPos() { - doMoveObjects ({1, 0, 0}); + MoveObjects ({1, 0, 0}); } void MainWindow::slot_actionMoveYPos() { - doMoveObjects ({0, 1, 0}); + MoveObjects ({0, 1, 0}); } void MainWindow::slot_actionMoveZPos() { - doMoveObjects ({0, 0, 1}); + MoveObjects ({0, 0, 1}); } // ============================================================================= // void MainWindow::slot_actionInvert() { - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) obj->invert(); refresh(); @@ -407,21 +407,21 @@ // ============================================================================= // -static void rotateVertex (Vertex& v, const Vertex& rotpoint, const Matrix& transformer) +static void RotateVertex (Vertex& v, const Vertex& rotpoint, const Matrix& transformer) { v -= rotpoint; - v.transform (transformer, g_origin); + v.transform (transformer, Origin); v += rotpoint; } // ============================================================================= // -static void doRotate (const int l, const int m, const int n) +static void RotateObjects (const int l, const int m, const int n) { - LDObjectList sel = selection(); + LDObjectList sel = Selection(); QList<Vertex*> queue; const Vertex rotpoint = GetRotationPoint (sel); - const double angle = (pi * *CurrentGrid().angleSnap) / 180, + const double angle = (Pi * *CurrentGrid().angleSnap) / 180, cosangle = cos (angle), sinangle = sin (angle); @@ -449,7 +449,7 @@ for (int i = 0; i < obj->numVertices(); ++i) { Vertex v = obj->vertex (i); - rotateVertex (v, rotpoint, transform); + RotateVertex (v, rotpoint, transform); obj->setVertex (i, v); } } @@ -459,7 +459,7 @@ // Transform the position Vertex v = mo->position(); - rotateVertex (v, rotpoint, transform); + RotateVertex (v, rotpoint, transform); mo->setPosition (v); // Transform the matrix @@ -469,7 +469,7 @@ { LDVertexPtr vert = obj.staticCast<LDVertex>(); Vertex v = vert->pos; - rotateVertex (v, rotpoint, transform); + RotateVertex (v, rotpoint, transform); vert->pos = v; } } @@ -481,27 +481,27 @@ // void MainWindow::slot_actionRotateXPos() { - doRotate (1, 0, 0); + RotateObjects (1, 0, 0); } void MainWindow::slot_actionRotateYPos() { - doRotate (0, 1, 0); + RotateObjects (0, 1, 0); } void MainWindow::slot_actionRotateZPos() { - doRotate (0, 0, 1); + RotateObjects (0, 0, 1); } void MainWindow::slot_actionRotateXNeg() { - doRotate (-1, 0, 0); + RotateObjects (-1, 0, 0); } void MainWindow::slot_actionRotateYNeg() { - doRotate (0, -1, 0); + RotateObjects (0, -1, 0); } void MainWindow::slot_actionRotateZNeg() { - doRotate (0, 0, -1); + RotateObjects (0, 0, -1); } void MainWindow::slot_actionRotationPoint() @@ -516,7 +516,7 @@ setlocale (LC_ALL, "C"); int num = 0; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { LDMatrixObjectPtr mo = obj.dynamicCast<LDMatrixObject>(); @@ -527,7 +527,7 @@ // Note: matrix values are to be rounded to 4 decimals. v.apply ([](Axis, double& a) { RoundToDecimals (a, cfg::RoundPosition); }); - applyToMatrix (t, [](int, double& a) { RoundToDecimals (a, cfg::RoundMatrix); }); + ApplyToMatrix (t, [](int, double& a) { RoundToDecimals (a, cfg::RoundMatrix); }); mo->setPosition (v); mo->setTransform (t); @@ -556,7 +556,7 @@ { int num = 0; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (not obj->isColored()) continue; @@ -592,7 +592,7 @@ if (ui.y->isChecked()) sel << Y; if (ui.z->isChecked()) sel << Z; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { for (int i = 0; i < obj->numVertices(); ++i) { @@ -638,7 +638,7 @@ if (ui.y->isChecked()) sel << Y; if (ui.z->isChecked()) sel << Z; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { for (int i = 0; i < obj->numVertices(); ++i) { @@ -663,7 +663,7 @@ { int num = 0; - LDIterate<LDCondLine> (selection(), [&](LDCondLinePtr const& cnd) + LDIterate<LDCondLine> (Selection(), [&](LDCondLinePtr const& cnd) { cnd->toEdgeLine(); ++num; @@ -675,9 +675,9 @@ // ============================================================================= // -static bool isColorUsed (LDColor color) +static bool IsColorUsed (LDColor color) { - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (obj->isColored() and obj->color() == color) return true; @@ -694,18 +694,18 @@ LDColor color; for (colnum = 0; - colnum < numLDConfigColors() and + colnum < CountLDConfigColors() and ((color = LDColor::fromIndex (colnum)) == null or - isColorUsed (color)); + IsColorUsed (color)); colnum++) {} - if (colnum >= numLDConfigColors()) + if (colnum >= CountLDConfigColors()) { print (tr ("Cannot auto-color: all colors are in use!")); return; } - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (not obj->isColored()) continue; @@ -741,10 +741,10 @@ ui->m_username->text(), ui->m_comment->text()); - LDCommentPtr comm (spawn<LDComment> (commentText)); + LDCommentPtr comm (LDSpawn<LDComment> (commentText)); // Find a spot to place the new comment - for (obj = getCurrentDocument()->getObject (0); + for (obj = CurrentDocument()->getObject (0); obj != null and obj->next() != null and not obj->next()->isScemantic(); obj = obj->next()) { @@ -764,12 +764,12 @@ } int idx = obj ? obj->lineNumber() : 0; - getCurrentDocument()->insertObj (idx++, comm); + CurrentDocument()->insertObj (idx++, comm); // If we're adding a history line right before a scemantic object, pad it // an empty line if (obj and obj->next() and obj->next()->isScemantic()) - getCurrentDocument()->insertObj (idx, LDEmptyPtr (spawn<LDEmpty>())); + CurrentDocument()->insertObj (idx, LDEmptyPtr (LDSpawn<LDEmpty>())); buildObjList(); delete ui; @@ -786,9 +786,9 @@ cfg::SplitLinesSegments = segments; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { - if (not eq (obj->type(), OBJ_Line, OBJ_CondLine)) + if (not Eq (obj->type(), OBJ_Line, OBJ_CondLine)) continue; QVector<LDObjectPtr> newsegs; @@ -811,9 +811,9 @@ }); if (obj->type() == OBJ_Line) - segment = spawn<LDLine> (v0, v1); + segment = LDSpawn<LDLine> (v0, v1); else - segment = spawn<LDCondLine> (v0, v1, obj->vertex (2), obj->vertex (3)); + segment = LDSpawn<LDCondLine> (v0, v1, obj->vertex (2), obj->vertex (3)); newsegs << segment; } @@ -821,7 +821,7 @@ int ln = obj->lineNumber(); for (LDObjectPtr seg : newsegs) - getCurrentDocument()->insertObj (ln++, seg); + CurrentDocument()->insertObj (ln++, seg); obj->destroy(); }
--- a/src/addObjectDialog.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/addObjectDialog.cc Wed Aug 06 16:18:24 2014 +0300 @@ -100,7 +100,7 @@ coordCount = 3; tw_subfileList = new QTreeWidget(); tw_subfileList->setHeaderLabel (tr ("Primitives")); - populatePrimitives (tw_subfileList, (obj != null ? obj.staticCast<LDSubfile>()->fileInfo()->name() : "")); + PopulatePrimitives (tw_subfileList, (obj != null ? obj.staticCast<LDSubfile>()->fileInfo()->name() : "")); connect (tw_subfileList, SIGNAL (itemSelectionChanged()), this, SLOT (slot_subfileTypeChanged())); lb_subfileName = new QLabel ("File:"); @@ -116,11 +116,11 @@ default: { - critical (format ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, typeName)); + CriticalError (format ("Unhandled LDObject type %1 (%2) in AddObjectDialog", (int) type, typeName)); } return; } - QPixmap icon = getIcon (format ("add-%1", typeName)); + QPixmap icon = GetIcon (format ("add-%1", typeName)); LDObjectPtr defaults = LDObject::getDefault (type); lb_typeIcon = new QLabel; @@ -130,12 +130,12 @@ if (defaults->isColored()) { if (obj != null) - _color = obj->color(); + m_color = obj->color(); else - _color = (type == OBJ_CondLine or type == OBJ_Line) ? edgecolor() : maincolor(); + m_color = (type == OBJ_CondLine or type == OBJ_Line) ? EdgeColor() : MainColor(); pb_color = new QPushButton; - setButtonBackground (pb_color, _color); + setButtonBackground (pb_color, m_color); connect (pb_color, SIGNAL (clicked()), this, SLOT (slot_colorButtonClicked())); } @@ -193,7 +193,7 @@ QLabel* lb_matrix = new QLabel ("Matrix:"); le_matrix = new QLineEdit; // le_matrix->setValidator (new QDoubleValidator); - Matrix defaultMatrix = g_identity; + Matrix defaultMatrix = IdentityMatrix; if (mo != null) { @@ -236,7 +236,7 @@ // ============================================================================= void AddObjectDialog::setButtonBackground (QPushButton* button, LDColor color) { - button->setIcon (getIcon ("palette")); + button->setIcon (GetIcon ("palette")); button->setAutoFillBackground (true); if (color != null) @@ -259,8 +259,8 @@ // ============================================================================= void AddObjectDialog::slot_colorButtonClicked() { - ColorSelector::selectColor (_color, _color, this); - setButtonBackground (pb_color, _color); + ColorSelector::selectColor (m_color, m_color, this); + setButtonBackground (pb_color, m_color); } // ============================================================================= @@ -276,10 +276,10 @@ // ============================================================================= // ============================================================================= template<typename T> -static QSharedPointer<T> initObj (LDObjectPtr& obj) +static QSharedPointer<T> InitObject (LDObjectPtr& obj) { if (obj == null) - obj = spawn<T>(); + obj = LDSpawn<T>(); return obj.staticCast<T>(); } @@ -298,7 +298,7 @@ return; // Nothing to edit with empties const bool newObject = (obj == null); - Matrix transform = g_identity; + Matrix transform = IdentityMatrix; AddObjectDialog dlg (type, obj); assert (obj == null or obj->type() == type); @@ -326,7 +326,7 @@ { case OBJ_Comment: { - LDCommentPtr comm = initObj<LDComment> (obj); + LDCommentPtr comm = InitObject<LDComment> (obj); comm->setText (dlg.le_comment->text()); } break; @@ -354,14 +354,14 @@ case OBJ_BFC: { - LDBFCPtr bfc = initObj<LDBFC> (obj); + LDBFCPtr bfc = InitObject<LDBFC> (obj); assert (within (dlg.rb_bfcType->value(), 0, int (BFCStatement::NumValues) - 1)); bfc->setStatement (BFCStatement (dlg.rb_bfcType->value())); } break; case OBJ_Vertex: { - LDVertexPtr vert = initObj<LDVertex> (obj); + LDVertexPtr vert = InitObject<LDVertex> (obj); vert->pos.apply ([&](Axis ax, double& value) { value = dlg.dsb_coords[ax]->value(); }); } break; @@ -373,15 +373,15 @@ if (name.length() == 0) return; // no subfile filename - LDDocumentPtr file = getDocument (name); + LDDocumentPtr file = GetDocument (name); if (not file) { - critical (format ("Couldn't open `%1': %2", name, strerror (errno))); + CriticalError (format ("Couldn't open `%1': %2", name, strerror (errno))); return; } - LDSubfilePtr ref = initObj<LDSubfile> (obj); + LDSubfilePtr ref = InitObject<LDSubfile> (obj); assert (ref); for_axes (ax) @@ -396,12 +396,12 @@ } if (obj->isColored()) - obj->setColor (dlg._color); + obj->setColor (dlg.m_color); if (newObject) { int idx = g_win->getInsertionPoint(); - getCurrentDocument()->insertObj (idx, obj); + CurrentDocument()->insertObj (idx, obj); } g_win->refresh();
--- a/src/addObjectDialog.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/addObjectDialog.h Wed Aug 06 16:18:24 2014 +0300 @@ -61,7 +61,7 @@ void setButtonBackground (QPushButton* button, LDColor color); QString currentSubfileName(); - LDColor _color; + LDColor m_color; private slots: void slot_colorButtonClicked();
--- a/src/basics.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/basics.cc Wed Aug 06 16:18:24 2014 +0300 @@ -224,10 +224,10 @@ { reset(); - if (getCurrentDocument() == null) + if (CurrentDocument() == null) return; - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) calcObject (obj); } @@ -284,12 +284,12 @@ // void LDBoundingBox::calcVertex (const Vertex& vertex) { - m_vertex0.setX (min (vertex.x(), m_vertex0.x())); - m_vertex0.setY (min (vertex.y(), m_vertex0.y())); - m_vertex0.setZ (min (vertex.z(), m_vertex0.z())); - m_vertex1.setX (max (vertex.x(), m_vertex1.x())); - m_vertex1.setY (max (vertex.y(), m_vertex1.y())); - m_vertex1.setZ (max (vertex.z(), m_vertex1.z())); + m_vertex0.setX (Min (vertex.x(), m_vertex0.x())); + m_vertex0.setY (Min (vertex.y(), m_vertex0.y())); + m_vertex0.setZ (Min (vertex.z(), m_vertex0.z())); + m_vertex1.setX (Max (vertex.x(), m_vertex1.x())); + m_vertex1.setY (Max (vertex.y(), m_vertex1.y())); + m_vertex1.setZ (Max (vertex.z(), m_vertex1.z())); setEmpty (false); } @@ -319,8 +319,8 @@ elif (yscale > zscale) size = yscale; - if (abs (size) >= 2.0) - return abs (size / 2); + if (Abs (size) >= 2.0) + return Abs (size / 2); return 1.0; }
--- a/src/basics.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/basics.h Wed Aug 06 16:18:24 2014 +0300 @@ -195,68 +195,75 @@ LDBoundingBox& operator<< (const Vertex& v); }; -extern const Vertex g_origin; // Vertex at (0, 0, 0) -extern const Matrix g_identity; // Identity matrix +extern const Vertex Origin; +extern const Matrix IdentityMatrix; -static const double pi = 3.14159265358979323846; +static const double Pi = 3.14159265358979323846; // ============================================================================= // Plural expression -template<class T> static inline const char* plural (T n) +template<typename T> +static inline const char* Plural (T n) { return (n != 1) ? "s" : ""; } // ============================================================================= // Templated clamp -template<class T> static inline T clamp (T a, T min, T max) +template<typename T> +static inline T Clamp (T a, T min, T max) { return (a > max) ? max : (a < min) ? min : a; } // Templated minimum -template<class T> static inline T min (T a, T b) +template<typename T> +static inline T Min (T a, T b) { return (a < b) ? a : b; } // Templated maximum -template<class T> static inline T max (T a, T b) +template<typename T> +static inline T Max (T a, T b) { return (a > b) ? a : b; } // Templated absolute value -template<class T> static inline T abs (T a) +template<typename T> +static inline T Abs (T a) { return (a >= 0) ? a : -a; } -template<class T> inline bool isZero (T a) +template<typename T> +inline bool IsZero (T a) { - return abs<T> (a) < 0.0001; -} - -template<class T> inline bool isInteger (T a) -{ - return isZero (a - (int) a); + return Abs<T> (a) < 0.0001; } template<typename T> -inline bool within (T a, T b, T c) +inline bool IsIntegral (T a) +{ + return IsZero (a - int (a)); +} + +template<typename T> +inline bool IsWithin (T a, T b, T c) { return a >= b and a <= c; } template<typename T> -void removeDuplicates (T& a) +void RemoveDuplicates (T& a) { std::sort (a.begin(), a.end()); a.erase (std::unique (a.begin(), a.end()), a.end()); } -inline QString utf16 (const char16_t* a) +inline QString UTF16 (const char16_t* a) { if (Q_LIKELY (sizeof(char16_t) == sizeof(unsigned short))) return QString::fromUtf16 (reinterpret_cast<const unsigned short*> (a)); @@ -274,16 +281,16 @@ // Returns true if first arg is equal to any of the other args // template<typename T, typename Arg, typename... Args> -bool eq (T const& a, Arg const& arg, Args const&... args) +bool Eq (T const& a, Arg const& arg, Args const&... args) { if (a == arg) return true; - return eq (a, args...); + return Eq (a, args...); } template<typename T> -bool eq (T const&) +bool Eq (T const&) { return false; }
--- a/src/colorSelector.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/colorSelector.cc Wed Aug 06 16:18:24 2014 +0300 @@ -51,7 +51,7 @@ setSelection (defval); // not really an icon but eh - m_scene->setBackgroundBrush (getIcon ("checkerboard")); + m_scene->setBackgroundBrush (GetIcon ("checkerboard")); drawScene(); int width = viewportWidth(); @@ -93,7 +93,7 @@ // Draw the color rectangles. m_scene->clear(); - for (int i = 0; i < numLDConfigColors(); ++i) + for (int i = 0; i < CountLDConfigColors(); ++i) { LDColor info = LDColor::fromIndex (i); @@ -106,7 +106,7 @@ QColor col (info.faceColor()); - if (i == mainColorIndex) + if (i == MainColorIndex) { // Use the user preferences for main color here col = QColor (cfg::MainColor); @@ -116,12 +116,12 @@ QPen pen (info.edgeColor(), penWidth, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin); m_scene->addRect (x, y, w, w, pen, col); QGraphicsTextItem* numtext = m_scene->addText (format ("%1", i)); - numtext->setDefaultTextColor ((luma (col) < 80) ? Qt::white : Qt::black); + numtext->setDefaultTextColor ((Luma (col) < 80) ? Qt::white : Qt::black); numtext->setPos (x, y); if (selection() and i == selection().index()) { - auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); + auto curspic = m_scene->addPixmap (GetIcon ("colorcursor")); curspic->setPos (x, y); } } @@ -131,7 +131,7 @@ // int ColorSelector::numRows() const { - return (numLDConfigColors() / g_numColumns); + return (CountLDConfigColors() / g_numColumns); } // ============================================================================= @@ -155,7 +155,7 @@ ui->colorLabel->setText (format ("%1 - %2", selection().indexString(), (selection().isDirect() ? "<direct color>" : selection().name()))); - ui->iconLabel->setPixmap (makeColorIcon (selection(), 16).pixmap (16, 16)); + ui->iconLabel->setPixmap (MakeColorIcon (selection(), 16).pixmap (16, 16)); #ifdef TRANSPARENT_DIRECT_COLORS ui->transparentDirectColor->setEnabled (selection().isDirect()); @@ -174,7 +174,7 @@ // currently selected color. We cannot do this in the constructor because the // height is not set properly there. Though don't do this if we selected a // direct color. - if (m_firstResize and selection().index() >= numLDConfigColors()) + if (m_firstResize and selection().index() >= CountLDConfigColors()) { int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; @@ -255,4 +255,4 @@ } return false; -} \ No newline at end of file +}
--- a/src/colors.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/colors.cc Wed Aug 06 16:18:24 2014 +0300 @@ -26,35 +26,35 @@ static LDColor g_LDConfigColors[512]; -void initColors() +void InitColors() { LDColorData* col; print ("Initializing color information.\n"); // Always make sure there's 16 and 24 available. They're special like that. col = new LDColorData; - col->_faceColor = - col->_hexcode = "#AAAAAA"; - col->_edgeColor = Qt::black; + col->m_faceColor = + col->m_hexcode = "#AAAAAA"; + col->m_edgeColor = Qt::black; g_LDConfigColors[16] = col; col = new LDColorData; - col->_faceColor = - col->_edgeColor = - col->_hexcode = "#000000"; + col->m_faceColor = + col->m_edgeColor = + col->m_hexcode = "#000000"; g_LDConfigColors[24] = col; LDConfigParser::parseLDConfig(); } -LDColor maincolor() +LDColor MainColor() { - return g_LDConfigColors[16]; + return g_LDConfigColors[MainColorIndex]; } -LDColor edgecolor() +LDColor EdgeColor() { - return g_LDConfigColors[24]; + return g_LDConfigColors[EdgeColorIndex]; } void LDColor::addLDConfigColor (qint32 index, LDColor color) @@ -80,11 +80,11 @@ col.setAlpha (128); LDColorData* color = new LDColorData; - color->_name = "0x" + QString::number (index, 16).toUpper(); - color->_faceColor = col; - color->_edgeColor = luma(col) < 48 ? Qt::white : Qt::black; - color->_hexcode = col.name(); - color->_index = index; + color->m_name = "0x" + QString::number (index, 16).toUpper(); + color->m_faceColor = col; + color->m_edgeColor = Luma (col) < 48 ? Qt::white : Qt::black; + color->m_hexcode = col.name(); + color->m_index = index; return LDColor (color); } @@ -116,14 +116,14 @@ return true; } -int luma (const QColor& col) +int Luma (const QColor& col) { return (0.2126f * col.red()) + (0.7152f * col.green()) + (0.0722f * col.blue()); } -int numLDConfigColors() +int CountLDConfigColors() { return countof (g_LDConfigColors); }
--- a/src/colors.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/colors.h Wed Aug 06 16:18:24 2014 +0300 @@ -39,17 +39,17 @@ inline DataType* operator->() const = delete; #define SHARED_POINTER_DATA_ACCESS(N) \ - public: inline decltype(DataType::_##N) const& N() const { return data()->_##N; } + public: inline decltype(DataType::m_##N) const& N() const { return data()->m_##N; } class LDColor; struct LDColorData { - QString _name; - QString _hexcode; - QColor _faceColor; - QColor _edgeColor; - qint32 _index; + QString m_name; + QString m_hexcode; + QColor m_faceColor; + QColor m_edgeColor; + qint32 m_index; }; class LDColor : public QSharedPointer<LDColorData> @@ -70,12 +70,16 @@ static LDColor fromIndex (qint32 index); }; -void initColors(); -int luma (const QColor& col); -int numLDConfigColors(); +void InitColors(); +int Luma (const QColor& col); +int CountLDConfigColors(); // Main and edge colors -LDColor maincolor(); -LDColor edgecolor(); -static constexpr int mainColorIndex = 16; -static constexpr int edgeColorIndex = 24; +LDColor MainColor(); +LDColor EdgeColor(); + +enum +{ + MainColorIndex = 16, + EdgeColorIndex = 24, +};
--- a/src/configDialog.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/configDialog.cc Wed Aug 06 16:18:24 2014 +0300 @@ -97,7 +97,7 @@ ui->setupUi (this); // Set defaults - _applyToWidgetOptions ([&](QWidget* wdg, AbstractConfigEntry* conf) + m_applyToWidgetOptions ([&](QWidget* wdg, AbstractConfigEntry* conf) { QVariant value (conf->toVariant()); QLineEdit* le; @@ -145,7 +145,7 @@ ui->shortcutsList->setSortingEnabled (true); ui->shortcutsList->sortItems(); - quickColors = quickColorsFromConfig(); + quickColors = LoadQuickColorList(); updateQuickColorList(); initExtProgs(); selectPage (deftab); @@ -195,7 +195,7 @@ // If the action doesn't have a valid icon, use an empty one // so that the list is kept aligned. if (act->icon().isNull()) - item->setIcon (getIcon ("empty")); + item->setIcon (GetIcon ("empty")); ui->shortcutsList->insertItem (ui->shortcutsList->count(), item); } @@ -215,9 +215,9 @@ QLineEdit* input = new QLineEdit; QPushButton* setPathButton = new QPushButton; - icon->setPixmap (getIcon (info.iconname)); + icon->setPixmap (GetIcon (info.iconname)); input->setText (*info.path); - setPathButton->setIcon (getIcon ("folder")); + setPathButton->setIcon (GetIcon ("folder")); info.input = input; info.setPathButton = setPathButton; @@ -242,7 +242,7 @@ ui->extProgs->setLayout (pathsLayout); } -void ConfigDialog::_applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func) +void ConfigDialog::m_applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func) { // Apply configuration for (QWidget* widget : findChildren<QWidget*>()) @@ -268,7 +268,7 @@ // void ConfigDialog::applySettings() { - _applyToWidgetOptions ([&](QWidget* widget, AbstractConfigEntry* conf) + m_applyToWidgetOptions ([&](QWidget* widget, AbstractConfigEntry* conf) { QVariant value (conf->toVariant()); QLineEdit* le; @@ -289,7 +289,7 @@ elif ((checkbox = qobject_cast<QCheckBox*> (widget)) != null) value = checkbox->isChecked(); elif ((button = qobject_cast<QPushButton*> (widget)) != null) - value = _buttonColors[button]; + value = m_buttonColors[button]; else print ("Unknown widget of type %1\n", widget->metaObject()->className()); @@ -317,8 +317,8 @@ } Config::Save(); - reloadAllSubfiles(); - loadLogoedStuds(); + ReloadAllSubfiles(); + LoadLogoStuds(); g_win->R()->setBackground(); g_win->doFullRefresh(); g_win->updateDocumentList(); @@ -364,7 +364,7 @@ if (entry.isSeparator()) { item->setText ("<hr />"); - item->setIcon (getIcon ("empty")); + item->setIcon (GetIcon ("empty")); } else { @@ -373,12 +373,12 @@ if (col == null) { item->setText ("[[unknown color]]"); - item->setIcon (getIcon ("error")); + item->setIcon (GetIcon ("error")); } else { item->setText (col.name()); - item->setIcon (makeColorIcon (col, 16)); + item->setIcon (MakeColorIcon (col, 16)); } } @@ -504,7 +504,7 @@ return; } - QColor color = QColorDialog::getColor (_buttonColors[button]); + QColor color = QColorDialog::getColor (m_buttonColors[button]); if (color.isValid()) { @@ -519,10 +519,10 @@ // void ConfigDialog::setButtonBackground (QPushButton* button, QString value) { - button->setIcon (getIcon ("colorselect")); + button->setIcon (GetIcon ("colorselect")); button->setAutoFillBackground (true); button->setStyleSheet (format ("background-color: %1", value)); - _buttonColors[button] = QColor (value); + m_buttonColors[button] = QColor (value); } //
--- a/src/configDialog.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/configDialog.h Wed Aug 06 16:18:24 2014 +0300 @@ -61,7 +61,7 @@ private: Ui_ConfigUI* ui; QList<QListWidgetItem*> quickColorItems; - QMap<QPushButton*, QColor> _buttonColors; + QMap<QPushButton*, QColor> m_buttonColors; void applySettings(); void addShortcut (QAction* act); @@ -73,7 +73,7 @@ QListWidgetItem* getSelectedQuickColor(); QList<ShortcutListItem*> getShortcutSelection(); void initExtProgs(); - void _applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func); + void m_applyToWidgetOptions (std::function<void (QWidget*, AbstractConfigEntry*)> func); private slots: void setButtonColor();
--- a/src/configuration.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/configuration.cc Wed Aug 06 16:18:24 2014 +0300 @@ -131,7 +131,7 @@ QString Config::DirectoryPath() { QSettings* settings = SettingsObject(); - QString result = dirname (settings->fileName()); + QString result = Dirname (settings->fileName()); delete settings; return result; }
--- a/src/crashCatcher.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/crashCatcher.cc Wed Aug 06 16:18:24 2014 +0300 @@ -144,7 +144,7 @@ // the signal handler, which will cause the usual bomb box with GDB diagnostics. Said prompt will // embed the assertion failure information. // -void assertionFailure (const char* file, int line, const char* funcname, const char* expr) +void HandleAssertFailure (const char* file, int line, const char* funcname, const char* expr) { #ifdef __unix__ AssertionFailureText = format ("%1:%2: %3: %4", file, line, funcname, expr);
--- a/src/dialogs.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/dialogs.cc Wed Aug 06 16:18:24 2014 +0300 @@ -90,7 +90,7 @@ void OverlayDialog::fillDefaults (int newcam) { LDGLOverlay& info = g_win->R()->getOverlay (newcam); - radioDefault<int> (newcam, m_cameraArgs); + RadioDefault<int> (newcam, m_cameraArgs); if (info.img != null) { @@ -139,7 +139,7 @@ int OverlayDialog::camera() const { - return radioSwitch<int> (ETopCamera, m_cameraArgs); + return RadioSwitch<int> (ETopCamera, m_cameraArgs); } void OverlayDialog::slot_fpath() @@ -173,7 +173,7 @@ else { cancelButton()->setText ("Exit"); - cancelButton()->setIcon (getIcon ("exit")); + cancelButton()->setIcon (GetIcon ("exit")); } okButton()->setEnabled (false); @@ -346,11 +346,11 @@ { Ui::AboutUI ui; ui.setupUi (this); - ui.versionInfo->setText (APPNAME " " + QString (fullVersionString())); + ui.versionInfo->setText (APPNAME " " + QString (FullVersionString())); QPushButton* mailButton = new QPushButton; mailButton->setText (tr ("Contact")); - mailButton->setIcon (getIcon ("mail")); + mailButton->setIcon (GetIcon ("mail")); ui.buttonBox->addButton (static_cast<QAbstractButton*> (mailButton), QDialogButtonBox::HelpRole); connect (ui.buttonBox, SIGNAL (helpRequested()), this, SLOT (slot_mail())); @@ -366,7 +366,7 @@ // ============================================================================= // ============================================================================= -void bombBox (const QString& message) +void DisplayBombBox (const QString& message) { QDialog dlg (g_win); Ui_BombBox ui;
--- a/src/dialogs.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/dialogs.h Wed Aug 06 16:18:24 2014 +0300 @@ -138,4 +138,4 @@ void slot_mail(); }; -void bombBox (const QString& message); +void DisplayBombBox (const QString& message);
--- a/src/editHistory.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editHistory.cc Wed Aug 06 16:18:24 2014 +0300 @@ -139,7 +139,7 @@ // void AddHistory::redo() const { - LDObjectPtr obj = parseLine (code()); + LDObjectPtr obj = ParseLine (code()); parent()->document().toStrongRef()->insertObj (index(), obj); g_win->R()->compileObject (obj); } @@ -155,7 +155,7 @@ // void DelHistory::undo() const { - LDObjectPtr obj = parseLine (code()); + LDObjectPtr obj = ParseLine (code()); parent()->document().toStrongRef()->insertObj (index(), obj); g_win->R()->compileObject (obj); } @@ -172,8 +172,8 @@ // void EditHistory::undo() const { - LDObjectPtr obj = getCurrentDocument()->getObject (index()); - LDObjectPtr newobj = parseLine (oldCode()); + LDObjectPtr obj = CurrentDocument()->getObject (index()); + LDObjectPtr newobj = ParseLine (oldCode()); obj->replace (newobj); g_win->R()->compileObject (newobj); } @@ -182,8 +182,8 @@ // void EditHistory::redo() const { - LDObjectPtr obj = getCurrentDocument()->getObject (index()); - LDObjectPtr newobj = parseLine (newCode()); + LDObjectPtr obj = CurrentDocument()->getObject (index()); + LDObjectPtr newobj = ParseLine (newCode()); obj->replace (newobj); g_win->R()->compileObject (newobj); }
--- a/src/editmodes/abstractEditMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/abstractEditMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -31,7 +31,7 @@ CFGENTRY (Bool, DrawAngles, false) AbstractEditMode::AbstractEditMode (GLRenderer* renderer) : - _renderer (renderer) {} + m_renderer (renderer) {} AbstractEditMode::~AbstractEditMode() {} @@ -51,12 +51,12 @@ GLRenderer* AbstractEditMode::renderer() const { - return _renderer; + return m_renderer; } AbstractDrawMode::AbstractDrawMode (GLRenderer* renderer) : AbstractEditMode (renderer), - _polybrush (QBrush (QColor (64, 192, 0, 128))) + m_polybrush (QBrush (QColor (64, 192, 0, 128))) { // Disable the context menu - we need the right mouse button // for removing vertices. @@ -66,10 +66,10 @@ renderer->setCursor (Qt::CrossCursor); // Clear the selection when beginning to draw. - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); g_win->updateSelection(); - _drawedVerts.clear(); + m_drawedVerts.clear(); } AbstractSelectMode::AbstractSelectMode (GLRenderer* renderer) : @@ -86,7 +86,7 @@ if (preAddVertex (pos)) return; - _drawedVerts << pos; + m_drawedVerts << pos; } bool AbstractDrawMode::mouseReleased (MouseEventData const& data) @@ -94,7 +94,7 @@ if (Super::mouseReleased (data)) return true; - if ((data.releasedButtons & Qt::MidButton) and (_drawedVerts.size() < 4) and (not data.mouseMoved)) + if ((data.releasedButtons & Qt::MidButton) and (m_drawedVerts.size() < 4) and (not data.mouseMoved)) { // Find the closest vertex to our cursor double minimumDistance = 1024.0; @@ -146,10 +146,10 @@ return true; } - if ((data.releasedButtons & Qt::RightButton) and (not _drawedVerts.isEmpty())) + if ((data.releasedButtons & Qt::RightButton) and (not m_drawedVerts.isEmpty())) { // Remove the last vertex - _drawedVerts.removeLast(); + m_drawedVerts.removeLast(); return true; } @@ -171,7 +171,7 @@ g_win->endAction(); } - _drawedVerts.clear(); + m_drawedVerts.clear(); } void AbstractDrawMode::renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d, bool withangles) const @@ -184,7 +184,7 @@ poly[i] = renderer()->coordconv3_2 (poly3d[i]); // Draw the polygon-to-be - painter.setBrush (_polybrush); + painter.setBrush (m_polybrush); painter.drawPolygon (QPolygonF (poly)); // Draw vertex blips
--- a/src/editmodes/abstractEditMode.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/abstractEditMode.h Wed Aug 06 16:18:24 2014 +0300 @@ -34,7 +34,7 @@ class AbstractEditMode { - GLRenderer* _renderer; + GLRenderer* m_renderer; public: struct MouseEventData @@ -68,8 +68,8 @@ DEFINE_CLASS (AbstractDrawMode, AbstractEditMode) protected: - QList<Vertex> _drawedVerts; - QBrush _polybrush; + QList<Vertex> m_drawedVerts; + QBrush m_polybrush; public: AbstractDrawMode (GLRenderer* renderer);
--- a/src/editmodes/circleMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/circleMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -35,14 +35,14 @@ double CircleMode::getCircleDrawDist (int pos) const { - assert (_drawedVerts.size() >= pos + 1); - Vertex v1 = (_drawedVerts.size() >= pos + 2) ? _drawedVerts[pos + 1] : + assert (m_drawedVerts.size() >= pos + 1); + Vertex v1 = (m_drawedVerts.size() >= pos + 2) ? m_drawedVerts[pos + 1] : renderer()->coordconv2_3 (renderer()->mousePosition(), false); Axis localx, localy; renderer()->getRelativeAxes (localx, localy); - double dx = _drawedVerts[0][localx] - v1[localx]; - double dy = _drawedVerts[0][localy] - v1[localy]; - return Grid::snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate); + double dx = m_drawedVerts[0][localx] - v1[localx]; + double dy = m_drawedVerts[0][localy] - v1[localy]; + return Grid::Snap (sqrt ((dx * dx) + (dy * dy)), Grid::Coordinate); } Matrix CircleMode::getCircleDrawMatrix (double scale) @@ -84,14 +84,14 @@ if (dist0 == dist1) { // If the radii are the same, there's no ring space to fill. Use a circle. - refFile = getDocument ("4-4edge.dat"); + refFile = GetDocument ("4-4edge.dat"); transform = getCircleDrawMatrix (dist0); circleOrDisc = true; } elif (dist0 == 0 or dist1 == 0) { // If either radii is 0, use a disc. - refFile = getDocument ("4-4disc.dat"); + refFile = GetDocument ("4-4disc.dat"); transform = getCircleDrawMatrix ((dist0 != 0) ? dist0 : dist1); circleOrDisc = true; } @@ -102,18 +102,18 @@ { // Get a ref file for this primitive. If we cannot find it in the // LDraw library, generate it. - if ((refFile = ::getDocument (radialFileName (::Ring, LowResolution, LowResolution, + if ((refFile = ::GetDocument (MakeRadialFileName (::Ring, LowResolution, LowResolution, cmp.num))) == null) { - refFile = generatePrimitive (::Ring, LowResolution, LowResolution, cmp.num); + refFile = GeneratePrimitive (::Ring, LowResolution, LowResolution, cmp.num); refFile->setImplicit (false); } - LDSubfilePtr ref = spawn<LDSubfile>(); + LDSubfilePtr ref = LDSpawn<LDSubfile>(); ref->setFileInfo (refFile); ref->setTransform (getCircleDrawMatrix (cmp.scale)); - ref->setPosition (_drawedVerts[0]); - ref->setColor (maincolor()); + ref->setPosition (m_drawedVerts[0]); + ref->setColor (MainColor()); objs << ref; } } @@ -124,8 +124,8 @@ Axis localx, localy, localz; renderer()->getRelativeAxes (localx, localy); localz = (Axis) (3 - localx - localy); - double x0 = _drawedVerts[0][localx], - y0 = _drawedVerts[0][localy]; + double x0 = m_drawedVerts[0][localx], + y0 = m_drawedVerts[0][localy]; Vertex templ; templ.setCoordinate (localx, x0); @@ -133,8 +133,8 @@ templ.setCoordinate (localz, renderer()->getDepthValue()); // Calculate circle coords - makeCircle (segs, divs, dist0, c0); - makeCircle (segs, divs, dist1, c1); + MakeCircle (segs, divs, dist0, c0); + MakeCircle (segs, divs, dist1, c1); for (int i = 0; i < segs; ++i) { @@ -149,8 +149,8 @@ v3.setCoordinate (localx, v3[localx] + c1[i].x1()); v3.setCoordinate (localy, v3[localy] + c1[i].y1()); - LDQuadPtr quad (spawn<LDQuad> (v0, v1, v2, v3)); - quad->setColor (maincolor()); + LDQuadPtr quad (LDSpawn<LDQuad> (v0, v1, v2, v3)); + quad->setColor (MainColor()); // Ensure the quads always are BFC-front towards the camera if (renderer()->camera() % 3 <= 0) @@ -162,11 +162,11 @@ if (circleOrDisc and refFile != null) { - LDSubfilePtr ref = spawn<LDSubfile>(); + LDSubfilePtr ref = LDSpawn<LDSubfile>(); ref->setFileInfo (refFile); ref->setTransform (transform); - ref->setPosition (_drawedVerts[0]); - ref->setColor (maincolor()); + ref->setPosition (m_drawedVerts[0]); + ref->setColor (MainColor()); objs << ref; } @@ -178,7 +178,7 @@ QFontMetrics metrics = QFontMetrics (QFont()); // If we have not specified the center point of the circle yet, preview it on the screen. - if (_drawedVerts.isEmpty()) + if (m_drawedVerts.isEmpty()) { renderer()->drawBlip (painter, renderer()->coordconv3_2 (renderer()->position3D())); } @@ -186,9 +186,9 @@ { QVector<Vertex> verts, verts2; const double dist0 = getCircleDrawDist (0), - dist1 = (_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; + dist1 = (m_drawedVerts.size() >= 2) ? getCircleDrawDist (1) : -1; const int segs = LowResolution; - const double angleUnit = (2 * pi) / segs; + const double angleUnit = (2 * Pi) / segs; Axis relX, relY; QVector<QPoint> ringpoints, circlepoints, circle2points; @@ -197,15 +197,15 @@ // Calculate the preview positions of vertices for (int i = 0; i < segs; ++i) { - Vertex v = g_origin; - v.setCoordinate (relX, _drawedVerts[0][relX] + (cos (i * angleUnit) * dist0)); - v.setCoordinate (relY, _drawedVerts[0][relY] + (sin (i * angleUnit) * dist0)); + Vertex v = Origin; + v.setCoordinate (relX, m_drawedVerts[0][relX] + (cos (i * angleUnit) * dist0)); + v.setCoordinate (relY, m_drawedVerts[0][relY] + (sin (i * angleUnit) * dist0)); verts << v; if (dist1 != -1) { - v.setCoordinate (relX, _drawedVerts[0][relX] + (cos (i * angleUnit) * dist1)); - v.setCoordinate (relY, _drawedVerts[0][relY] + (sin (i * angleUnit) * dist1)); + v.setCoordinate (relX, m_drawedVerts[0][relX] + (cos (i * angleUnit) * dist1)); + v.setCoordinate (relY, m_drawedVerts[0][relY] + (sin (i * angleUnit) * dist1)); verts2 << v; } } @@ -242,7 +242,7 @@ ringpoints.insert (33, ringpoints[17]); // Draw the ring - painter.setBrush ((_drawedVerts.size() >= 2) ? _polybrush : Qt::NoBrush); + painter.setBrush ((m_drawedVerts.size() >= 2) ? m_polybrush : Qt::NoBrush); painter.setPen (Qt::NoPen); painter.drawPolygon (QPolygon (ringpoints)); @@ -253,12 +253,12 @@ painter.drawPolygon (QPolygon (circle2points)); // Draw the current radius in the middle of the circle. - QPoint origin = renderer()->coordconv3_2 (_drawedVerts[0]); + QPoint origin = renderer()->coordconv3_2 (m_drawedVerts[0]); QString label = QString::number (dist0); painter.setPen (renderer()->textPen()); painter.drawText (origin.x() - (metrics.width (label) / 2), origin.y(), label); - if (_drawedVerts.size() >= 2) + if (m_drawedVerts.size() >= 2) { painter.drawText (origin.x() - (metrics.width (label) / 2), origin.y() + metrics.height(), QString::number (dist1)); @@ -273,7 +273,7 @@ if (data.releasedButtons & Qt::LeftButton) { - if (_drawedVerts.size() < 3) + if (m_drawedVerts.size() < 3) addDrawnVertex (renderer()->position3D()); else buildCircle();
--- a/src/editmodes/drawMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/drawMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -35,7 +35,7 @@ QVector<Vertex> poly; QFontMetrics metrics = QFontMetrics (QFont()); - for (Vertex const& vert : _drawedVerts) + for (Vertex const& vert : m_drawedVerts) poly << vert; // Draw the cursor vertex as the last one in the list. @@ -48,7 +48,7 @@ bool DrawMode::preAddVertex (Vertex const& pos) { // If we picked an already-existing vertex, stop drawing - for (Vertex& vert : _drawedVerts) + for (Vertex& vert : m_drawedVerts) { if (vert == pos) { @@ -68,7 +68,7 @@ if (data.releasedButtons & Qt::LeftButton) { // If we have 4 verts, stop drawing. - if (_drawedVerts.size() >= 4) + if (m_drawedVerts.size() >= 4) { endDraw(); return true; @@ -84,7 +84,7 @@ void DrawMode::endDraw() { // Clean the selection and create the object - QList<Vertex>& verts = _drawedVerts; + QList<Vertex>& verts = m_drawedVerts; LDObjectList objs; switch (verts.size()) @@ -92,9 +92,9 @@ case 1: { // 1 vertex - add a vertex object - LDVertexPtr obj = spawn<LDVertex>(); + LDVertexPtr obj = LDSpawn<LDVertex>(); obj->pos = verts[0]; - obj->setColor (maincolor()); + obj->setColor (MainColor()); objs << obj; break; } @@ -102,8 +102,8 @@ case 2: { // 2 verts - make a line - LDLinePtr obj = spawn<LDLine> (verts[0], verts[1]); - obj->setColor (edgecolor()); + LDLinePtr obj = LDSpawn<LDLine> (verts[0], verts[1]); + obj->setColor (EdgeColor()); objs << obj; break; } @@ -112,10 +112,10 @@ case 4: { LDObjectPtr obj = (verts.size() == 3) ? - static_cast<LDObjectPtr> (spawn<LDTriangle>()) : - static_cast<LDObjectPtr> (spawn<LDQuad>()); + static_cast<LDObjectPtr> (LDSpawn<LDTriangle>()) : + static_cast<LDObjectPtr> (LDSpawn<LDQuad>()); - obj->setColor (maincolor()); + obj->setColor (MainColor()); for (int i = 0; i < verts.size(); ++i) obj->setVertex (i, verts[i]);
--- a/src/editmodes/drawMode.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/drawMode.h Wed Aug 06 16:18:24 2014 +0300 @@ -22,7 +22,7 @@ class DrawMode : public AbstractDrawMode { DEFINE_CLASS (DrawMode, AbstractDrawMode) - bool _rectdraw; + bool m_rectdraw; public: DrawMode (GLRenderer* renderer);
--- a/src/editmodes/magicWandMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/magicWandMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -26,12 +26,12 @@ Super (renderer) { // Get vertex<->object data - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { // Note: this deliberately only takes vertex-objects into account. // The magic wand does not process subparts. for (int i = 0; i < obj->numVertices(); ++i) - _vertices[obj->vertex (i)] << obj; + m_vertices[obj->vertex (i)] << obj; } } @@ -46,14 +46,14 @@ // of candidates. for (auto it = candidates.begin(); it != candidates.end(); ++it) { - if (not eq ((*it)->type(), OBJ_Line, OBJ_CondLine) or (*it)->vertex (0) == (*it)->vertex (1)) + if (not Eq ((*it)->type(), OBJ_Line, OBJ_CondLine) or (*it)->vertex (0) == (*it)->vertex (1)) continue; int matches = 0; for (int i = 0; i < obj->numVertices(); ++i) { - if (not eq (obj->vertex (i), (*it)->vertex (0), (*it)->vertex (1))) + if (not Eq (obj->vertex (i), (*it)->vertex (0), (*it)->vertex (1))) continue; if (++matches == 2) @@ -61,7 +61,7 @@ // Boundary found. If it's an edgeline, add it to the boundaries list, if a // conditional line, select it. if ((*it)->type() == OBJ_CondLine) - _selection << *it; + m_selection << *it; else boundaries.append (std::make_tuple ((*it)->vertex (0), (*it)->vertex (1))); @@ -77,7 +77,7 @@ { if (type == Set) { - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); g_win->buildObjList(); } @@ -90,8 +90,8 @@ if (type != InternalRecursion) { - _selection.clear(); - _selection.append (obj); + m_selection.clear(); + m_selection.append (obj); } switch (obj->type()) @@ -115,9 +115,9 @@ // Get the list of objects that touch this object, i.e. share a vertex // with this. for (int i = 0; i < obj->numVertices(); ++i) - candidates += _vertices[obj->vertex (i)]; + candidates += m_vertices[obj->vertex (i)]; - removeDuplicates (candidates); + RemoveDuplicates (candidates); // If we're dealing with surfaces, get a list of boundaries. if (matchesneeded > 1) @@ -132,7 +132,7 @@ // objects we have already processed. if ((candidate == obj) or (candidate->color() != obj->color()) or - (_selection.contains (candidate)) or + (m_selection.contains (candidate)) or (matchesneeded == 1 and (candidate->type() != objtype)) or ((candidate->numVertices() > 2) ^ (matchesneeded == 2))) { @@ -160,14 +160,14 @@ // Check if a boundary gets in between the objects. for (auto boundary : boundaries) { - if (eq (matches[0], std::get<0> (boundary), std::get<1> (boundary)) and - eq (matches[1], std::get<0> (boundary), std::get<1> (boundary))) + if (Eq (matches[0], std::get<0> (boundary), std::get<1> (boundary)) and + Eq (matches[1], std::get<0> (boundary), std::get<1> (boundary))) { throw 0; } } - _selection.append (candidate); + m_selection.append (candidate); doMagic (candidate, InternalRecursion); } catch (int&) @@ -179,14 +179,14 @@ switch (type) { case Set: - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); case Additive: - for (LDObjectPtr obj : _selection) + for (LDObjectPtr obj : m_selection) obj->select(); break; case Subtractive: - for (LDObjectPtr obj : _selection) + for (LDObjectPtr obj : m_selection) obj->deselect(); break;
--- a/src/editmodes/magicWandMode.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/magicWandMode.h Wed Aug 06 16:18:24 2014 +0300 @@ -24,8 +24,8 @@ class MagicWandMode : public AbstractSelectMode { - QMap<Vertex, QVector<LDObjectPtr>> _vertices; - QVector<LDObjectPtr> _selection; + QMap<Vertex, QVector<LDObjectPtr>> m_vertices; + QVector<LDObjectPtr> m_selection; DEFINE_CLASS (MagicWandMode, AbstractSelectMode)
--- a/src/editmodes/rectangleMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/rectangleMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -24,7 +24,7 @@ RectangleMode::RectangleMode (GLRenderer* renderer) : Super (renderer), - _rectangleVerts (QVector<Vertex>(4)) {} + m_rectangleVerts (QVector<Vertex>(4)) {} EditModeType RectangleMode::type() const { @@ -33,7 +33,7 @@ void RectangleMode::render (QPainter& painter) const { - renderPolygon (painter, (_drawedVerts.size() > 0) ? _rectangleVerts : + renderPolygon (painter, (m_drawedVerts.size() > 0) ? m_rectangleVerts : QVector<Vertex> ({renderer()->position3D()}), false); } @@ -44,15 +44,15 @@ if (data.releasedButtons & Qt::LeftButton) { - if (_drawedVerts.size() == 2) + if (m_drawedVerts.size() == 2) { - LDQuadPtr quad (spawn<LDQuad>()); + LDQuadPtr quad (LDSpawn<LDQuad>()); updateRectVerts(); for (int i = 0; i < quad->numVertices(); ++i) - quad->setVertex (i, _rectangleVerts[i]); + quad->setVertex (i, m_rectangleVerts[i]); - quad->setColor (maincolor()); + quad->setColor (MainColor()); finishDraw (LDObjectList ({quad})); return true; } @@ -75,30 +75,30 @@ void RectangleMode::updateRectVerts() { - if (_drawedVerts.isEmpty()) + if (m_drawedVerts.isEmpty()) { for (int i = 0; i < 4; ++i) - _rectangleVerts[i] = renderer()->position3D(); + m_rectangleVerts[i] = renderer()->position3D(); return; } - Vertex v0 = _drawedVerts[0], - v1 = (_drawedVerts.size() >= 2) ? _drawedVerts[1] : renderer()->position3D(); + Vertex v0 = m_drawedVerts[0], + v1 = (m_drawedVerts.size() >= 2) ? m_drawedVerts[1] : renderer()->position3D(); const Axis localx = renderer()->getCameraAxis (false), localy = renderer()->getCameraAxis (true), localz = (Axis) (3 - localx - localy); for (int i = 0; i < 4; ++i) - _rectangleVerts[i].setCoordinate (localz, renderer()->getDepthValue()); + m_rectangleVerts[i].setCoordinate (localz, renderer()->getDepthValue()); - _rectangleVerts[0].setCoordinate (localx, v0[localx]); - _rectangleVerts[0].setCoordinate (localy, v0[localy]); - _rectangleVerts[1].setCoordinate (localx, v1[localx]); - _rectangleVerts[1].setCoordinate (localy, v0[localy]); - _rectangleVerts[2].setCoordinate (localx, v1[localx]); - _rectangleVerts[2].setCoordinate (localy, v1[localy]); - _rectangleVerts[3].setCoordinate (localx, v0[localx]); - _rectangleVerts[3].setCoordinate (localy, v1[localy]); + m_rectangleVerts[0].setCoordinate (localx, v0[localx]); + m_rectangleVerts[0].setCoordinate (localy, v0[localy]); + m_rectangleVerts[1].setCoordinate (localx, v1[localx]); + m_rectangleVerts[1].setCoordinate (localy, v0[localy]); + m_rectangleVerts[2].setCoordinate (localx, v1[localx]); + m_rectangleVerts[2].setCoordinate (localy, v1[localy]); + m_rectangleVerts[3].setCoordinate (localx, v0[localx]); + m_rectangleVerts[3].setCoordinate (localy, v1[localy]); }
--- a/src/editmodes/rectangleMode.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/rectangleMode.h Wed Aug 06 16:18:24 2014 +0300 @@ -22,7 +22,7 @@ class RectangleMode : public AbstractDrawMode { DEFINE_CLASS (RectangleMode, AbstractDrawMode) - QVector<Vertex> _rectangleVerts; + QVector<Vertex> m_rectangleVerts; public: RectangleMode (GLRenderer* renderer);
--- a/src/editmodes/selectMode.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/selectMode.cc Wed Aug 06 16:18:24 2014 +0300 @@ -25,7 +25,7 @@ SelectMode::SelectMode (GLRenderer* renderer) : Super (renderer), - _rangepick (false) {} + m_rangepick (false) {} EditModeType SelectMode::type() const { @@ -35,15 +35,15 @@ void SelectMode::render (QPainter& painter) const { // If we're range-picking, draw a rectangle encompassing the selection area. - if (_rangepick) + if (m_rangepick) { - int x0 = _rangeStart.x(), - y0 = _rangeStart.y(), + int x0 = m_rangeStart.x(), + y0 = m_rangeStart.y(), x1 = renderer()->mousePosition().x(), y1 = renderer()->mousePosition().y(); QRect rect (x0, y0, x1 - x0, y1 - y0); - QColor fillColor = (_addpick ? "#40FF00" : "#00CCFF"); + QColor fillColor = (m_addpick ? "#40FF00" : "#00CCFF"); fillColor.setAlphaF (0.2f); painter.setPen (QPen (QColor (0, 0, 0, 208), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setBrush (QBrush (fillColor)); @@ -59,34 +59,34 @@ if (data.releasedButtons & Qt::LeftButton) { if (not data.mouseMoved) - _rangepick = false; + m_rangepick = false; - if (not _rangepick) - _addpick = (data.keymods & Qt::ControlModifier); + if (not m_rangepick) + m_addpick = (data.keymods & Qt::ControlModifier); - if (not data.mouseMoved or _rangepick) + if (not data.mouseMoved or m_rangepick) { QRect area; int const mx = data.ev->x(); int const my = data.ev->y(); - if (not _rangepick) + if (not m_rangepick) { area = QRect (mx, my, 1, 1); } else { - int const x = min (_rangeStart.x(), mx); - int const y = min (_rangeStart.y(), my); - int const width = abs (_rangeStart.x() - mx); - int const height = abs (_rangeStart.y() - my); + int const x = Min (m_rangeStart.x(), mx); + int const y = Min (m_rangeStart.y(), my); + int const width = Abs (m_rangeStart.x() - mx); + int const height = Abs (m_rangeStart.y() - my); area = QRect (x, y, width, height); } - renderer()->pick (area, _addpick); + renderer()->pick (area, m_addpick); } - _rangepick = false; + m_rangepick = false; return true; } @@ -100,10 +100,10 @@ if (ev->modifiers() & Qt::ControlModifier) { - _rangepick = true; - _rangeStart.setX (ev->x()); - _rangeStart.setY (ev->y()); - _addpick = (ev->modifiers() & Qt::AltModifier); + m_rangepick = true; + m_rangeStart.setX (ev->x()); + m_rangeStart.setY (ev->y()); + m_addpick = (ev->modifiers() & Qt::AltModifier); return true; } @@ -133,5 +133,5 @@ bool SelectMode::mouseMoved (QMouseEvent*) { - return _rangepick; + return m_rangepick; }
--- a/src/editmodes/selectMode.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/editmodes/selectMode.h Wed Aug 06 16:18:24 2014 +0300 @@ -21,9 +21,9 @@ class SelectMode : public AbstractSelectMode { - QPoint _rangeStart; - bool _rangepick; - bool _addpick; + QPoint m_rangeStart; + bool m_rangepick; + bool m_addpick; DEFINE_CLASS (SelectMode, AbstractSelectMode)
--- a/src/extPrograms.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/extPrograms.cc Wed Aug 06 16:18:24 2014 +0300 @@ -97,7 +97,7 @@ // ============================================================================= // -static bool mkTempFile (QTemporaryFile& tmp, QString& fname) +static bool MakeTempFile (QTemporaryFile& tmp, QString& fname) { if (not tmp.open()) return false; @@ -109,11 +109,11 @@ // ============================================================================= // -static bool checkProgPath (const extprog prog) +static bool CheckExtProgramPath (const extprog prog) { QString& path = *g_extProgPaths[prog]; - if (path.length() > 0) + if (not path.isEmpty()) return true; ExtProgPathPrompt* dlg = new ExtProgPathPrompt (g_extProgNames[prog]); @@ -129,7 +129,7 @@ // ============================================================================= // -static QString processErrorString (extprog prog, QProcess& proc) +static QString ProcessExtProgError (extprog prog, QProcess& proc) { switch (proc.error()) { @@ -166,7 +166,7 @@ // ============================================================================= // -static void writeObjects (const LDObjectList& objects, QFile& f) +static void WriteObjects (const LDObjectList& objects, QFile& f) { for (LDObjectPtr obj : objects) { @@ -175,7 +175,7 @@ LDSubfilePtr ref = obj.staticCast<LDSubfile>(); LDObjectList objs = ref->inlineContents (true, false); - writeObjects (objs, f); + WriteObjects (objs, f); for (LDObjectPtr obj : objs) obj->destroy(); @@ -187,18 +187,18 @@ // ============================================================================= // -static void writeObjects (const LDObjectList& objects, QString fname) +static void WriteObjects (const LDObjectList& objects, QString fname) { // Write the input file QFile f (fname); if (not f.open (QIODevice::WriteOnly | QIODevice::Text)) { - critical (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString())); + CriticalError (format ("Couldn't open temporary file %1 for writing: %2\n", fname, f.errorString())); return; } - writeObjects (objects, f); + WriteObjects (objects, f); f.close(); #ifdef DEBUG @@ -208,18 +208,18 @@ // ============================================================================= // -void writeSelection (QString fname) +void WriteSelection (QString fname) { - writeObjects (selection(), fname); + WriteObjects (Selection(), fname); } // ============================================================================= // -void writeColorGroup (LDColor color, QString fname) +void WriteColorGroup (LDColor color, QString fname) { LDObjectList objects; - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (not obj->isColored() or obj->color() != color) continue; @@ -227,12 +227,12 @@ objects << obj; } - writeObjects (objects, fname); + WriteObjects (objects, fname); } // ============================================================================= // -bool runUtilityProcess (extprog prog, QString path, QString argvstr) +bool RunExtProgram (extprog prog, QString path, QString argvstr) { QTemporaryFile input; QStringList argv = argvstr.split (" ", QString::SkipEmptyParts); @@ -258,7 +258,7 @@ if (not proc.waitForStarted()) { - critical (format ("Couldn't start %1: %2\n", g_extProgNames[prog], processErrorString (prog, proc))); + CriticalError (format ("Couldn't start %1: %2\n", g_extProgNames[prog], ProcessExtProgError (prog, proc))); return false; } @@ -271,7 +271,7 @@ QString err = ""; if (proc.exitStatus() != QProcess::NormalExit) - err = processErrorString (prog, proc); + err = ProcessExtProgError (prog, proc); // Check the return code if (proc.exitCode() != 0) @@ -279,7 +279,7 @@ if (not err.isEmpty()) { - critical (format ("%1 failed: %2\n", g_extProgNames[prog], err)); + CriticalError (format ("%1 failed: %2\n", g_extProgNames[prog], err)); return false; } @@ -288,7 +288,7 @@ // ============================================================================= // -static void insertOutput (QString fname, bool replace, QList<LDColor> colorsToReplace) +static void InsertOutput (QString fname, bool replace, QList<LDColor> colorsToReplace) { #ifdef DEBUG QFile::copy (fname, "./debug_lastOutput"); @@ -299,11 +299,11 @@ if (not f.open (QIODevice::ReadOnly)) { - critical (format ("Couldn't open temporary file %1 for reading.\n", fname)); + CriticalError (format ("Couldn't open temporary file %1 for reading.\n", fname)); return; } - LDObjectList objs = loadFileContents (&f, null); + LDObjectList objs = LoadFileContents (&f, null); // If we replace the objects, delete the selection now. if (replace) @@ -313,7 +313,7 @@ g_win->deleteByColor (color); // Insert the new objects - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); for (LDObjectPtr obj : objs) { @@ -323,7 +323,7 @@ continue; } - getCurrentDocument()->addObject (obj); + CurrentDocument()->addObject (obj); obj->select(); } @@ -337,7 +337,7 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Ytruder)) + if (not CheckExtProgramPath (Ytruder)) return; QDialog* dlg = new QDialog; @@ -364,7 +364,7 @@ QString inDATName, outDATName; // Make temp files for the input and output files - if (not mkTempFile (indat, inDATName) or not mkTempFile (outdat, outDATName)) + if (not MakeTempFile (indat, inDATName) or not MakeTempFile (outdat, outDATName)) return; // Compose the command-line arguments @@ -379,12 +379,12 @@ outDATName }); - writeSelection (inDATName); + WriteSelection (inDATName); - if (not runUtilityProcess (Ytruder, cfg::YtruderPath, argv)) + if (not RunExtProgram (Ytruder, cfg::YtruderPath, argv)) return; - insertOutput (outDATName, false, {}); + InsertOutput (outDATName, false, {}); } // ============================================================================= @@ -394,7 +394,7 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Rectifier)) + if (not CheckExtProgramPath (Rectifier)) return; QDialog* dlg = new QDialog; @@ -408,7 +408,7 @@ QString inDATName, outDATName; // Make temp files for the input and output files - if (not mkTempFile (indat, inDATName) or not mkTempFile (outdat, outDATName)) + if (not MakeTempFile (indat, inDATName) or not MakeTempFile (outdat, outDATName)) return; // Compose arguments @@ -424,12 +424,12 @@ outDATName }); - writeSelection (inDATName); + WriteSelection (inDATName); - if (not runUtilityProcess (Rectifier, cfg::RectifierPath, argv)) + if (not RunExtProgram (Rectifier, cfg::RectifierPath, argv)) return; - insertOutput (outDATName, true, {}); + InsertOutput (outDATName, true, {}); } // ============================================================================= @@ -439,15 +439,15 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Intersector)) + if (not CheckExtProgramPath (Intersector)) return; QDialog* dlg = new QDialog; Ui::IntersectorUI ui; ui.setupUi (dlg); - makeColorComboBox (ui.cmb_incol); - makeColorComboBox (ui.cmb_cutcol); + MakeColorComboBox (ui.cmb_incol); + MakeColorComboBox (ui.cmb_cutcol); ui.cb_repeat->setWhatsThis ("If this is set, " APPNAME " runs Intersector a second time with inverse files to cut the " " cutter group with the input group. Both groups are cut by the intersection."); ui.cb_edges->setWhatsThis ("Makes " APPNAME " try run Isecalc to create edgelines for the intersection."); @@ -465,7 +465,7 @@ if (inCol == cutCol) { - critical ("Cannot use the same color group for both input and cutter!"); + CriticalError ("Cannot use the same color group for both input and cutter!"); continue; } @@ -481,11 +481,11 @@ QTemporaryFile indat, cutdat, outdat, outdat2, edgesdat; QString inDATName, cutDATName, outDATName, outDAT2Name, edgesDATName; - if (not mkTempFile (indat, inDATName) or - not mkTempFile (cutdat, cutDATName) or - not mkTempFile (outdat, outDATName) or - not mkTempFile (outdat2, outDAT2Name) or - not mkTempFile (edgesdat, edgesDATName)) + if (not MakeTempFile (indat, inDATName) or + not MakeTempFile (cutdat, cutDATName) or + not MakeTempFile (outdat, outDATName) or + not MakeTempFile (outdat2, outDAT2Name) or + not MakeTempFile (edgesdat, edgesDATName)) { return; } @@ -514,21 +514,21 @@ outDAT2Name }); - writeColorGroup (inCol, inDATName); - writeColorGroup (cutCol, cutDATName); + WriteColorGroup (inCol, inDATName); + WriteColorGroup (cutCol, cutDATName); - if (not runUtilityProcess (Intersector, cfg::IntersectorPath, argv_normal)) + if (not RunExtProgram (Intersector, cfg::IntersectorPath, argv_normal)) return; - insertOutput (outDATName, false, {inCol}); + InsertOutput (outDATName, false, {inCol}); - if (repeatInverse and runUtilityProcess (Intersector, cfg::IntersectorPath, argv_inverse)) - insertOutput (outDAT2Name, false, {cutCol}); + if (repeatInverse and RunExtProgram (Intersector, cfg::IntersectorPath, argv_inverse)) + InsertOutput (outDAT2Name, false, {cutCol}); - if (ui.cb_edges->isChecked() and checkProgPath (Isecalc) and - runUtilityProcess (Isecalc, cfg::IsecalcPath, Join ({inDATName, cutDATName, edgesDATName}))) + if (ui.cb_edges->isChecked() and CheckExtProgramPath (Isecalc) and + RunExtProgram (Isecalc, cfg::IsecalcPath, Join ({inDATName, cutDATName, edgesDATName}))) { - insertOutput (edgesDATName, false, {}); + InsertOutput (edgesDATName, false, {}); } } @@ -538,14 +538,14 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Coverer)) + if (not CheckExtProgramPath (Coverer)) return; QDialog* dlg = new QDialog; Ui::CovererUI ui; ui.setupUi (dlg); - makeColorComboBox (ui.cmb_col1); - makeColorComboBox (ui.cmb_col2); + MakeColorComboBox (ui.cmb_col1); + MakeColorComboBox (ui.cmb_col2); LDColor in1Col, in2Col; @@ -559,7 +559,7 @@ if (in1Col == in2Col) { - critical ("Cannot use the same color group for both inputs!"); + CriticalError ("Cannot use the same color group for both inputs!"); continue; } @@ -569,9 +569,9 @@ QTemporaryFile in1dat, in2dat, outdat; QString in1DATName, in2DATName, outDATName; - if (not mkTempFile (in1dat, in1DATName) or - not mkTempFile (in2dat, in2DATName) or - not mkTempFile (outdat, outDATName)) + if (not MakeTempFile (in1dat, in1DATName) or + not MakeTempFile (in2dat, in2DATName) or + not MakeTempFile (outdat, outDATName)) { return; } @@ -587,13 +587,13 @@ outDATName }); - writeColorGroup (in1Col, in1DATName); - writeColorGroup (in2Col, in2DATName); + WriteColorGroup (in1Col, in1DATName); + WriteColorGroup (in2Col, in2DATName); - if (not runUtilityProcess (Coverer, cfg::CovererPath, argv)) + if (not RunExtProgram (Coverer, cfg::CovererPath, argv)) return; - insertOutput (outDATName, false, {}); + InsertOutput (outDATName, false, {}); } // ============================================================================= @@ -602,15 +602,15 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Isecalc)) + if (not CheckExtProgramPath (Isecalc)) return; Ui::IsecalcUI ui; QDialog* dlg = new QDialog; ui.setupUi (dlg); - makeColorComboBox (ui.cmb_col1); - makeColorComboBox (ui.cmb_col2); + MakeColorComboBox (ui.cmb_col1); + MakeColorComboBox (ui.cmb_col2); LDColor in1Col, in2Col; @@ -625,7 +625,7 @@ if (in1Col == in2Col) { - critical ("Cannot use the same color group for both input and cutter!"); + CriticalError ("Cannot use the same color group for both input and cutter!"); continue; } @@ -635,9 +635,9 @@ QTemporaryFile in1dat, in2dat, outdat; QString in1DATName, in2DATName, outDATName; - if (not mkTempFile (in1dat, in1DATName) or - not mkTempFile (in2dat, in2DATName) or - not mkTempFile (outdat, outDATName)) + if (not MakeTempFile (in1dat, in1DATName) or + not MakeTempFile (in2dat, in2DATName) or + not MakeTempFile (outdat, outDATName)) { return; } @@ -649,10 +649,10 @@ outDATName }); - writeColorGroup (in1Col, in1DATName); - writeColorGroup (in2Col, in2DATName); - runUtilityProcess (Isecalc, cfg::IsecalcPath, argv); - insertOutput (outDATName, false, {}); + WriteColorGroup (in1Col, in1DATName); + WriteColorGroup (in2Col, in2DATName); + RunExtProgram (Isecalc, cfg::IsecalcPath, argv); + InsertOutput (outDATName, false, {}); } // ============================================================================= @@ -661,7 +661,7 @@ { setlocale (LC_ALL, "C"); - if (not checkProgPath (Edger2)) + if (not CheckExtProgramPath (Edger2)) return; QDialog* dlg = new QDialog; @@ -674,7 +674,7 @@ QTemporaryFile in, out; QString inName, outName; - if (not mkTempFile (in, inName) or not mkTempFile (out, outName)) + if (not MakeTempFile (in, inName) or not MakeTempFile (out, outName)) return; int unmatched = ui.unmatched->currentIndex(); @@ -696,10 +696,10 @@ outName, }); - writeSelection (inName); + WriteSelection (inName); - if (not runUtilityProcess (Edger2, cfg::Edger2Path, argv)) + if (not RunExtProgram (Edger2, cfg::Edger2Path, argv)) return; - insertOutput (outName, true, {}); + InsertOutput (outName, true, {}); }
--- a/src/format.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/format.h Wed Aug 06 16:18:24 2014 +0300 @@ -120,7 +120,7 @@ // From messageLog.cc - declared here so that I don't need to include // messageLog.h here. Prints the given message to log. // -void printToLog (const QString& msg); +void PrintToLog (const QString& msg); // // Format and print the given args to the message log. @@ -129,7 +129,7 @@ void print (QString fmtstr, Args... args) { formatHelper (fmtstr, args...); - printToLog (fmtstr); + PrintToLog (fmtstr); } // @@ -160,7 +160,7 @@ void dprint (QString fmtstr, Args... args) { formatHelper (fmtstr, args...); - printToLog (fmtstr); + PrintToLog (fmtstr); } #else void dprint (QString, Args...) {}
--- a/src/glCompiler.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/glCompiler.cc Wed Aug 06 16:18:24 2014 +0300 @@ -57,7 +57,7 @@ // ============================================================================= // -void checkGLError_private (const char* file, int line) +void CheckGLErrorImpl (const char* file, int line) { QString errmsg; GLenum errnum = glGetError(); @@ -74,7 +74,7 @@ } } - print ("OpenGL ERROR: at %1:%2: %3", basename (QString (file)), line, errmsg); + print ("OpenGL ERROR: at %1:%2: %3", Basename (QString (file)), line, errmsg); } // ============================================================================= @@ -92,7 +92,7 @@ { initializeOpenGLFunctions(); glGenBuffers (g_numVBOs, &m_vbo[0]); - checkGLError(); + CHECK_GL_ERROR(); } // ============================================================================= @@ -100,7 +100,7 @@ GLCompiler::~GLCompiler() { glDeleteBuffers (g_numVBOs, &m_vbo[0]); - checkGLError(); + CHECK_GL_ERROR(); if (m_renderer != null) m_renderer->setCompiler (null); @@ -159,16 +159,16 @@ break; case VBOCM_NormalColors: - if (poly.color == mainColorIndex) + if (poly.color == MainColorIndex) { - if (topobj->color() == maincolor()) + if (topobj->color() == MainColor()) qcol = GLRenderer::getMainColor(); else qcol = topobj->color().faceColor(); } - elif (poly.color == edgeColorIndex) + elif (poly.color == EdgeColorIndex) { - qcol = luma (QColor (cfg::BackgroundColor)) > 40 ? Qt::black : Qt::white; + qcol = Luma (QColor (cfg::BackgroundColor)) > 40 ? Qt::black : Qt::white; } else { @@ -260,7 +260,7 @@ // void GLCompiler::compileStaged() { - removeDuplicates (m_staged); + RemoveDuplicates (m_staged); for (LDObjectPtr obj : m_staged) compileObject (obj); @@ -284,14 +284,14 @@ { if (it.key() == null) it = m_objectInfo.erase (it); - elif (it.key().toStrongRef()->document() == getCurrentDocument() and not it.key().toStrongRef()->isHidden()) + elif (it.key().toStrongRef()->document() == CurrentDocument() and not it.key().toStrongRef()->isHidden()) vbodata += it->data[vbonum]; } glBindBuffer (GL_ARRAY_BUFFER, m_vbo[vbonum]); glBufferData (GL_ARRAY_BUFFER, vbodata.size() * sizeof(GLfloat), vbodata.constData(), GL_STATIC_DRAW); glBindBuffer (GL_ARRAY_BUFFER, 0); - checkGLError(); + CHECK_GL_ERROR(); m_vboChanged[vbonum] = false; m_vboSizes[vbonum] = vbodata.size(); }
--- a/src/glCompiler.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/glCompiler.h Wed Aug 06 16:18:24 2014 +0300 @@ -77,5 +77,5 @@ GLRenderer* m_renderer; }; -#define checkGLError() { checkGLError_private (__FILE__, __LINE__); } -void checkGLError_private (const char* file, int line); +#define CHECK_GL_ERROR() { CheckGLErrorImpl (__FILE__, __LINE__); } +void CheckGLErrorImpl (const char* file, int line);
--- a/src/glRenderer.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/glRenderer.cc Wed Aug 06 16:18:24 2014 +0300 @@ -110,7 +110,7 @@ setDrawOnly (false); setMessageLog (null); m_width = m_height = -1; - m_position3D = g_origin; + m_position3D = Origin; m_toolTipTimer = new QTimer (this); m_toolTipTimer->setSingleShot (true); m_isCameraMoving = false; @@ -124,7 +124,7 @@ { QString iconname = format ("camera-%1", tr (g_CameraNames[cam]).toLower()); CameraIcon* info = &m_cameraIcons[cam]; - info->img = new QPixmap (getIcon (iconname)); + info->img = new QPixmap (GetIcon (iconname)); info->cam = cam; } @@ -148,8 +148,8 @@ delete m_compiler; delete m_editmode; - glDeleteBuffers (1, &_axesVBO); - glDeleteBuffers (1, &_axesColorVBO); + glDeleteBuffers (1, &m_axesVBO); + glDeleteBuffers (1, &m_axesColorVBO); } // ============================================================================= @@ -280,11 +280,11 @@ } } - glGenBuffers (1, &_axesVBO); - glBindBuffer (GL_ARRAY_BUFFER, _axesVBO); + glGenBuffers (1, &m_axesVBO); + glBindBuffer (GL_ARRAY_BUFFER, m_axesVBO); glBufferData (GL_ARRAY_BUFFER, sizeof axesdata, axesdata, GL_STATIC_DRAW); - glGenBuffers (1, &_axesColorVBO); - glBindBuffer (GL_ARRAY_BUFFER, _axesColorVBO); + glGenBuffers (1, &m_axesColorVBO); + glBindBuffer (GL_ARRAY_BUFFER, m_axesColorVBO); glBufferData (GL_ARRAY_BUFFER, sizeof colordata, colordata, GL_STATIC_DRAW); glBindBuffer (GL_ARRAY_BUFFER, 0); } @@ -319,7 +319,7 @@ col.setAlpha (255); - m_darkbg = luma (col) < 80; + m_darkbg = Luma (col) < 80; m_bgcolor = col; qglClearColor (col); } @@ -341,7 +341,7 @@ if (not RendererInitialized) return; - compiler()->compileDocument (getCurrentDocument()); + compiler()->compileDocument (CurrentDocument()); refresh(); } @@ -460,12 +460,12 @@ if (cfg::DrawAxes) { - glBindBuffer (GL_ARRAY_BUFFER, _axesVBO); + glBindBuffer (GL_ARRAY_BUFFER, m_axesVBO); glVertexPointer (3, GL_FLOAT, 0, NULL); - glBindBuffer (GL_ARRAY_BUFFER, _axesVBO); + glBindBuffer (GL_ARRAY_BUFFER, m_axesVBO); glColorPointer (3, GL_FLOAT, 0, NULL); glDrawArrays (GL_LINES, 0, 6); - checkGLError(); + CHECK_GL_ERROR(); } } @@ -473,7 +473,7 @@ glBindBuffer (GL_ARRAY_BUFFER, 0); glDisableClientState (GL_VERTEX_ARRAY); glDisableClientState (GL_COLOR_ARRAY); - checkGLError(); + CHECK_GL_ERROR(); glDisable (GL_CULL_FACE); glMatrixMode (GL_MODELVIEW); glPolygonMode (GL_FRONT_AND_BACK, GL_FILL); @@ -484,7 +484,7 @@ void GLRenderer::drawVBOs (EVBOSurface surface, EVBOComplement colors, GLenum type) { // Filter this through some configuration options - if ((eq (surface, VBOSF_Quads, VBOSF_Triangles) and cfg::DrawSurfaces == false) or + if ((Eq (surface, VBOSF_Quads, VBOSF_Triangles) and cfg::DrawSurfaces == false) or (surface == VBOSF_Lines and cfg::DrawEdgeLines == false) or (surface == VBOSF_CondLines and cfg::DrawConditionalLines == false)) { @@ -503,12 +503,12 @@ { glBindBuffer (GL_ARRAY_BUFFER, surfacevbo); glVertexPointer (3, GL_FLOAT, 0, null); - checkGLError(); + CHECK_GL_ERROR(); glBindBuffer (GL_ARRAY_BUFFER, colorvbo); glColorPointer (4, GL_FLOAT, 0, null); - checkGLError(); + CHECK_GL_ERROR(); glDrawArrays (type, 0, count); - checkGLError(); + CHECK_GL_ERROR(); } } @@ -533,8 +533,8 @@ if (snap) { - cx = Grid::snap (cx, Grid::Coordinate); - cy = Grid::snap (cy, Grid::Coordinate); + cx = Grid::Snap (cx, Grid::Coordinate); + cy = Grid::Snap (cy, Grid::Coordinate); } cx *= negXFac; @@ -590,7 +590,7 @@ { QPen linepen (m_thinBorderPen); linepen.setWidth (2); - linepen.setColor (luma (m_bgcolor) < 40 ? Qt::white : Qt::black); + linepen.setColor (Luma (m_bgcolor) < 40 ? Qt::white : Qt::black); return linepen; } @@ -634,7 +634,7 @@ QPoint v0 = coordconv3_2 (currentDocumentData().overlays[camera()].v0), v1 = coordconv3_2 (currentDocumentData().overlays[camera()].v1); - QRect targRect (v0.x(), v0.y(), abs (v1.x() - v0.x()), abs (v1.y() - v0.y())), + QRect targRect (v0.x(), v0.y(), Abs (v1.x() - v0.x()), Abs (v1.y() - v0.y())), srcRect (0, 0, overlay.img->width(), overlay.img->height()); paint.drawImage (targRect, *overlay.img, srcRect); } @@ -794,7 +794,7 @@ { int dx = ev->x() - m_mousePosition.x(); int dy = ev->y() - m_mousePosition.y(); - m_totalmove += abs (dx) + abs (dy); + m_totalmove += Abs (dx) + Abs (dy); setCameraMoving (false); if (not m_editmode->mouseMoved (ev)) @@ -830,7 +830,7 @@ m_globalpos = ev->globalPos(); // Calculate 3d position of the cursor - m_position3D = (camera() != EFreeCamera) ? coordconv2_3 (m_mousePosition, true) : g_origin; + m_position3D = (camera() != EFreeCamera) ? coordconv2_3 (m_mousePosition, true) : Origin; highlightCursorObject(); update(); @@ -858,7 +858,7 @@ doMakeCurrent(); zoomNotch (ev->delta() > 0); - zoom() = clamp (zoom(), 0.01, 10000.0); + zoom() = Clamp (zoom(), 0.01, 10000.0); setCameraMoving (true); update(); ev->accept(); @@ -910,8 +910,8 @@ // Clear the selection if we do not wish to add to it. if (not additive) { - LDObjectList oldsel = selection(); - getCurrentDocument()->clearSelection(); + LDObjectList oldsel = Selection(); + CurrentDocument()->clearSelection(); for (LDObjectPtr obj : oldsel) compileObject (obj); @@ -927,10 +927,10 @@ int y1 = y0 + range.height(); // Clamp the values to ensure they're within bounds - x0 = max (0, x0); - y0 = max (0, y0); - x1 = min (x1, m_width); - y1 = min (y1, m_height); + x0 = Max (0, x0); + y0 = Max (0, y0); + x1 = Min (x1, m_width); + y1 = Min (y1, m_height); const int areawidth = (x1 - x0); const int areaheight = (y1 - y0); const qint32 numpixels = areawidth * areaheight; @@ -959,7 +959,7 @@ indices << idx; } - removeDuplicates (indices); + RemoveDuplicates (indices); for (qint32 idx : indices) { @@ -987,7 +987,7 @@ g_win->updateSelection(); // Recompile the objects now to update their color - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) compileObject (obj); if (removedObj) @@ -1070,7 +1070,7 @@ glDisable (GL_DITHER); // Use particularly thick lines while picking ease up selecting lines. - glLineWidth (max<double> (cfg::LineThickness, 6.5)); + glLineWidth (Max<double> (cfg::LineThickness, 6.5)); } else { @@ -1100,7 +1100,7 @@ // ============================================================================= // -static QList<Vertex> getVertices (LDObjectPtr obj) +static QList<Vertex> GetVerticesOf (LDObjectPtr obj) { QList<Vertex> verts; @@ -1116,7 +1116,7 @@ for (LDObjectPtr obj : objs) { - verts << getVertices (obj); + verts << GetVerticesOf (obj); obj->destroy(); } } @@ -1196,7 +1196,7 @@ if (img->isNull()) { - critical (tr ("Failed to load overlay image!")); + CriticalError (tr ("Failed to load overlay image!")); currentDocumentData().overlays[cam].invalid = true; delete img; return false; @@ -1222,7 +1222,7 @@ const double negXFac = g_FixedCameras[cam].negX ? -1 : 1, negYFac = g_FixedCameras[cam].negY ? -1 : 1; - info.v0 = info.v1 = g_origin; + info.v0 = info.v1 = Origin; info.v0.setCoordinate (x2d, -(info.ox * info.lw * negXFac) / img->width()); info.v0.setCoordinate (y2d, (info.oy * info.lh * negYFac) / img->height()); info.v1.setCoordinate (x2d, info.v0[x2d] + info.lw); @@ -1488,7 +1488,7 @@ { // Inverse case: image is there but the overlay object is // not, thus create the object. - ovlobj = spawn<LDOverlay>(); + ovlobj = LDSpawn<LDOverlay>(); // Find a suitable position to place this object. We want to place // this into the header, which is everything up to the first scemantic @@ -1520,7 +1520,7 @@ document()->insertObj (i, ovlobj); if (found) - document()->insertObj (i + 1, spawn<LDEmpty>()); + document()->insertObj (i + 1, LDSpawn<LDEmpty>()); } } @@ -1593,11 +1593,11 @@ if (g_win != null and ev->source() == g_win->getPrimitivesTree()) { QString primName = static_cast<SubfileListItem*> (g_win->getPrimitivesTree()->currentItem())->primitive()->name; - LDSubfilePtr ref = spawn<LDSubfile>(); - ref->setColor (maincolor()); - ref->setFileInfo (getDocument (primName)); - ref->setPosition (g_origin); - ref->setTransform (g_identity); + LDSubfilePtr ref = LDSpawn<LDSubfile>(); + ref->setColor (MainColor()); + ref->setFileInfo (GetDocument (primName)); + ref->setPosition (Origin); + ref->setTransform (IdentityMatrix); LDDocument::current()->insertObj (g_win->getInsertionPoint(), ref); ref->select(); g_win->buildObjList();
--- a/src/glRenderer.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/glRenderer.h Wed Aug 06 16:18:24 2014 +0300 @@ -233,8 +233,8 @@ m_totalmove; QColor m_bgcolor; AbstractEditMode* m_editmode; - GLuint _axesVBO; - GLuint _axesColorVBO; + GLuint m_axesVBO; + GLuint m_axesColorVBO; void calcCameraIcons(); void clampAngle (double& angle) const;
--- a/src/ldConfig.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ldConfig.cc Wed Aug 06 16:18:24 2014 +0300 @@ -27,7 +27,7 @@ // // Helper function for parseLDConfig // -static bool parseLDConfigTag (LDConfigParser& pars, char const* tag, QString& val) +static bool ParseLDConfigTag (LDConfigParser& pars, char const* tag, QString& val) { int pos; @@ -43,11 +43,11 @@ // void LDConfigParser::parseLDConfig() { - QFile* fp = openLDrawFile ("LDConfig.ldr", false); + QFile* fp = OpenLDrawFile ("LDConfig.ldr", false); if (fp == null) { - critical (QObject::tr ("Unable to open LDConfig.ldr for parsing.")); + CriticalError (QObject::tr ("Unable to open LDConfig.ldr for parsing.")); return; } @@ -80,7 +80,7 @@ name.replace ("_", " "); // Get the CODE tag - if (not parseLDConfigTag (pars, "CODE", valuestr)) + if (not ParseLDConfigTag (pars, "CODE", valuestr)) continue; // Ensure that the code is within [0 - 511] @@ -91,7 +91,7 @@ continue; // VALUE and EDGE tags - if (not parseLDConfigTag (pars, "VALUE", facename) or not parseLDConfigTag (pars, "EDGE", edgename)) + if (not ParseLDConfigTag (pars, "VALUE", facename) or not ParseLDConfigTag (pars, "EDGE", edgename)) continue; // Ensure that our colors are correct @@ -102,16 +102,16 @@ continue; // Parse alpha if given. - if (parseLDConfigTag (pars, "ALPHA", valuestr)) - alpha = clamp (valuestr.toInt(), 0, 255); + if (ParseLDConfigTag (pars, "ALPHA", valuestr)) + alpha = Clamp (valuestr.toInt(), 0, 255); LDColorData* col = new LDColorData; - col->_name = name; - col->_faceColor = faceColor; - col->_edgeColor = edgeColor; - col->_hexcode = facename; - col->_faceColor.setAlpha (alpha); - col->_index = code; + col->m_name = name; + col->m_faceColor = faceColor; + col->m_edgeColor = edgeColor; + col->m_hexcode = facename; + col->m_faceColor.setAlpha (alpha); + col->m_index = code; LDColor::addLDConfigColor (code, LDColor (col)); }
--- a/src/ldDocument.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ldDocument.cc Wed Aug 06 16:18:24 2014 +0300 @@ -126,8 +126,8 @@ LDDocument::LDDocument (LDDocumentPtr* selfptr) : m_isImplicit (true), m_flags (0), - _verticesOutdated (true), - _needVertexMerge (true), + m_verticesOutdated (true), + m_needVertexMerge (true), m_gldata (new LDGLData) { *selfptr = LDDocumentPtr (this); @@ -224,7 +224,7 @@ // ============================================================================= // -LDDocumentPtr findDocument (QString name) +LDDocumentPtr FindDocument (QString name) { for (LDDocumentWeakPtr file : g_allDocuments) { @@ -237,7 +237,7 @@ // ============================================================================= // -QString dirname (QString path) +QString Dirname (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -254,7 +254,7 @@ // ============================================================================= // -QString basename (QString path) +QString Basename (QString path) { long lastpos = path.lastIndexOf (DIRSLASH); @@ -266,7 +266,7 @@ // ============================================================================= // -static QString findLDrawFilePath (QString relpath, bool subdirs) +static QString FindDocumentPath (QString relpath, bool subdirs) { QString fullPath; @@ -279,20 +279,20 @@ // Try find it relative to other currently open documents. We want a file // in the immediate vicinity of a current model to override stock LDraw stuff. - QString reltop = basename (dirname (relpath)); + QString reltop = Basename (Dirname (relpath)); for (LDDocumentWeakPtr doc : g_allDocuments) { if (doc == null) continue; - QString partpath = format ("%1/%2", dirname (doc.toStrongRef()->fullPath()), relpath); + QString partpath = format ("%1/%2", Dirname (doc.toStrongRef()->fullPath()), relpath); QFile f (partpath); if (f.exists()) { // ensure we don't mix subfiles and 48-primitives with non-subfiles and non-48 - QString proptop = basename (dirname (partpath)); + QString proptop = Basename (Dirname (partpath)); bool bogus = false; @@ -341,10 +341,10 @@ // ============================================================================= // -QFile* openLDrawFile (QString relpath, bool subdirs, QString* pathpointer) +QFile* OpenLDrawFile (QString relpath, bool subdirs, QString* pathpointer) { print ("Opening %1...\n", relpath); - QString path = findLDrawFilePath (relpath, subdirs); + QString path = FindDocumentPath (relpath, subdirs); if (pathpointer != null) *pathpointer = path; @@ -421,7 +421,7 @@ while (line.endsWith ("\n") or line.endsWith ("\r")) line.chop (1); - LDObjectPtr obj = parseLine (line); + LDObjectPtr obj = ParseLine (line); // Check for parse errors and warn about tthem if (obj->type() == OBJ_Error) @@ -481,7 +481,7 @@ // ============================================================================= // -LDObjectList loadFileContents (QFile* fp, int* numWarnings, bool* ok) +LDObjectList LoadFileContents (QFile* fp, int* numWarnings, bool* ok) { QStringList lines; LDObjectList objs; @@ -517,7 +517,7 @@ // ============================================================================= // -LDDocumentPtr openDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride) +LDDocumentPtr OpenDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride) { // Convert the file name to lowercase since some parts contain uppercase // file names. I'll assume here that the library will always use lowercase @@ -526,7 +526,7 @@ QString fullpath; if (search) - fp = openLDrawFile (path.toLower(), true, &fullpath); + fp = OpenLDrawFile (path.toLower(), true, &fullpath); else { fp = new QFile (path); @@ -552,7 +552,7 @@ int numWarnings; bool ok; - LDObjectList objs = loadFileContents (fp, &numWarnings, &ok); + LDObjectList objs = LoadFileContents (fp, &numWarnings, &ok); fp->close(); fp->deleteLater(); @@ -598,7 +598,7 @@ if (name().length() == 0) { QString newpath = QFileDialog::getSaveFileName (g_win, tr ("Save As"), - getCurrentDocument()->name(), tr ("LDraw files (*.dat *.ldr)")); + CurrentDocument()->name(), tr ("LDraw files (*.dat *.ldr)")); if (newpath.length() == 0) return false; @@ -633,7 +633,7 @@ // ============================================================================= // -void closeAll() +void CloseAllDocuments() { for (LDDocumentPtr file : g_explicitDocuments) file->dismiss(); @@ -657,7 +657,7 @@ // ============================================================================= // -void addRecentFile (QString path) +void AddRecentFile (QString path) { auto& rfiles = cfg::RecentFiles; int idx = rfiles.indexOf (path); @@ -685,7 +685,7 @@ // ============================================================================= // Open an LDraw file and set it as the main model // ============================================================================= -void openMainFile (QString path) +void OpenMainModel (QString path) { // If there's already a file with the same name, this file must replace it. LDDocumentPtr documentToReplace; @@ -716,7 +716,7 @@ file->clear(); } - file = openDocument (path, false, false, file); + file = OpenDocument (path, false, false, file); if (file == null) { @@ -724,7 +724,7 @@ { // Tell the user loading failed. setlocale (LC_ALL, "C"); - critical (format (QObject::tr ("Failed to open %1: %2"), path, strerror (errno))); + CriticalError (format (QObject::tr ("Failed to open %1: %2"), path, strerror (errno))); } g_loadingMainFile = false; @@ -742,7 +742,7 @@ g_win->doFullRefresh(); // Add it to the recent files list. - addRecentFile (path); + AddRecentFile (path); g_loadingMainFile = false; } @@ -815,7 +815,7 @@ // ============================================================================= // -static void checkTokenCount (const QStringList& tokens, int num) +static void CheckTokenCount (const QStringList& tokens, int num) { if (tokens.size() != num) throw QString (format ("Bad amount of tokens, expected %1, got %2", num, tokens.size())); @@ -823,7 +823,7 @@ // ============================================================================= // -static void checkTokenNumbers (const QStringList& tokens, int min, int max) +static void CheckTokenNumbers (const QStringList& tokens, int min, int max) { bool ok; @@ -856,14 +856,14 @@ // ============================================================================= // -static Vertex parseVertex (QStringList& s, const int n) +static Vertex ParseVertex (QStringList& s, const int n) { Vertex v; v.apply ([&] (Axis ax, double& a) { a = s[n + ax].toDouble(); }); return v; } -static int32 stringToNumber (QString a) +static int32 StringToNumber (QString a, bool* ok = null) { int base = 10; @@ -873,7 +873,7 @@ base = 16; } - return a.toLong (null, base); + return a.toLong (ok, base); } // ============================================================================= @@ -881,7 +881,7 @@ // code and returns the object parsed from it. parseLine never returns null, // the object will be LDError if it could not be parsed properly. // ============================================================================= -LDObjectPtr parseLine (QString line) +LDObjectPtr ParseLine (QString line) { try { @@ -890,7 +890,7 @@ if (tokens.size() <= 0) { // Line was empty, or only consisted of whitespace - return spawn<LDEmpty>(); + return LDSpawn<LDEmpty>(); } if (tokens[0].length() != 1 or not tokens[0][0].isDigit()) @@ -914,7 +914,7 @@ if (commentTextSimplified == format ("BFC %1", LDBFC::StatementStrings[int (i)])) { - return spawn<LDBFC> (i); + return LDSpawn<LDBFC> (i); } } @@ -922,11 +922,11 @@ // creates. The above block only handles valid statements, so we // need to handle MLCAD-style invertnext, clip and noclip separately. if (commentTextSimplified == "BFC CERTIFY INVERTNEXT") - return spawn<LDBFC> (BFCStatement::InvertNext); + return LDSpawn<LDBFC> (BFCStatement::InvertNext); elif (commentTextSimplified == "BFC CERTIFY CLIP") - return spawn<LDBFC> (BFCStatement::Clip); + return LDSpawn<LDBFC> (BFCStatement::Clip); elif (commentTextSimplified == "BFC CERTIFY NOCLIP") - return spawn<LDBFC> (BFCStatement::NoClip); + return LDSpawn<LDBFC> (BFCStatement::NoClip); } if (tokens.size() > 2 and tokens[1] == "!LDFORGE") @@ -935,21 +935,21 @@ if (tokens[2] == "VERTEX") { // Vertex (0 !LDFORGE VERTEX) - checkTokenCount (tokens, 7); - checkTokenNumbers (tokens, 3, 6); + CheckTokenCount (tokens, 7); + CheckTokenNumbers (tokens, 3, 6); - LDVertexPtr obj = spawn<LDVertex>(); - obj->setColor (LDColor::fromIndex (stringToNumber (tokens[3]))); + LDVertexPtr obj = LDSpawn<LDVertex>(); + obj->setColor (LDColor::fromIndex (StringToNumber (tokens[3]))); obj->pos.apply ([&](Axis ax, double& value) { value = tokens[4 + ax].toDouble(); }); return obj; } elif (tokens[2] == "OVERLAY") { - checkTokenCount (tokens, 9); - checkTokenNumbers (tokens, 5, 8); + CheckTokenCount (tokens, 9); + CheckTokenNumbers (tokens, 5, 8); - LDOverlayPtr obj = spawn<LDOverlay>(); + LDOverlayPtr obj = LDSpawn<LDOverlay>(); obj->setFileName (tokens[3]); obj->setCamera (tokens[4].toLong()); obj->setX (tokens[5].toLong()); @@ -961,7 +961,7 @@ } // Just a regular comment: - LDCommentPtr obj = spawn<LDComment>(); + LDCommentPtr obj = LDSpawn<LDComment>(); obj->setText (commentText); return obj; } @@ -969,28 +969,28 @@ case 1: { // Subfile - checkTokenCount (tokens, 15); - checkTokenNumbers (tokens, 1, 13); + CheckTokenCount (tokens, 15); + CheckTokenNumbers (tokens, 1, 13); // Try open the file. Disable g_loadingMainFile temporarily since we're // not loading the main file now, but the subfile in question. bool tmp = g_loadingMainFile; g_loadingMainFile = false; - LDDocumentPtr load = getDocument (tokens[14]); + LDDocumentPtr load = GetDocument (tokens[14]); g_loadingMainFile = tmp; // If we cannot open the file, mark it an error. Note we cannot use LDParseError // here because the error object needs the document reference. if (not load) { - LDErrorPtr obj = spawn<LDError> (line, format ("Could not open %1", tokens[14])); + LDErrorPtr obj = LDSpawn<LDError> (line, format ("Could not open %1", tokens[14])); obj->setFileReferenced (tokens[14]); return obj; } - LDSubfilePtr obj = spawn<LDSubfile>(); - obj->setColor (LDColor::fromIndex (stringToNumber (tokens[1]))); - obj->setPosition (parseVertex (tokens, 2)); // 2 - 4 + LDSubfilePtr obj = LDSpawn<LDSubfile>(); + obj->setColor (LDColor::fromIndex (StringToNumber (tokens[1]))); + obj->setPosition (ParseVertex (tokens, 2)); // 2 - 4 Matrix transform; @@ -1004,30 +1004,30 @@ case 2: { - checkTokenCount (tokens, 8); - checkTokenNumbers (tokens, 1, 7); + CheckTokenCount (tokens, 8); + CheckTokenNumbers (tokens, 1, 7); // Line - LDLinePtr obj (spawn<LDLine>()); - obj->setColor (LDColor::fromIndex (stringToNumber (tokens[1]))); + LDLinePtr obj (LDSpawn<LDLine>()); + obj->setColor (LDColor::fromIndex (StringToNumber (tokens[1]))); for (int i = 0; i < 2; ++i) - obj->setVertex (i, parseVertex (tokens, 2 + (i * 3))); // 2 - 7 + obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 7 return obj; } case 3: { - checkTokenCount (tokens, 11); - checkTokenNumbers (tokens, 1, 10); + CheckTokenCount (tokens, 11); + CheckTokenNumbers (tokens, 1, 10); // Triangle - LDTrianglePtr obj (spawn<LDTriangle>()); - obj->setColor (LDColor::fromIndex (stringToNumber (tokens[1]))); + LDTrianglePtr obj (LDSpawn<LDTriangle>()); + obj->setColor (LDColor::fromIndex (StringToNumber (tokens[1]))); for (int i = 0; i < 3; ++i) - obj->setVertex (i, parseVertex (tokens, 2 + (i * 3))); // 2 - 10 + obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 10 return obj; } @@ -1035,21 +1035,21 @@ case 4: case 5: { - checkTokenCount (tokens, 14); - checkTokenNumbers (tokens, 1, 13); + CheckTokenCount (tokens, 14); + CheckTokenNumbers (tokens, 1, 13); // Quadrilateral / Conditional line LDObjectPtr obj; if (num == 4) - obj = spawn<LDQuad>(); + obj = LDSpawn<LDQuad>(); else - obj = spawn<LDCondLine>(); + obj = LDSpawn<LDCondLine>(); - obj->setColor (LDColor::fromIndex (stringToNumber (tokens[1]))); + obj->setColor (LDColor::fromIndex (StringToNumber (tokens[1]))); for (int i = 0; i < 4; ++i) - obj->setVertex (i, parseVertex (tokens, 2 + (i * 3))); // 2 - 13 + obj->setVertex (i, ParseVertex (tokens, 2 + (i * 3))); // 2 - 13 return obj; } @@ -1061,49 +1061,49 @@ catch (QString& e) { // Strange line we couldn't parse - return spawn<LDError> (line, e); + return LDSpawn<LDError> (line, e); } } // ============================================================================= // -LDDocumentPtr getDocument (QString filename) +LDDocumentPtr GetDocument (QString filename) { // Try find the file in the list of loaded files - LDDocumentPtr doc = findDocument (filename); + LDDocumentPtr doc = FindDocument (filename); // If it's not loaded, try open it if (not doc) - doc = openDocument (filename, true, true); + doc = OpenDocument (filename, true, true); return doc; } // ============================================================================= // -void reloadAllSubfiles() +void ReloadAllSubfiles() { - if (not getCurrentDocument()) + if (not CurrentDocument()) return; // Go through all objects in the current file and reload the subfiles - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (obj->type() == OBJ_Subfile) { LDSubfilePtr ref = obj.staticCast<LDSubfile>(); - LDDocumentPtr fileInfo = getDocument (ref->fileInfo()->name()); + LDDocumentPtr fileInfo = GetDocument (ref->fileInfo()->name()); if (fileInfo) ref->setFileInfo (fileInfo); else - ref->replace (spawn<LDError> (ref->asText(), format ("Could not open %1", ref->fileInfo()->name()))); + ref->replace (LDSpawn<LDError> (ref->asText(), format ("Could not open %1", ref->fileInfo()->name()))); } // Reparse gibberish files. It could be that they are invalid because // of loading errors. Circumstances may be different now. if (obj->type() == OBJ_Error) - obj->replace (parseLine (obj.staticCast<LDError>()->contents())); + obj->replace (ParseLine (obj.staticCast<LDError>()->contents())); } } @@ -1156,10 +1156,10 @@ // void LDDocument::addKnownVertices (LDObjectPtr obj) { - auto it = _objectVertices.find (obj); + auto it = m_objectVertices.find (obj); - if (it == _objectVertices.end()) - it = _objectVertices.insert (obj, QVector<Vertex>()); + if (it == m_objectVertices.end()) + it = m_objectVertices.insert (obj, QVector<Vertex>()); else it->clear(); @@ -1178,7 +1178,7 @@ if (not isImplicit() and not (flags() & DOCF_IsBeingDestroyed)) { history()->add (new DelHistory (idx, obj)); - _objectVertices.remove (obj); + m_objectVertices.remove (obj); } m_objects.removeAt (idx); @@ -1187,7 +1187,7 @@ // ============================================================================= // -bool safeToCloseAll() +bool IsSafeToCloseAll() { for (LDDocumentPtr f : LDDocument::explicitDocuments()) { @@ -1212,7 +1212,7 @@ *m_history << new EditHistory (idx, oldcode, newcode); } - _objectVertices.remove (m_objects[idx]); + m_objectVertices.remove (m_objects[idx]); m_objects[idx]->deselect(); m_objects[idx]->setDocument (LDDocumentPtr()); obj->setDocument (self()); @@ -1265,7 +1265,7 @@ { if (m_needsReCache) { - _vertices.clear(); + m_vertices.clear(); for (LDObjectPtr obj : inlineContents (true, true)) { @@ -1282,18 +1282,18 @@ m_needsReCache = false; } - if (_verticesOutdated) + if (m_verticesOutdated) { - _objectVertices.clear(); + m_objectVertices.clear(); for (LDObjectPtr obj : inlineContents (true, false)) addKnownVertices (obj); mergeVertices(); - _verticesOutdated = false; + m_verticesOutdated = false; } - if (_needVertexMerge) + if (m_needVertexMerge) mergeVertices(); } @@ -1301,13 +1301,13 @@ // void LDDocument::mergeVertices() { - _vertices.clear(); + m_vertices.clear(); - for (QVector<Vertex> const& verts : _objectVertices) - _vertices << verts; + for (QVector<Vertex> const& verts : m_objectVertices) + m_vertices << verts; - removeDuplicates (_vertices); - _needVertexMerge = false; + RemoveDuplicates (m_vertices); + m_needVertexMerge = false; } // ============================================================================= @@ -1328,7 +1328,7 @@ if (cfg::UseLogoStuds and renderinline) { // Ensure logoed studs are loaded first - loadLogoedStuds(); + LoadLogoStuds(); if (name() == "stud.dat" and g_logoedStud != null) return g_logoedStud->inlineContents (deep, renderinline); @@ -1416,13 +1416,13 @@ // ============================================================================= // -void loadLogoedStuds() +void LoadLogoStuds() { if (g_logoedStud and g_logoedStud2) return; - g_logoedStud = openDocument ("stud-logo.dat", true, true); - g_logoedStud2 = openDocument ("stud2-logo.dat", true, true); + g_logoedStud = OpenDocument ("stud-logo.dat", true, true); + g_logoedStud2 = OpenDocument ("stud2-logo.dat", true, true); print (LDDocument::tr ("Logoed studs loaded.\n")); } @@ -1486,8 +1486,8 @@ // QString LDDocument::shortenName (QString a) // [static] { - QString shortname = basename (a); - QString topdirname = basename (dirname (a)); + QString shortname = Basename (a); + QString topdirname = Basename (Dirname (a)); if (g_specialSubdirectories.contains (topdirname)) shortname.prepend (topdirname + "\\"); @@ -1500,15 +1500,15 @@ QVector<Vertex> const& LDDocument::inlineVertices() { initializeCachedData(); - return _vertices; + return m_vertices; } void LDDocument::redoVertices() { - _verticesOutdated = true; + m_verticesOutdated = true; } void LDDocument::needVertexMerge() { - _needVertexMerge = true; + m_needVertexMerge = true; }
--- a/src/ldDocument.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ldDocument.h Wed Aug 06 16:18:24 2014 +0300 @@ -76,10 +76,10 @@ PROPERTY (private, LDDocumentFlags, flags, setFlags, STOCK_WRITE) PROPERTY (private, LDDocumentWeakPtr, self, setSelf, STOCK_WRITE) - QMap<LDObjectPtr, QVector<Vertex>> _objectVertices; - QVector<Vertex> _vertices; - bool _verticesOutdated; - bool _needVertexMerge; + QMap<LDObjectPtr, QVector<Vertex>> m_objectVertices; + QVector<Vertex> m_vertices; + bool m_verticesOutdated; + bool m_needVertexMerge; public: LDDocument(LDDocumentPtr* selfptr); @@ -177,7 +177,7 @@ bool m_needsReCache; }; -inline LDDocumentPtr getCurrentDocument() +inline LDDocumentPtr CurrentDocument() { return LDDocument::current(); } @@ -186,45 +186,45 @@ void newFile(); // Opens the given file as the main file. Everything is closed first. -void openMainFile (QString path); +void OpenMainModel (QString path); // Finds an OpenFile by name or null if not open -LDDocumentPtr findDocument (QString name); +LDDocumentPtr FindDocument (QString name); // Opens the given file and parses the LDraw code within. Returns a pointer // to the opened file or null on error. -LDDocumentPtr openDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride = LDDocumentPtr()); +LDDocumentPtr OpenDocument (QString path, bool search, bool implicit, LDDocumentPtr fileToOverride = LDDocumentPtr()); // Opens the given file and returns a pointer to it, potentially looking in /parts and /p -QFile* openLDrawFile (QString relpath, bool subdirs, QString* pathpointer = null); +QFile* OpenLDrawFile (QString relpath, bool subdirs, QString* pathpointer = null); // Close all open files, whether user-opened or subfile caches. -void closeAll(); +void CloseAllDocuments(); // Parses a string line containing an LDraw object and returns the object parsed. -LDObjectPtr parseLine (QString line); +LDObjectPtr ParseLine (QString line); // Retrieves the pointer to the given document by file name. Document is loaded // from file if necessary. Can return null if neither succeeds. -LDDocumentPtr getDocument (QString filename); +LDDocumentPtr GetDocument (QString filename); // Re-caches all subfiles. -void reloadAllSubfiles(); +void ReloadAllSubfiles(); // Is it safe to close all files? -bool safeToCloseAll(); +bool IsSafeToCloseAll(); -LDObjectList loadFileContents (QFile* f, int* numWarnings, bool* ok = null); +LDObjectList LoadFileContents (QFile* f, int* numWarnings, bool* ok = null); -inline const LDObjectList& selection() +inline const LDObjectList& Selection() { - return getCurrentDocument()->getSelection(); + return CurrentDocument()->getSelection(); } -void addRecentFile (QString path); -void loadLogoedStuds(); -QString basename (QString path); -QString dirname (QString path); +void AddRecentFile (QString path); +void LoadLogoStuds(); +QString Basename (QString path); +QString Dirname (QString path); // ============================================================================= //
--- a/src/ldObject.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ldObject.cc Wed Aug 06 16:18:24 2014 +0300 @@ -86,9 +86,9 @@ // In case someone does, we cannot really continue execution. We must abort, // give the user a chance to save their documents though. - critical ("Created too many objects. Execution cannot continue. You have a " + CriticalError ("Created too many objects. Execution cannot continue. You have a " "chance to save any changes to documents, then restart."); - (void) safeToCloseAll(); + (void) IsSafeToCloseAll(); Exit(); } @@ -220,8 +220,8 @@ // | | ==> | / / | // | | |/ / | // 1---2 1 1---2 - LDTrianglePtr tri1 (spawn<LDTriangle> (vertex (0), vertex (1), vertex (3))); - LDTrianglePtr tri2 (spawn<LDTriangle> (vertex (1), vertex (2), vertex (3))); + LDTrianglePtr tri1 (LDSpawn<LDTriangle> (vertex (0), vertex (1), vertex (3))); + LDTrianglePtr tri2 (LDSpawn<LDTriangle> (vertex (1), vertex (2), vertex (3))); // The triangles also inherit the quad's color tri1->setColor (color()); @@ -337,7 +337,7 @@ // ============================================================================= // -static void transformObject (LDObjectPtr obj, Matrix transform, Vertex pos, LDColor parentcolor) +static void TransformObject (LDObjectPtr obj, Matrix transform, Vertex pos, LDColor parentcolor) { switch (obj->type()) { @@ -345,7 +345,6 @@ case OBJ_CondLine: case OBJ_Triangle: case OBJ_Quad: - for (int i = 0; i < obj->numVertices(); ++i) { Vertex v = obj->vertex (i); @@ -363,14 +362,14 @@ newpos.transform (transform, pos); ref->setPosition (newpos); ref->setTransform (newMatrix); + break; } - break; default: break; } - if (obj->color() == maincolor()) + if (obj->color() == MainColor()) obj->setColor (parentcolor); } @@ -385,7 +384,7 @@ { // Set the parent now so we know what inlined the object. obj->setParent (self()); - transformObject (obj, transform(), position(), color()); + TransformObject (obj, transform(), position(), color()); } return objs; @@ -482,7 +481,7 @@ obj->swap (file->getObject (target)); } - removeDuplicates (objsToCompile); + RemoveDuplicates (objsToCompile); // The objects need to be recompiled, otherwise their pick lists are left with // the wrong index colors which messes up selection. @@ -522,7 +521,7 @@ if (not text.isEmpty()) text += ", "; - QString noun = format ("%1%2", typeName (objType), plural (count)); + QString noun = format ("%1%2", typeName (objType), Plural (count)); // Plural of "vertex" is "vertices", correct that if (objType == OBJ_Vertex and count != 1) @@ -618,17 +617,17 @@ { switch (type) { - case OBJ_Comment: return spawn<LDComment>(); - case OBJ_BFC: return spawn<LDBFC>(); - case OBJ_Line: return spawn<LDLine>(); - case OBJ_CondLine: return spawn<LDCondLine>(); - case OBJ_Subfile: return spawn<LDSubfile>(); - case OBJ_Triangle: return spawn<LDTriangle>(); - case OBJ_Quad: return spawn<LDQuad>(); - case OBJ_Empty: return spawn<LDEmpty>(); - case OBJ_Error: return spawn<LDError>(); - case OBJ_Vertex: return spawn<LDVertex>(); - case OBJ_Overlay: return spawn<LDOverlay>(); + case OBJ_Comment: return LDSpawn<LDComment>(); + case OBJ_BFC: return LDSpawn<LDBFC>(); + case OBJ_Line: return LDSpawn<LDLine>(); + case OBJ_CondLine: return LDSpawn<LDCondLine>(); + case OBJ_Subfile: return LDSpawn<LDSubfile>(); + case OBJ_Triangle: return LDSpawn<LDTriangle>(); + case OBJ_Quad: return LDSpawn<LDQuad>(); + case OBJ_Empty: return LDSpawn<LDEmpty>(); + case OBJ_Error: return LDSpawn<LDError>(); + case OBJ_Vertex: return LDSpawn<LDVertex>(); + case OBJ_Overlay: return LDSpawn<LDOverlay>(); case OBJ_NumTypes: assert (false); } return LDObjectPtr(); @@ -702,7 +701,7 @@ { // Subfile has all vertices zero on one specific plane, so it is flat. // Let's flip it. - Matrix matrixModifier = g_identity; + Matrix matrixModifier = IdentityMatrix; if (axisSet & (1 << X)) matrixModifier[0] = -1; @@ -733,7 +732,7 @@ } // Not inverted, thus prefix it with a new invertnext. - document().toStrongRef()->insertObj (idx, spawn<LDBFC> (BFCStatement::InvertNext)); + document().toStrongRef()->insertObj (idx, LDSpawn<LDBFC> (BFCStatement::InvertNext)); } // ============================================================================= @@ -763,7 +762,7 @@ // LDLinePtr LDCondLine::toEdgeLine() { - LDLinePtr replacement (spawn<LDLine>()); + LDLinePtr replacement (LDSpawn<LDLine>()); for (int i = 0; i < replacement->numVertices(); ++i) replacement->setVertex (i, vertex (i)); @@ -820,7 +819,7 @@ { obj->document().toStrongRef()->addToHistory (new EditHistory (idx, before, after)); g_win->R()->compileObject (obj); - getCurrentDocument()->redoVertices(); + CurrentDocument()->redoVertices(); } } else @@ -901,7 +900,7 @@ // LDObjectPtr LDObject::createCopy() const { - LDObjectPtr copy = parseLine (asText()); + LDObjectPtr copy = ParseLine (asText()); return copy; }
--- a/src/ldObject.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ldObject.h Wed Aug 06 16:18:24 2014 +0300 @@ -40,7 +40,7 @@ #define LDOBJ_VERTICES(V) public: virtual int numVertices() const override { return V; } #define LDOBJ_SETCOLORED(V) public: virtual bool isColored() const override { return V; } #define LDOBJ_COLORED LDOBJ_SETCOLORED (true) -#define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) LDOBJ_DEFAULTCOLOR (maincolor()) +#define LDOBJ_UNCOLORED LDOBJ_SETCOLORED (false) LDOBJ_DEFAULTCOLOR (MainColor()) #define LDOBJ_DEFAULTCOLOR(V) public: virtual LDColor defaultColor() const override { return (V); } #define LDOBJ_CUSTOM_SCEMANTIC public: virtual bool isScemantic() const override @@ -218,13 +218,14 @@ // deleter so that all deletions go through finalDelete(); // template<typename T, typename... Args> -inline QSharedPointer<T> spawn (Args... args) +inline QSharedPointer<T> LDSpawn (Args... args) { - static_assert (std::is_base_of<LDObject, T>::value, "spawn may only be used with LDObject-derivatives"); + static_assert (std::is_base_of<LDObject, T>::value, + "spawn may only be used with LDObject-derivatives"); LDObjectPtr ptr; new T (&ptr, args...); - // Set default color. This cannot be done in the c-tor. + // Set default color. Relying on virtual functions, this cannot be done in the c-tor. if (ptr->isColored()) ptr->setColor (ptr->defaultColor()); @@ -259,7 +260,7 @@ public: LDMatrixObject (LDObjectPtr* selfptr) : LDObject (selfptr), - m_position (g_origin) {} + m_position (Origin) {} LDMatrixObject (LDObjectPtr* selfptr, const Matrix& transform, const Vertex& pos) : LDObject (selfptr), @@ -414,7 +415,7 @@ LDOBJ_NAME (subfile) LDOBJ_VERTICES (0) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (maincolor()) + LDOBJ_DEFAULTCOLOR (MainColor()) LDOBJ_SCEMANTIC LDOBJ_HAS_MATRIX PROPERTY (public, LDDocumentPtr, fileInfo, setFileInfo, CUSTOM_WRITE) @@ -451,7 +452,7 @@ LDOBJ_NAME (line) LDOBJ_VERTICES (2) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (edgecolor()) + LDOBJ_DEFAULTCOLOR (EdgeColor()) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX @@ -473,7 +474,7 @@ LDOBJ_NAME (condline) LDOBJ_VERTICES (4) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (edgecolor()) + LDOBJ_DEFAULTCOLOR (EdgeColor()) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX @@ -499,7 +500,7 @@ LDOBJ_NAME (triangle) LDOBJ_VERTICES (3) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (maincolor()) + LDOBJ_DEFAULTCOLOR (MainColor()) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX @@ -523,7 +524,7 @@ LDOBJ_NAME (quad) LDOBJ_VERTICES (4) LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (maincolor()) + LDOBJ_DEFAULTCOLOR (MainColor()) LDOBJ_SCEMANTIC LDOBJ_NO_MATRIX @@ -552,7 +553,7 @@ LDOBJ_NAME (vertex) LDOBJ_VERTICES (0) // TODO: move pos to m_vertices[0] LDOBJ_COLORED - LDOBJ_DEFAULTCOLOR (maincolor()) + LDOBJ_DEFAULTCOLOR (MainColor()) LDOBJ_NON_SCEMANTIC LDOBJ_NO_MATRIX @@ -583,7 +584,7 @@ PROPERTY (public, int, y, setY, STOCK_WRITE) PROPERTY (public, int, width, setWidth, STOCK_WRITE) PROPERTY (public, int, height, setHeight, STOCK_WRITE) - PROPERTY (public, QString, fileName, setFileName, STOCK_WRITE) + PROPERTY (public, QString, fileName, setFileName, STOCK_WRITE) }; using LDOverlayPtr = QSharedPointer<LDOverlay>; @@ -592,8 +593,12 @@ // Other common LDraw stuff static const QString CALicenseText ("!LICENSE Redistributable under CCAL version 2.0 : " "see CAreadme.txt"); -static const int LowResolution = 16; -static const int HighResolution = 48; + +enum +{ + LowResolution = 16, + HighResolution = 48 +}; QString PreferredLicenseText();
--- a/src/main.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/main.cc Wed Aug 06 16:18:24 2014 +0300 @@ -38,8 +38,8 @@ static QString g_versionString, g_fullVersionString; static bool g_IsExiting (false); -const Vertex g_origin (0.0f, 0.0f, 0.0f); -const Matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); +const Vertex Origin (0.0f, 0.0f, 0.0f); +const Matrix IdentityMatrix ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); CFGENTRY (Bool, FirstStart, true) @@ -61,12 +61,12 @@ if (Config::Save()) print ("Configuration file successfully created.\n"); else - critical ("Failed to create configuration file!\n"); + CriticalError ("Failed to create configuration file!\n"); } LDPaths::initPaths(); - initColors(); - loadPrimitives(); + InitColors(); + LoadPrimitives(); MainWindow* win = new MainWindow; newFile(); win->show();
--- a/src/main.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/main.h Wed Aug 06 16:18:24 2014 +0300 @@ -35,6 +35,6 @@ // Null pointer static const std::nullptr_t null = nullptr; -void assertionFailure (const char* file, int line, const char* funcname, const char* expr); +void HandleAssertFailure (const char* file, int line, const char* funcname, const char* expr); bool IsExiting(); void Exit();
--- a/src/mainWindow.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/mainWindow.cc Wed Aug 06 16:18:24 2014 +0300 @@ -93,15 +93,15 @@ connect (m_tabs, SIGNAL (currentChanged(int)), this, SLOT (changeCurrentFile())); connect (m_tabs, SIGNAL (tabCloseRequested (int)), this, SLOT (closeTab (int))); - if (getActivePrimitiveScanner() != null) - connect (getActivePrimitiveScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives())); + if (ActivePrimitiveScanner() != null) + connect (ActivePrimitiveScanner(), SIGNAL (workDone()), this, SLOT (updatePrimitives())); else updatePrimitives(); m_msglog = new MessageManager; m_msglog->setRenderer (R()); m_renderer->setMessageLog (m_msglog); - m_quickColors = quickColorsFromConfig(); + m_quickColors = LoadQuickColorList(); slot_selectionChanged(); setStatusBar (new QStatusBar); updateActions(); @@ -144,11 +144,11 @@ void MainWindow::endAction() { // Add a step in the history now. - getCurrentDocument()->addHistoryStep(); + CurrentDocument()->addHistoryStep(); // Update the list item of the current file - we may need to draw an icon // now that marks it as having unsaved changes. - updateDocumentListItem (getCurrentDocument()); + updateDocumentListItem (CurrentDocument()); } // ============================================================================= @@ -174,7 +174,7 @@ for (const QVariant& it : cfg::RecentFiles) { QString file = it.toString(); - QAction* recent = new QAction (getIcon ("open-recent"), file, this); + QAction* recent = new QAction (GetIcon ("open-recent"), file, this); connect (recent, SIGNAL (triggered()), this, SLOT (slot_recentFile())); ui->menuOpenRecent->insertAction (first, recent); @@ -185,7 +185,7 @@ // ============================================================================= // -QList<LDQuickColor> quickColorsFromConfig() +QList<LDQuickColor> LoadQuickColorList() { QList<LDQuickColor> colors; @@ -221,7 +221,7 @@ else { QToolButton* colorButton = new QToolButton; - colorButton->setIcon (makeColorIcon (entry.color(), 16)); + colorButton->setIcon (MakeColorIcon (entry.color(), 16)); colorButton->setIconSize (QSize (16, 16)); colorButton->setToolTip (entry.color().name()); @@ -250,23 +250,23 @@ // void MainWindow::updateTitle() { - QString title = format (APPNAME " %1", versionString()); + QString title = format (APPNAME " %1", VersionString()); // Append our current file if we have one - if (getCurrentDocument()) + if (CurrentDocument()) { title += ": "; - title += getCurrentDocument()->getDisplayName(); + title += CurrentDocument()->getDisplayName(); - if (getCurrentDocument()->getObjectCount() > 0 and - getCurrentDocument()->getObject (0)->type() == OBJ_Comment) + if (CurrentDocument()->getObjectCount() > 0 and + CurrentDocument()->getObject (0)->type() == OBJ_Comment) { // Append title - LDCommentPtr comm = getCurrentDocument()->getObject (0).staticCast<LDComment>(); + LDCommentPtr comm = CurrentDocument()->getObject (0).staticCast<LDComment>(); title += format (": %1", comm->text()); } - if (getCurrentDocument()->hasUnsavedChanges()) + if (CurrentDocument()->hasUnsavedChanges()) title += '*'; } @@ -276,8 +276,8 @@ title += " [pre-release build]"; #endif // DEBUG - if (commitTimeString()[0] != '\0') - title += format (" (%1)", QString::fromUtf8 (commitTimeString())); + if (CommitTimeString()[0] != '\0') + title += format (" (%1)", QString::fromUtf8 (CommitTimeString())); setWindowTitle (title); } @@ -286,10 +286,10 @@ // int MainWindow::deleteSelection() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return 0; - LDObjectList selCopy = selection(); + LDObjectList selCopy = Selection(); // Delete the objects that were being selected for (LDObjectPtr obj : selCopy) @@ -303,7 +303,7 @@ // void MainWindow::buildObjList() { - if (not getCurrentDocument()) + if (not CurrentDocument()) return; // Lock the selection while we do this so that refreshing the object list @@ -316,7 +316,7 @@ ui->objectList->clear(); - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { QString descr; @@ -386,7 +386,7 @@ { LDOverlayPtr ovl = obj.staticCast<LDOverlay>(); descr = format ("[%1] %2 (%3, %4), %5 x %6", g_CameraNames[ovl->camera()], - basename (ovl->fileName()), ovl->x(), ovl->y(), + Basename (ovl->fileName()), ovl->x(), ovl->y(), ovl->width(), ovl->height()); break; } @@ -399,7 +399,7 @@ } QListWidgetItem* item = new QListWidgetItem (descr); - item->setIcon (getIcon (obj->typeName())); + item->setIcon (GetIcon (obj->typeName())); // Use italic font if hidden if (obj->isHidden()) @@ -416,7 +416,7 @@ item->setForeground (QColor ("#FFAA00")); } elif (cfg::ColorizeObjectsList and obj->isColored() and - obj->color() != null and obj->color() != maincolor() and obj->color() != edgecolor()) + obj->color() != null and obj->color() != MainColor() and obj->color() != EdgeColor()) { // If the object isn't in the main or edge color, draw this // list entry in said color. @@ -436,10 +436,10 @@ // void MainWindow::scrollToSelection() { - if (selection().isEmpty()) + if (Selection().isEmpty()) return; - LDObjectPtr obj = selection().last(); + LDObjectPtr obj = Selection().last(); ui->objectList->scrollToItem (obj->qObjListEntry); } @@ -447,16 +447,16 @@ // void MainWindow::slot_selectionChanged() { - if (g_isSelectionLocked == true or getCurrentDocument() == null) + if (g_isSelectionLocked == true or CurrentDocument() == null) return; - LDObjectList priorSelection = selection(); + LDObjectList priorSelection = Selection(); // Get the objects from the object list selection - getCurrentDocument()->clearSelection(); + CurrentDocument()->clearSelection(); const QList<QListWidgetItem*> items = ui->objectList->selectedItems(); - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { for (QListWidgetItem* item : items) { @@ -473,8 +473,8 @@ updateSelection(); // Update the GL renderer - LDObjectList compound = priorSelection + selection(); - removeDuplicates (compound); + LDObjectList compound = priorSelection + Selection(); + RemoveDuplicates (compound); for (LDObjectPtr obj : compound) R()->compileObject (obj); @@ -487,7 +487,7 @@ void MainWindow::slot_recentFile() { QAction* qAct = static_cast<QAction*> (sender()); - openMainFile (qAct->text()); + OpenMainModel (qAct->text()); } // ============================================================================= @@ -509,7 +509,7 @@ if (col == null) return; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (not obj->isColored()) continue; // uncolored object @@ -527,11 +527,11 @@ int MainWindow::getInsertionPoint() { // If we have a selection, put the item after it. - if (not selection().isEmpty()) - return selection().last()->lineNumber() + 1; + if (not Selection().isEmpty()) + return Selection().last()->lineNumber() + 1; // Otherwise place the object at the end. - return getCurrentDocument()->getObjectCount(); + return CurrentDocument()->getObjectCount(); } // ============================================================================= @@ -558,7 +558,7 @@ ui->objectList->clearSelection(); - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (obj->qObjListEntry == null) continue; @@ -575,7 +575,7 @@ { LDColor result; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (not obj->isColored()) continue; // doesn't use color @@ -595,7 +595,7 @@ void MainWindow::closeEvent (QCloseEvent* ev) { // Check whether it's safe to close all files. - if (not safeToCloseAll()) + if (not IsSafeToCloseAll()) { ev->ignore(); return; @@ -612,12 +612,12 @@ // void MainWindow::spawnContextMenu (const QPoint pos) { - const bool single = (selection().size() == 1); - LDObjectPtr singleObj = single ? selection().first() : LDObjectPtr(); + const bool single = (Selection().size() == 1); + LDObjectPtr singleObj = single ? Selection().first() : LDObjectPtr(); bool hasSubfiles = false; - for (LDObjectPtr obj : selection()) + for (LDObjectPtr obj : Selection()) { if (obj->type() == OBJ_Subfile) { @@ -659,7 +659,7 @@ contextMenu->addAction (ui->actionModeDraw); contextMenu->addAction (ui->actionModeCircle); - if (not selection().isEmpty()) + if (not Selection().isEmpty()) { contextMenu->addSeparator(); contextMenu->addAction (ui->actionSubfileSelection); @@ -680,7 +680,7 @@ { LDObjectList objs; - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (not obj->isColored() or obj->color() != color) continue; @@ -708,7 +708,7 @@ // void MainWindow::slot_editObject (QListWidgetItem* listitem) { - for (LDObjectPtr it : getCurrentDocument()->objects()) + for (LDObjectPtr it : CurrentDocument()->objects()) { if (it->qObjListEntry == listitem) { @@ -747,13 +747,13 @@ if (doc->save (path, &savesize)) { - if (doc == getCurrentDocument()) + if (doc == CurrentDocument()) updateTitle(); print ("Saved to %1 (%2)", path, MakePrettyFileSize (savesize)); // Add it to recent files - addRecentFile (path); + AddRecentFile (path); return true; } @@ -764,7 +764,7 @@ // Add a save-as button QPushButton* saveAsBtn = new QPushButton (tr ("Save As")); - saveAsBtn->setIcon (getIcon ("file-save-as")); + saveAsBtn->setIcon (GetIcon ("file-save-as")); dlg.addButton (saveAsBtn, QMessageBox::ActionRole); dlg.setDefaultButton (QMessageBox::Close); dlg.exec(); @@ -788,21 +788,21 @@ // ============================================================================= // -QPixmap getIcon (QString iconName) +QPixmap GetIcon (QString iconName) { return (QPixmap (format (":/icons/%1.png", iconName))); } // ============================================================================= // -bool confirm (const QString& message) +bool Confirm (const QString& message) { - return confirm (MainWindow::tr ("Confirm"), message); + return Confirm (MainWindow::tr ("Confirm"), message); } // ============================================================================= // -bool confirm (const QString& title, const QString& message) +bool Confirm (const QString& title, const QString& message) { return QMessageBox::question (g_win, title, message, (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes; @@ -810,7 +810,7 @@ // ============================================================================= // -void critical (const QString& message) +void CriticalError (const QString& message) { QMessageBox::critical (g_win, MainWindow::tr ("Error"), message, (QMessageBox::Close), QMessageBox::Close); @@ -818,14 +818,14 @@ // ============================================================================= // -QIcon makeColorIcon (LDColor colinfo, const int size) +QIcon MakeColorIcon (LDColor colinfo, const int size) { // Create an image object and link a painter to it. QImage img (size, size, QImage::Format_ARGB32); QPainter paint (&img); QColor col = colinfo.faceColor(); - if (colinfo == maincolor()) + if (colinfo == MainColor()) { // Use the user preferences for main color here col = cfg::MainColor; @@ -836,7 +836,7 @@ paint.fillRect (QRect (0, 0, size, size), colinfo.edgeColor()); // Paint the checkerboard background, visible with translucent icons - paint.drawPixmap (QRect (1, 1, size - 2, size - 2), getIcon ("checkerboard"), QRect (0, 0, 8, 8)); + paint.drawPixmap (QRect (1, 1, size - 2, size - 2), GetIcon ("checkerboard"), QRect (0, 0, 8, 8)); // Paint the color above the checkerboard paint.fillRect (QRect (1, 1, size - 2, size - 2), col); @@ -845,11 +845,11 @@ // ============================================================================= // -void makeColorComboBox (QComboBox* box) +void MakeColorComboBox (QComboBox* box) { std::map<LDColor, int> counts; - for (LDObjectPtr obj : getCurrentDocument()->objects()) + for (LDObjectPtr obj : CurrentDocument()->objects()) { if (not obj->isColored() or obj->color() == null) continue; @@ -865,9 +865,9 @@ for (const auto& pair : counts) { - QIcon ico = makeColorIcon (pair.first, 16); + QIcon ico = MakeColorIcon (pair.first, 16); box->addItem (ico, format ("[%1] %2 (%3 object%4)", - pair.first, pair.first.name(), pair.second, plural (pair.second))); + pair.first, pair.first.name(), pair.second, Plural (pair.second))); box->setItemData (row, pair.first.index()); ++row; @@ -911,13 +911,13 @@ // If this is the current file, it also needs to be the selected item on // the list. - if (doc == getCurrentDocument()) + if (doc == CurrentDocument()) m_tabs->setCurrentIndex (doc->tabIndex()); m_tabs->setTabText (doc->tabIndex(), doc->getDisplayName()); // If the document.has unsaved changes, draw a little icon next to it to mark that. - m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); + m_tabs->setTabIcon (doc->tabIndex(), doc->hasUnsavedChanges() ? GetIcon ("file-save") : QIcon()); m_tabs->setTabData (doc->tabIndex(), doc->name()); m_updatingTabs = oldUpdatingTabs; } @@ -947,7 +947,7 @@ // If we picked the same file we're currently on, we don't need to do // anything. - if (f == null or f == getCurrentDocument()) + if (f == null or f == CurrentDocument()) return; LDDocument::setCurrent (f); @@ -973,9 +973,9 @@ // void MainWindow::updateActions() { - if (getCurrentDocument() != null and getCurrentDocument()->history() != null) + if (CurrentDocument() != null and CurrentDocument()->history() != null) { - History* his = getCurrentDocument()->history(); + History* his = CurrentDocument()->history(); int pos = his->position(); ui->actionUndo->setEnabled (pos != -1); ui->actionRedo->setEnabled (pos < (long) his->getSize() - 1); @@ -995,14 +995,14 @@ // void MainWindow::updatePrimitives() { - populatePrimitives (ui->primitives); + PopulatePrimitives (ui->primitives); } // ============================================================================= // void MainWindow::closeTab (int tabindex) { - LDDocumentPtr doc = findDocument (m_tabs->tabData (tabindex).toString()); + LDDocumentPtr doc = FindDocument (m_tabs->tabData (tabindex).toString()); if (doc == null) return; @@ -1056,7 +1056,7 @@ // ============================================================================= // -QImage imageFromScreencap (uchar* data, int w, int h) +QImage GetImageFromScreencap (uchar* data, int w, int h) { // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); @@ -1082,7 +1082,7 @@ return color() == null; } -void populatePrimitives (QTreeWidget* tw, QString const& selectByDefault) +void PopulatePrimitives (QTreeWidget* tw, QString const& selectByDefault) { tw->clear();
--- a/src/mainWindow.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/mainWindow.h Wed Aug 06 16:18:24 2014 +0300 @@ -306,32 +306,32 @@ extern MainWindow* g_win; //! Get an icon by name from the resources directory. -QPixmap getIcon (QString iconName); +QPixmap GetIcon (QString iconName); //! \returns a list of quick colors based on the configuration entry. -QList<LDQuickColor> quickColorsFromConfig(); +QList<LDQuickColor> LoadQuickColorList(); //! Asks the user a yes/no question with the given \c message and the given //! window \c title. //! \returns true if the user answered yes, false if no. -bool confirm (const QString& title, const QString& message); // Generic confirm prompt +bool Confirm (const QString& title, const QString& message); // Generic confirm prompt //! An overload of \c confirm(), this asks the user a yes/no question with the //! given \c message. //! \returns true if the user answered yes, false if no. -bool confirm (const QString& message); +bool Confirm (const QString& message); //! Displays an error prompt with the given \c message -void critical (const QString& message); +void CriticalError (const QString& message); //! Makes an icon of \c size x \c size pixels to represent \c colinfo -QIcon makeColorIcon (LDColor colinfo, const int size); +QIcon MakeColorIcon (LDColor colinfo, const int size); //! Fills the given combo-box with color information -void makeColorComboBox (QComboBox* box); +void MakeColorComboBox (QComboBox* box); //! \returns a QImage from the given raw GL \c data -QImage imageFromScreencap (uchar* data, int w, int h); +QImage GetImageFromScreencap (uchar* data, int w, int h); //! //! Takes in pairs of radio buttons and respective values and finds the first @@ -340,11 +340,13 @@ //! \returns by the user. //! template<class T> -T radioSwitch (const T& defval, QList<Pair<QRadioButton*, T>> haystack) +T RadioSwitch (const T& defval, QList<Pair<QRadioButton*, T>> haystack) { for (Pair<QRadioButton*, const T&> i : haystack) + { if (i.first->isChecked()) return i.second; + } return defval; } @@ -354,7 +356,7 @@ //! found radio button whose respsective value matches \c expr have the given value. //! template<class T> -void radioDefault (const T& expr, QList<Pair<QRadioButton*, T>> haystack) +void RadioDefault (const T& expr, QList<Pair<QRadioButton*, T>> haystack) { for (Pair<QRadioButton*, const T&> i : haystack) { @@ -372,14 +374,14 @@ { PROPERTY (public, Primitive*, primitive, setPrimitive, STOCK_WRITE) - public: - SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : - QTreeWidgetItem (parent), - m_primitive (info) {} +public: + SubfileListItem (QTreeWidgetItem* parent, Primitive* info) : + QTreeWidgetItem (parent), + m_primitive (info) {} - SubfileListItem (QTreeWidget* parent, Primitive* info) : - QTreeWidgetItem (parent), - m_primitive (info) {} + SubfileListItem (QTreeWidget* parent, Primitive* info) : + QTreeWidgetItem (parent), + m_primitive (info) {} }; -void populatePrimitives (QTreeWidget* tw, const QString& selectByDefault = QString()); +void PopulatePrimitives (QTreeWidget* tw, const QString& selectByDefault = QString());
--- a/src/messageLog.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/messageLog.cc Wed Aug 06 16:18:24 2014 +0300 @@ -22,28 +22,31 @@ #include "glRenderer.h" #include "mainWindow.h" -static const int g_maxMessages = 5; -static const int g_expiry = 5; -static const int g_fadeTime = 500; // msecs +enum +{ + MaxMessages = 5, + ExpireTime = 5000, + FadeTime = 500 +}; -// ============================================================================= +// ------------------------------------------------------------------------------------------------- // MessageManager::MessageManager (QObject* parent) : - QObject (parent) + QObject (parent) { m_ticker = new QTimer; m_ticker->start (100); connect (m_ticker, SIGNAL (timeout()), this, SLOT (tick())); } -// ============================================================================= +// ------------------------------------------------------------------------------------------------- // MessageManager::Line::Line (QString text) : - text (text), - alpha (1.0f), - expiry (QDateTime::currentDateTime().addSecs (g_expiry)) {} + text (text), + alpha (1.0f), + expiry (QDateTime::currentDateTime().addMSecs (ExpireTime)) {} -// ============================================================================= +// ------------------------------------------------------------------------------------------------- // bool MessageManager::Line::update (bool& changed) { @@ -58,23 +61,24 @@ return false; } - if (msec <= g_fadeTime) + if (msec <= FadeTime) { // Message line has not expired but is fading out - alpha = ( (float) msec) / g_fadeTime; + alpha = ( (float) msec) / FadeTime; changed = true; } return true; } -// ============================================================================= -// Add a line to the message manager. +// ------------------------------------------------------------------------------------------------- +// +// Add a line to the message manager. // void MessageManager::addLine (QString line) { // If there's too many entries, pop the excess out - while (m_lines.size() >= g_maxMessages) + while (m_lines.size() >= MaxMessages) m_lines.removeFirst(); m_lines << Line (line); @@ -84,9 +88,10 @@ renderer()->update(); } -// ============================================================================= -// Ticks the message manager. All lines are ticked and the renderer scene is -// redrawn if something changed. +// ------------------------------------------------------------------------------------------------- +// +// Ticks the message manager. All lines are ticked and the renderer scene is redrawn if something +// changed. // void MessageManager::tick() { @@ -118,7 +123,7 @@ // ============================================================================= // -void printToLog (const QString& msg) +void PrintToLog (const QString& msg) { for (QString& a : msg.split ("\n", QString::SkipEmptyParts)) {
--- a/src/miscallenous.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/miscallenous.cc Wed Aug 06 16:18:24 2014 +0300 @@ -107,7 +107,7 @@ CFGENTRY (Float, GridFineCoordinateSnap, 0.1f) CFGENTRY (Float, GridFineAngleSnap, 7.5f) CFGENTRY (Int, RotationPointType, 0) -CFGENTRY (Vertex, CustomRotationPoint, g_origin) +CFGENTRY (Vertex, CustomRotationPoint, Origin) const GridData Grids[3] = { @@ -120,13 +120,13 @@ // // Snap the given coordinate value on the current grid's given axis. // -double Grid::snap (double value, const Grid::Config type) +double Grid::Snap (double value, const Grid::Config type) { double snapvalue = (type == Coordinate) ? *CurrentGrid().coordinateSnap : *CurrentGrid().angleSnap; - double mult = floor (abs<double> (value / snapvalue)); + double mult = floor (Abs<double> (value / snapvalue)); double out = mult * snapvalue; - if (abs (value) - (mult * snapvalue) > snapvalue / 2) + if (Abs (value) - (mult * snapvalue) > snapvalue / 2) out += snapvalue; if (value < 0) @@ -137,7 +137,7 @@ // ============================================================================= // -void simplify (int& numer, int& denom) +void Simplify (int& numer, int& denom) { bool repeat; @@ -186,7 +186,7 @@ } case RotationPoint::WorldOrigin: - return g_origin; + return Origin; case RotationPoint::CustomPoint: return cfg::CustomRotationPoint; @@ -261,7 +261,7 @@ // ============================================================================= // -void applyToMatrix (Matrix& a, ApplyToMatrixFunction func) +void ApplyToMatrix (Matrix& a, ApplyToMatrixFunction func) { for (int i = 0; i < 9; ++i) func (i, a[i]); @@ -269,7 +269,7 @@ // ============================================================================= // -void applyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func) +void ApplyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func) { for (int i = 0; i < 9; ++i) func (i, a[i]);
--- a/src/miscallenous.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/miscallenous.h Wed Aug 06 16:18:24 2014 +0300 @@ -33,14 +33,14 @@ extern const int PrimeNumbers[NUM_PRIMES]; // Simplifies the given fraction. -void simplify (int& numer, int& denom); +void Simplify (int& numer, int& denom); using ApplyToMatrixFunction = std::function<void (int, double&)>; using ApplyToMatrixConstFunction = std::function<void (int, double)>; void RoundToDecimals (double& a, int decimals); -void applyToMatrix (Matrix& a, ApplyToMatrixFunction func); -void applyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func); +void ApplyToMatrix (Matrix& a, ApplyToMatrixFunction func); +void ApplyToMatrix (const Matrix& a, ApplyToMatrixConstFunction func); double GetCoordinateOf (const Vertex& a, Axis ax); QString MakePrettyFileSize (qint64 size); @@ -91,5 +91,5 @@ Angle }; - double snap (double value, const Grid::Config type); + double Snap (double value, const Grid::Config type); }
--- a/src/partDownloader.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/partDownloader.cc Wed Aug 06 16:18:24 2014 +0300 @@ -44,7 +44,7 @@ if (path.isEmpty() or not QDir (path).exists()) { - critical (PartDownloader::tr ("You need to specify a valid path for " + CriticalError (PartDownloader::tr ("You need to specify a valid path for " "downloaded files in the configuration to download paths.")); (new ConfigDialog (ConfigDialog::DownloadTab, null))->exec(); @@ -146,12 +146,12 @@ // If the part starts with s\ or s/, then use parts/s/. Same goes with // 48\ and p/48/. - if (eq (dest.left (2), "s\\", "s/")) + if (Eq (dest.left (2), "s\\", "s/")) { dest.remove (0, 2); dest.prepend ("parts/s/"); } - elif (eq (dest.left (3), "48\\", "48/")) + elif (Eq (dest.left (3), "48\\", "48/")) { dest.remove (0, 3); dest.prepend ("p/48/"); @@ -223,14 +223,14 @@ setAborted (false); if (getSource() == CustomURL) - dest = basename (getURL()); + dest = Basename (getURL()); modifyDestination (dest); if (QFile::exists (PartDownloader::getDownloadPath() + DIRSLASH + dest)) { const QString overwritemsg = format (tr ("%1 already exists in download directory. Overwrite?"), dest); - if (not confirm (tr ("Overwrite?"), overwritemsg)) + if (not Confirm (tr ("Overwrite?"), overwritemsg)) return; } @@ -289,7 +289,7 @@ if (primaryFile() != null) { LDDocument::setCurrent (primaryFile()); - reloadAllSubfiles(); + ReloadAllSubfiles(); g_win->doFullRefresh(); g_win->R()->resetAngles(); } @@ -341,7 +341,7 @@ m_filePointer (null) { // Make sure that we have a valid destination. - QString dirpath = dirname (filePath()); + QString dirpath = Dirname (filePath()); QDir dir (dirpath); @@ -350,7 +350,7 @@ print ("Creating %1...\n", dirpath); if (not dir.mkpath (dirpath)) - critical (format (tr ("Couldn't create the directory %1!"), dirpath)); + CriticalError (format (tr ("Couldn't create the directory %1!"), dirpath)); } setNetworkReply (networkManager()->get (QNetworkRequest (QUrl (url)))); @@ -425,7 +425,7 @@ if (networkReply()->error() != QNetworkReply::NoError) { if (isPrimary() and not prompt()->isAborted()) - critical (networkReply()->errorString()); + CriticalError (networkReply()->errorString()); setState (DLRQ_Failed); } @@ -452,7 +452,7 @@ } // Try to load this file now. - LDDocumentPtr f = openDocument (filePath(), false, not isPrimary()); + LDDocumentPtr f = OpenDocument (filePath(), false, not isPrimary()); if (f == null) return; @@ -475,7 +475,7 @@ if (isPrimary()) { - addRecentFile (filePath()); + AddRecentFile (filePath()); prompt()->setPrimaryFile (f); } @@ -509,7 +509,7 @@ if (not filePointer()->open (QIODevice::WriteOnly)) { - critical (format (tr ("Couldn't open %1 for writing: %2"), filePath(), strerror (errno))); + CriticalError (format (tr ("Couldn't open %1 for writing: %2"), filePath(), strerror (errno))); setState (DLRQ_Failed); networkReply()->abort(); updateToTable(); @@ -525,7 +525,7 @@ // bool PartDownloadRequest::isFinished() const { - return eq (state(), DLRQ_Finished, DLRQ_Failed); + return Eq (state(), DLRQ_Finished, DLRQ_Failed); } // =============================================================================
--- a/src/primitives.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/primitives.cc Wed Aug 06 16:18:24 2014 +0300 @@ -45,14 +45,14 @@ "con" }; -PrimitiveScanner* getActivePrimitiveScanner() +PrimitiveScanner* ActivePrimitiveScanner() { return g_activeScanner; } // ============================================================================= // -void loadPrimitives() +void LoadPrimitives() { // Try to load prims.cfg QFile conf (Config::FilePath ("prims.cfg")); @@ -92,14 +92,14 @@ // ============================================================================= // -static void recursiveGetFilenames (QDir dir, QList<QString>& fnames) +static void GetRecursiveFilenames (QDir dir, QList<QString>& fnames) { QFileInfoList flist = dir.entryInfoList (QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); for (const QFileInfo& info : flist) { if (info.isDir()) - recursiveGetFilenames (QDir (info.absoluteFilePath()), fnames); + GetRecursiveFilenames (QDir (info.absoluteFilePath()), fnames); else fnames << info.absoluteFilePath(); } @@ -115,7 +115,7 @@ QDir dir (LDPaths::prims()); assert (dir.exists()); m_baselen = dir.absolutePath().length(); - recursiveGetFilenames (dir, m_files); + GetRecursiveFilenames (dir, m_files); emit starting (m_files.size()); print ("Scanning primitives..."); } @@ -131,7 +131,7 @@ // void PrimitiveScanner::work() { - int j = min (m_i + 100, m_files.size()); + int j = Min (m_i + 100, m_files.size()); for (; m_i < j; ++m_i) { @@ -168,7 +168,7 @@ QFile conf (path); if (not conf.open (QIODevice::WriteOnly | QIODevice::Text)) - critical (format ("Couldn't write primitive list %1: %2", + CriticalError (format ("Couldn't write primitive list %1: %2", path, conf.errorString())); else { @@ -292,7 +292,7 @@ if (not f.open (QIODevice::ReadOnly)) { - critical (format (QObject::tr ("Failed to open primitive categories: %1"), f.errorString())); + CriticalError (format (QObject::tr ("Failed to open primitive categories: %1"), f.errorString())); return; } @@ -366,28 +366,28 @@ // ============================================================================= // -bool isPrimitiveLoaderBusy() +bool IsPrimitiveLoaderBusy() { return g_activeScanner != null; } // ============================================================================= // -static double radialPoint (int i, int divs, double (*func) (double)) +static double GetRadialPoint (int i, int divs, double (*func) (double)) { - return (*func) ((i * 2 * pi) / divs); + return (*func) ((i * 2 * Pi) / divs); } // ============================================================================= // -void makeCircle (int segs, int divs, double radius, QList<QLineF>& lines) +void MakeCircle (int segs, int divs, double radius, QList<QLineF>& lines) { for (int i = 0; i < segs; ++i) { - double x0 = radius * radialPoint (i, divs, cos), - x1 = radius * radialPoint (i + 1, divs, cos), - z0 = radius * radialPoint (i, divs, sin), - z1 = radius * radialPoint (i + 1, divs, sin); + double x0 = radius * GetRadialPoint (i, divs, cos), + x1 = radius * GetRadialPoint (i + 1, divs, cos), + z0 = radius * GetRadialPoint (i, divs, sin), + z1 = radius * GetRadialPoint (i + 1, divs, sin); lines << QLineF (QPointF (x0, z0), QPointF (x1, z1)); } @@ -395,13 +395,13 @@ // ============================================================================= // -LDObjectList makePrimitive (PrimitiveType type, int segs, int divs, int num) +LDObjectList MakePrimitive (PrimitiveType type, int segs, int divs, int num) { LDObjectList objs; QList<int> condLineSegs; QList<QLineF> circle; - makeCircle (segs, divs, 1, circle); + MakeCircle (segs, divs, 1, circle); for (int i = 0; i < segs; ++i) { @@ -417,10 +417,10 @@ Vertex v0 (x0, 0.0f, z0), v1 (x1, 0.0f, z1); - LDLinePtr line (spawn<LDLine>()); + LDLinePtr line (LDSpawn<LDLine>()); line->setVertex (0, v0); line->setVertex (1, v1); - line->setColor (edgecolor()); + line->setColor (EdgeColor()); objs << line; } break; @@ -467,8 +467,8 @@ v2 (x2, y2, z2), v3 (x3, y3, z3); - LDQuadPtr quad (spawn<LDQuad> (v0, v1, v2, v3)); - quad->setColor (maincolor()); + LDQuadPtr quad (LDSpawn<LDQuad> (v0, v1, v2, v3)); + quad->setColor (MainColor()); if (type == Cylinder) quad->invert(); @@ -498,8 +498,8 @@ // Disc negatives need to go the other way around, otherwise // they'll end up upside-down. - LDTrianglePtr seg (spawn<LDTriangle>()); - seg->setColor (maincolor()); + LDTrianglePtr seg (LDSpawn<LDTriangle>()); + seg->setColor (MainColor()); seg->setVertex (type == Disc ? 0 : 2, v0); seg->setVertex (1, v1); seg->setVertex (type == Disc ? 2 : 0, v2); @@ -515,10 +515,10 @@ for (int i : condLineSegs) { - Vertex v0 (radialPoint (i, divs, cos), 0.0f, radialPoint (i, divs, sin)), + Vertex v0 (GetRadialPoint (i, divs, cos), 0.0f, GetRadialPoint (i, divs, sin)), v1, - v2 (radialPoint (i + 1, divs, cos), 0.0f, radialPoint (i + 1, divs, sin)), - v3 (radialPoint (i - 1, divs, cos), 0.0f, radialPoint (i - 1, divs, sin)); + v2 (GetRadialPoint (i + 1, divs, cos), 0.0f, GetRadialPoint (i + 1, divs, sin)), + v3 (GetRadialPoint (i - 1, divs, cos), 0.0f, GetRadialPoint (i - 1, divs, sin)); if (type == Cylinder) { @@ -532,8 +532,8 @@ v0.setZ (v0.z() * num); } - LDCondLinePtr line = (spawn<LDCondLine>()); - line->setColor (edgecolor()); + LDCondLinePtr line = (LDSpawn<LDCondLine>()); + line->setColor (EdgeColor()); line->setVertex (0, v0); line->setVertex (1, v1); line->setVertex (2, v2); @@ -546,7 +546,7 @@ // ============================================================================= // -static QString primitiveTypeName (PrimitiveType type) +static QString PrimitiveTypeName (PrimitiveType type) { // Not translated as primitives are in English. return type == Circle ? "Circle" : @@ -558,13 +558,13 @@ // ============================================================================= // -QString radialFileName (PrimitiveType type, int segs, int divs, int num) +QString MakeRadialFileName (PrimitiveType type, int segs, int divs, int num) { int numer = segs, denom = divs; // Simplify the fractional part, but the denominator must be at least 4. - simplify (numer, denom); + Simplify (numer, denom); if (denom < 4) { @@ -582,7 +582,7 @@ // Truncate the root if necessary (7-16rin4.dat for instance). // However, always keep the root at least 2 characters. int extra = (frac.length() + numstr.length() + root.length()) - 8; - root.chop (clamp (extra, 0, 2)); + root.chop (Clamp (extra, 0, 2)); // Stick them all together and return the result. return prefix + frac + root + numstr + ".dat"; @@ -590,11 +590,11 @@ // ============================================================================= // -LDDocumentPtr generatePrimitive (PrimitiveType type, int segs, int divs, int num) +LDDocumentPtr GeneratePrimitive (PrimitiveType type, int segs, int divs, int num) { // Make the description QString frac = QString::number ((float) segs / divs); - QString name = radialFileName (type, segs, divs, num); + QString name = MakeRadialFileName (type, segs, divs, num); QString descr; // Ensure that there's decimals, even if they're 0. @@ -607,10 +607,10 @@ (num < 10) ? " " : (num < 100) ? " " : ""; - descr = format ("%1 %2%3 x %4", primitiveTypeName (type), spacing, num, frac); + descr = format ("%1 %2%3 x %4", PrimitiveTypeName (type), spacing, num, frac); } else - descr = format ("%1 %2", primitiveTypeName (type), frac); + descr = format ("%1 %2", PrimitiveTypeName (type), frac); // Prepend "Hi-Res" if 48/ primitive. if (divs == HighResolution) @@ -630,32 +630,32 @@ LDObjectList objs; - objs << spawn<LDComment> (descr) - << spawn<LDComment> (format ("Name: %1", name)) - << spawn<LDComment> (format ("Author: %1", author)) - << spawn<LDComment> (format ("!LDRAW_ORG Unofficial_%1Primitive", divs == HighResolution ? -"48_" : "")) - << spawn<LDComment> (license) - << spawn<LDEmpty>() - << spawn<LDBFC> (BFCStatement::CertifyCCW) - << spawn<LDEmpty>(); + objs << LDSpawn<LDComment> (descr) + << LDSpawn<LDComment> (format ("Name: %1", name)) + << LDSpawn<LDComment> (format ("Author: %1", author)) + << LDSpawn<LDComment> (format ("!LDRAW_ORG Unofficial_%1Primitive", + divs == HighResolution ? "48_" : "")) + << LDSpawn<LDComment> (license) + << LDSpawn<LDEmpty>() + << LDSpawn<LDBFC> (BFCStatement::CertifyCCW) + << LDSpawn<LDEmpty>(); f->addObjects (objs); - f->addObjects (makePrimitive (type, segs, divs, num)); + f->addObjects (MakePrimitive (type, segs, divs, num)); return f; } // ============================================================================= // -LDDocumentPtr getPrimitive (PrimitiveType type, int segs, int divs, int num) +LDDocumentPtr GetPrimitive (PrimitiveType type, int segs, int divs, int num) { - QString name = radialFileName (type, segs, divs, num); - LDDocumentPtr f = getDocument (name); + QString name = MakeRadialFileName (type, segs, divs, num); + LDDocumentPtr f = GetDocument (name); if (f != null) return f; - return generatePrimitive (type, segs, divs, num); + return GeneratePrimitive (type, segs, divs, num); } // ============================================================================= @@ -706,7 +706,7 @@ dlg->ui->rb_ndisc->isChecked() ? DiscNeg : dlg->ui->rb_ring->isChecked() ? Ring : Cone; - LDDocumentPtr f = generatePrimitive (type, segs, divs, num); + LDDocumentPtr f = GeneratePrimitive (type, segs, divs, num); f->setImplicit (false); g_win->save (f, false); }
--- a/src/primitives.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/primitives.h Wed Aug 06 16:18:24 2014 +0300 @@ -91,8 +91,8 @@ extern QList<PrimitiveCategory*> g_PrimitiveCategories; -void loadPrimitives(); -PrimitiveScanner* getActivePrimitiveScanner(); +void LoadPrimitives(); +PrimitiveScanner* ActivePrimitiveScanner(); enum PrimitiveType { @@ -117,11 +117,11 @@ void hiResToggled (bool on); }; -void makeCircle (int segs, int divs, double radius, QList<QLineF>& lines); -LDDocumentPtr generatePrimitive (PrimitiveType type, int segs, int divs, int num); +void MakeCircle (int segs, int divs, double radius, QList<QLineF>& lines); +LDDocumentPtr GeneratePrimitive (PrimitiveType type, int segs, int divs, int num); // Gets a primitive by the given specs. If the primitive cannot be found, it will // be automatically generated. -LDDocumentPtr getPrimitive (PrimitiveType type, int segs, int divs, int num); +LDDocumentPtr GetPrimitive (PrimitiveType type, int segs, int divs, int num); -QString radialFileName (PrimitiveType type, int segs, int divs, int num); +QString MakeRadialFileName (PrimitiveType type, int segs, int divs, int num);
--- a/src/ringFinder.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/ringFinder.cc Wed Aug 06 16:18:24 2014 +0300 @@ -37,7 +37,7 @@ double num = r0 / scale; // If the ring number is integral, we have found a fitting ring to r0 -> r1! - if (isInteger (num)) + if (IsIntegral (num)) { Component cmp; cmp.scale = scale; @@ -55,7 +55,7 @@ else { // Try find solutions by splitting the ring in various positions. - if (isZero (r1 - r0)) + if (IsZero (r1 - r0)) return false; double interval; @@ -130,7 +130,7 @@ // components. double scale = 1.0; - if (not isZero (scale = r0 - floor (r0)) or not isZero (scale = r1 - floor (r1))) + if (not IsZero (scale = r0 - floor (r0)) or not IsZero (scale = r1 - floor (r1))) { double r0f = r0 / scale; double r1f = r1 / scale; @@ -197,8 +197,8 @@ for (int i = 0; i < getComponents().size(); ++i) { - maxA = max (getComponents()[i].num, maxA); - maxB = max (other->getComponents()[i].num, maxB); + maxA = Max (getComponents()[i].num, maxA); + maxB = Max (other->getComponents()[i].num, maxB); } if (maxA != maxB)
--- a/src/version.cc Mon Aug 04 13:43:54 2014 +0300 +++ b/src/version.cc Wed Aug 06 16:18:24 2014 +0300 @@ -32,7 +32,7 @@ // ============================================================================= // -const char* versionString() +const char* VersionString() { if (g_versionString[0] == '\0') { @@ -48,12 +48,12 @@ // ============================================================================= // -const char* fullVersionString() +const char* FullVersionString() { if (g_fullVersionString[0] == '\0') { #if BUILD_ID != BUILD_RELEASE and defined (SVN_REVISION_STRING) - sprintf (g_fullVersionString, "%s-" SVN_REVISION_STRING, versionString()); + sprintf (g_fullVersionString, "%s-" SVN_REVISION_STRING, VersionString()); #else sprintf (g_fullVersionString, "%s", versionString()); #endif @@ -64,7 +64,7 @@ // ============================================================================= // -const char* commitTimeString() +const char* CommitTimeString() { #ifdef SVN_REVISION_NUMBER if (g_buildTime[0] == '\0')
--- a/src/version.h Mon Aug 04 13:43:54 2014 +0300 +++ b/src/version.h Wed Aug 06 16:18:24 2014 +0300 @@ -46,6 +46,6 @@ # undef DEBUG #endif // RELEASE -const char* versionString(); -const char* fullVersionString(); -const char* commitTimeString(); +const char* VersionString(); +const char* FullVersionString(); +const char* CommitTimeString();
--- a/updaterevision/updaterevision.c Mon Aug 04 13:43:54 2014 +0300 +++ b/updaterevision/updaterevision.c Wed Aug 06 16:18:24 2014 +0300 @@ -18,7 +18,7 @@ int main(int argc, char **argv) { - char *name; + const char *name = "svnout"; char currev[64], lastrev[64], run[256], *rev; unsigned long urev; FILE *stream = NULL; @@ -55,7 +55,7 @@ sprintf (run, "svnversion -cn %s", argv[1]); else sprintf (run, "hg identify -n"); - if ((name = tempnam(NULL, "svnout")) != NULL) + // if ((name = tempnam(NULL, "svnout")) != NULL) { #ifdef __APPLE__ // tempnam will return errno of 2 even though it is successful for our purposes. @@ -91,10 +91,10 @@ fclose (stream); remove (name); } - if (name != NULL) + /*if (name != NULL) { free (name); - } + }*/ if (!gotrev) {