Fri, 23 Mar 2018 19:30:53 +0200
remove LDBfc
--- a/src/dialogs/newpartdialog.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/dialogs/newpartdialog.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -20,66 +20,64 @@ #include <QRadioButton> #include <QCheckBox> #include "../lddocument.h" -#include "../mainwindow.h" #include "newpartdialog.h" #include "ui_newpartdialog.h" -#include "../linetypes/comment.h" -#include "../linetypes/empty.h" NewPartDialog::NewPartDialog (QWidget *parent) : QDialog (parent), - HierarchyElement (parent), ui (*new Ui_NewPart) { - ui.setupUi (this); + this->ui.setupUi (this); - QString authortext = m_config->defaultName(); + QString authortext = ::config->defaultName(); - if (not m_config->defaultUser().isEmpty()) - authortext.append (format (" [%1]", m_config->defaultUser())); + if (not ::config->defaultUser().isEmpty()) + authortext.append(format(" [%1]", ::config->defaultUser())); - ui.author->setText (authortext); - ui.useCaLicense->setChecked (m_config->useCaLicense()); + this->ui.author->setText (authortext); + this->ui.useCaLicense->setChecked (::config->useCaLicense()); } -BfcStatement NewPartDialog::getWinding() const +NewPartDialog::~NewPartDialog() { - if (ui.windingCcw->isChecked()) - return BfcStatement::CertifyCCW; + delete &this->ui; +} - if (ui.windingCw->isChecked()) - return BfcStatement::CertifyCW; - - return BfcStatement::NoCertify; +Winding NewPartDialog::winding() const +{ + if (this->ui.windingCcw->isChecked()) + return CounterClockwise; + else if (this->ui.windingCw->isChecked()) + return Clockwise; + else + return NoWinding; } bool NewPartDialog::useCaLicense() const { - return ui.useCaLicense->isChecked(); + return this->ui.useCaLicense->isChecked(); } QString NewPartDialog::author() const { - return ui.author->text(); + return this->ui.author->text(); } -QString NewPartDialog::title() const +QString NewPartDialog::description() const { - return ui.title->text(); + return this->ui.title->text(); } -void NewPartDialog::fillHeader (LDDocument* newdoc) const +void NewPartDialog::fillHeader (LDDocument* document) const { - newdoc->emplace<LDComment>(title()); - newdoc->emplace<LDComment>("Name: <untitled>.dat"); - newdoc->emplace<LDComment>("Author: " + author()); - newdoc->emplace<LDComment>("!LDRAW_ORG Unofficial_Part"); - QString license = preferredLicenseText(); + document->header.description = this->description(); + document->header.type = LDHeader::Part; + document->header.author = this->author(); - if (not license.isEmpty()) - newdoc->emplace<LDComment>(license); + if (this->useCaLicense()) + document->header.license = LDHeader::CaLicense; + else + document->header.license = LDHeader::UnspecifiedLicense; - newdoc->emplace<LDEmpty>(); - newdoc->emplace<LDBfc>(getWinding()); - newdoc->emplace<LDEmpty>(); + document->setWinding(this->winding()); }
--- a/src/dialogs/newpartdialog.h Fri Mar 23 17:14:46 2018 +0200 +++ b/src/dialogs/newpartdialog.h Fri Mar 23 19:30:53 2018 +0200 @@ -21,17 +21,19 @@ #include "../main.h" #include "../linetypes/modelobject.h" -class NewPartDialog : public QDialog, HierarchyElement +class NewPartDialog : public QDialog { Q_OBJECT + public: NewPartDialog (QWidget *parent); + ~NewPartDialog(); QString author() const; - void fillHeader (LDDocument* newdoc) const; - BfcStatement getWinding() const; + void fillHeader(LDDocument* document) const; + Winding winding() const; bool useCaLicense() const; - QString title() const; + QString description() const; private: class Ui_NewPart& ui;
--- a/src/linetypes/modelobject.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/linetypes/modelobject.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -77,13 +77,6 @@ return contents(); } -// ============================================================================= -// -QString LDBfc::asText() const -{ - return format ("0 BFC %1", statementToString()); -} - int LDObject::triangleCount(DocumentManager*) const { return 0; @@ -324,9 +317,6 @@ case LDObjectType::ConditionalEdge: return new LDConditionalEdge {}; - case LDObjectType::Bfc: - return new LDBfc {}; - case LDObjectType::Comment: return new LDComment {}; @@ -430,46 +420,6 @@ return m_contents; } -LDBfc::LDBfc (const BfcStatement type) : - m_statement {type} {} - -BfcStatement LDBfc::statement() const -{ - return m_statement; -} - -void LDBfc::setStatement (BfcStatement value) -{ - m_statement = value; -} - -QString LDBfc::statementToString() const -{ - return LDBfc::statementToString (statement()); -} - -QString LDBfc::statementToString (BfcStatement statement) -{ - static const char* statementStrings[] = - { - "CERTIFY CCW", - "CCW", - "CERTIFY CW", - "CW", - "NOCERTIFY", - "INVERTNEXT", - "CLIP", - "CLIP CCW", - "CLIP CW", - "NOCLIP", - }; - - if ((int) statement >= 0 and (int) statement < countof (statementStrings)) - return QString::fromLatin1 (statementStrings[(int) statement]); - else - return ""; -} - Vertex LDBezierCurve::pointAt (qreal t) const { if (t >= 0.0 and t <= 1.0) @@ -589,11 +539,6 @@ return result; } -QString LDBfc::objectListText() const -{ - return statementToString(); -} - bool LDObject::isInverted() const { return m_hasInvertNext; @@ -623,12 +568,6 @@ serializer << m_transformationMatrix; } -void LDBfc::serialize(Serializer& serializer) -{ - LDObject::serialize(serializer); - serializer << m_statement; -} - void LDError::serialize(Serializer& serializer) { LDObject::serialize(serializer);
--- a/src/linetypes/modelobject.h Fri Mar 23 17:14:46 2018 +0200 +++ b/src/linetypes/modelobject.h Fri Mar 23 19:30:53 2018 +0200 @@ -35,7 +35,6 @@ Triangle, // Object represents a triangle EdgeLine, // Object represents a line ConditionalEdge, // Object represents a conditional line - Bfc, // Object represents a BFC statement Comment, // Object represents a comment Error, // Object is the result of failed parsing Empty, // Object represents an empty line @@ -154,56 +153,6 @@ }; /* - * Represents a 0 BFC statement in the LDraw code. - */ -enum class BfcStatement -{ - CertifyCCW, - CCW, - CertifyCW, - CW, - NoCertify, - InvertNext, - Clip, - ClipCCW, - ClipCW, - NoClip, - _End -}; - -Q_DECLARE_METATYPE(BfcStatement) -MAKE_ITERABLE_ENUM(BfcStatement) - -class LDBfc : public LDObject -{ -public: - static const LDObjectType SubclassType = LDObjectType::Bfc; - - LDBfc(BfcStatement type = BfcStatement::CertifyCCW); - - virtual LDObjectType type() const override - { - return LDObjectType::Bfc; - } - - virtual QString asText() const override; - - bool isScemantic() const override { return statement() == BfcStatement::InvertNext; } - QString objectListText() const override; - BfcStatement statement() const; - void setStatement (BfcStatement value); - QString statementToString() const; - bool isColored() const override { return false; } - QString typeName() const override { return "bfc"; } - void serialize(class Serializer& serializer) override; - - static QString statementToString (BfcStatement statement); - -private: - BfcStatement m_statement; -}; - -/* * Represents a single code-1 subfile reference. */ class LDSubfileReference : public LDMatrixObject
--- a/src/mainwindow.ui Fri Mar 23 17:14:46 2018 +0200 +++ b/src/mainwindow.ui Fri Mar 23 19:30:53 2018 +0200 @@ -48,7 +48,7 @@ <x>0</x> <y>0</y> <width>465</width> - <height>362</height> + <height>387</height> </rect> </property> <attribute name="label"> @@ -65,8 +65,8 @@ <rect> <x>0</x> <y>0</y> - <width>465</width> - <height>362</height> + <width>98</width> + <height>93</height> </rect> </property> <attribute name="label"> @@ -93,8 +93,8 @@ <rect> <x>0</x> <y>0</y> - <width>465</width> - <height>362</height> + <width>277</width> + <height>121</height> </rect> </property> <attribute name="label"> @@ -175,8 +175,8 @@ <rect> <x>0</x> <y>0</y> - <width>465</width> - <height>362</height> + <width>98</width> + <height>93</height> </rect> </property> <attribute name="label"> @@ -210,7 +210,7 @@ <x>0</x> <y>0</y> <width>1010</width> - <height>31</height> + <height>26</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -277,7 +277,6 @@ <addaction name="actionNewQuadrilateral"/> <addaction name="actionNewConditionalLine"/> <addaction name="actionNewComment"/> - <addaction name="actionNewBFC"/> </widget> <widget class="QMenu" name="menuEdit"> <property name="title"> @@ -446,7 +445,6 @@ <addaction name="actionNewQuadrilateral"/> <addaction name="actionNewConditionalLine"/> <addaction name="actionNewComment"/> - <addaction name="actionNewBFC"/> </widget> <widget class="QToolBar" name="toolBarBasicTools"> <property name="windowTitle"> @@ -845,15 +843,6 @@ <string>New C&omment</string> </property> </action> - <action name="actionNewBFC"> - <property name="icon"> - <iconset resource="../ldforge.qrc"> - <normaloff>:/icons/add-bfc.png</normaloff>:/icons/add-bfc.png</iconset> - </property> - <property name="text"> - <string>New &BFC Statement</string> - </property> - </action> <action name="actionUndo"> <property name="icon"> <iconset resource="../ldforge.qrc"> @@ -1751,7 +1740,6 @@ </customwidgets> <resources> <include location="../ldforge.qrc"/> - <include location="../ldforge.qrc"/> </resources> <connections/> </ui>
--- a/src/parser.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/parser.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -353,23 +353,6 @@ { // Comment QString commentText = line.mid(line.indexOf("0") + 2); - QString commentTextSimplified = commentText.trimmed(); - - // Handle BFC statements - if (countof(tokens) > 2 and tokens[1] == "BFC") - { - for (BfcStatement statement : iterateEnum<BfcStatement>()) - { - if (commentTextSimplified == format("BFC %1", LDBfc::statementToString(statement))) - return model.emplaceAt<LDBfc>(position, statement); - } - - // handle MLCAD nonsense - if (commentTextSimplified == "BFC CERTIFY CLIP") - return model.emplaceAt<LDBfc>(position, BfcStatement::Clip); - else if (commentTextSimplified == "BFC CERTIFY NOCLIP") - return model.emplaceAt<LDBfc>(position, BfcStatement::NoClip); - } if (countof(tokens) > 2 and tokens[1] == "!LDFORGE") {
--- a/src/primitives.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/primitives.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -486,14 +486,21 @@ document->setFrozen(false); document->history()->setIgnoring(false); - document->emplace<LDComment>(description); - document->emplace<LDComment>(format("Name: %1", fileName)); - document->emplace<LDComment>(format("Author: %1", author)); - document->emplace<LDComment>(format("!LDRAW_ORG Unofficial_%1Primitive", hires ? "48_" : "")); - document->emplace<LDComment>(license); - document->emplace<LDEmpty>(); - document->emplace<LDBfc>(BfcStatement::CertifyCCW); - document->emplace<LDEmpty>(); + document->header.name = fileName; + document->header.description = description; + document->header.author = author; + + if (hires) + document->header.type = LDHeader::Primitive_48; + else + document->header.type = LDHeader::Primitive_8; + + if (::config->useCaLicense()) + document->header.license = LDHeader::CaLicense; + else + document->header.license =LDHeader::UnspecifiedLicense; + + document->setWinding(CounterClockwise); spec.generateBody(*document); document->addHistoryStep(); return document;
--- a/src/toolsets/algorithmtoolset.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/toolsets/algorithmtoolset.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -556,36 +556,18 @@ } while (m_documents->findDocumentByName("s\\" + Basename(fullSubfileName)) != nullptr or QFile {fullSubfileName}.exists()); } - // Determine the BFC winding type used in the main document. It will be carried over to the subfile. - BfcStatement winding = BfcStatement::NoCertify; - for (LDObjectIterator<LDBfc> it (currentDocument()); it.isValid(); ++it) - { - if (isOneOf(it->statement(), BfcStatement::CertifyCCW, BfcStatement::CertifyCW, BfcStatement::NoCertify)) - { - winding = it->statement(); - break; - } - } - // Create the new subfile document LDDocument* subfile = m_window->newDocument(); subfile->setFullPath(fullSubfileName); - subfile->setName(LDDocument::shortenName(fullSubfileName)); - - Model header {m_documents}; - header.emplace<LDComment>(subfileTitle); - header.emplace<LDComment>("Name: "); // This gets filled in when the subfile is saved - header.emplace<LDComment>(format("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); - header.emplace<LDComment>("!LDRAW_ORG Unofficial_Subpart"); + subfile->header.description = subfileTitle; + subfile->header.type = LDHeader::Subpart; + subfile->header.name = LDDocument::shortenName(fullSubfileName); + subfile->header.author = format("%1 [%2]", m_config->defaultName(), m_config->defaultUser()); - QString license = preferredLicenseText(); - if (not license.isEmpty()) - header.emplace<LDComment>(license); + if (::config->useCaLicense()) + subfile->header.license = LDHeader::CaLicense; - header.emplace<LDEmpty>(); - header.emplace<LDBfc>(winding); - header.emplace<LDEmpty>(); - subfile->merge(header); + subfile->setWinding(currentDocument()->winding()); // Copy the body over to the new document for (LDObject* object : selectedObjects())
--- a/src/toolsets/basictoolset.cpp Fri Mar 23 17:14:46 2018 +0200 +++ b/src/toolsets/basictoolset.cpp Fri Mar 23 19:30:53 2018 +0200 @@ -276,11 +276,6 @@ createObject<LDComment>(this->m_window); } -void BasicToolset::newBFC() -{ - // TODO: -} - void BasicToolset::edit() { if (countof(selectedObjects()) == 1)
--- a/src/toolsets/basictoolset.h Fri Mar 23 17:14:46 2018 +0200 +++ b/src/toolsets/basictoolset.h Fri Mar 23 19:30:53 2018 +0200 @@ -40,7 +40,6 @@ Q_INVOKABLE void modeRectangle(); Q_INVOKABLE void modeSelect(); Q_INVOKABLE void modeCurve(); - Q_INVOKABLE void newBFC(); Q_INVOKABLE void newComment(); Q_INVOKABLE void newConditionalLine(); Q_INVOKABLE void newLine();