# HG changeset patch # User Teemu Piippo # Date 1521826253 -7200 # Node ID f2974f3ac1ab089cc780c590a242b691a1876d5f # Parent 8d22e1dd272d24b5f8c47ef97945c9f45779e042 remove LDBfc diff -r 8d22e1dd272d -r f2974f3ac1ab src/dialogs/newpartdialog.cpp --- 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 #include #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(title()); - newdoc->emplace("Name: .dat"); - newdoc->emplace("Author: " + author()); - newdoc->emplace("!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(license); + if (this->useCaLicense()) + document->header.license = LDHeader::CaLicense; + else + document->header.license = LDHeader::UnspecifiedLicense; - newdoc->emplace(); - newdoc->emplace(getWinding()); - newdoc->emplace(); + document->setWinding(this->winding()); } diff -r 8d22e1dd272d -r f2974f3ac1ab src/dialogs/newpartdialog.h --- 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; diff -r 8d22e1dd272d -r f2974f3ac1ab src/linetypes/modelobject.cpp --- 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); diff -r 8d22e1dd272d -r f2974f3ac1ab src/linetypes/modelobject.h --- 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 diff -r 8d22e1dd272d -r f2974f3ac1ab src/mainwindow.ui --- 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 @@ 0 0 465 - 362 + 387 @@ -65,8 +65,8 @@ 0 0 - 465 - 362 + 98 + 93 @@ -93,8 +93,8 @@ 0 0 - 465 - 362 + 277 + 121 @@ -175,8 +175,8 @@ 0 0 - 465 - 362 + 98 + 93 @@ -210,7 +210,7 @@ 0 0 1010 - 31 + 26 @@ -277,7 +277,6 @@ - @@ -446,7 +445,6 @@ - @@ -845,15 +843,6 @@ New C&omment - - - - :/icons/add-bfc.png:/icons/add-bfc.png - - - New &BFC Statement - - @@ -1751,7 +1740,6 @@ - diff -r 8d22e1dd272d -r f2974f3ac1ab src/parser.cpp --- 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()) - { - if (commentTextSimplified == format("BFC %1", LDBfc::statementToString(statement))) - return model.emplaceAt(position, statement); - } - - // handle MLCAD nonsense - if (commentTextSimplified == "BFC CERTIFY CLIP") - return model.emplaceAt(position, BfcStatement::Clip); - else if (commentTextSimplified == "BFC CERTIFY NOCLIP") - return model.emplaceAt(position, BfcStatement::NoClip); - } if (countof(tokens) > 2 and tokens[1] == "!LDFORGE") { diff -r 8d22e1dd272d -r f2974f3ac1ab src/primitives.cpp --- 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(description); - document->emplace(format("Name: %1", fileName)); - document->emplace(format("Author: %1", author)); - document->emplace(format("!LDRAW_ORG Unofficial_%1Primitive", hires ? "48_" : "")); - document->emplace(license); - document->emplace(); - document->emplace(BfcStatement::CertifyCCW); - document->emplace(); + 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; diff -r 8d22e1dd272d -r f2974f3ac1ab src/toolsets/algorithmtoolset.cpp --- 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 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(subfileTitle); - header.emplace("Name: "); // This gets filled in when the subfile is saved - header.emplace(format("Author: %1 [%2]", m_config->defaultName(), m_config->defaultUser())); - header.emplace("!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(license); + if (::config->useCaLicense()) + subfile->header.license = LDHeader::CaLicense; - header.emplace(); - header.emplace(winding); - header.emplace(); - subfile->merge(header); + subfile->setWinding(currentDocument()->winding()); // Copy the body over to the new document for (LDObject* object : selectedObjects()) diff -r 8d22e1dd272d -r f2974f3ac1ab src/toolsets/basictoolset.cpp --- 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(this->m_window); } -void BasicToolset::newBFC() -{ - // TODO: -} - void BasicToolset::edit() { if (countof(selectedObjects()) == 1) diff -r 8d22e1dd272d -r f2974f3ac1ab src/toolsets/basictoolset.h --- 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();