Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasfalk committed Sep 15, 2024
1 parent 331e166 commit df54629
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 50 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ If the Text Name is one of the below the Drawers detect that and Fill in the fol

| **Name** | **FreeCAD** | **KiCAD** |
|-----------------------|------------------------------------|---------------|
| **PageNumberNumbers** | "freecad:autofill", "sheet" | ${#}/${##} |
| **PageNumber** | "freecad:autofill", "page_number" | ${#} |
| **SheetNumberNumbers** | "freecad:autofill", "sheet" | ${#}/${##} |
| **SheetNumber** | "freecad:autofill", "page_number" | ${#} |
| **NumberOfPages** | "freecad:autofill", "page_count" | ${##} |
| **LegalOwner** | "freecad:autofill", "organization" | ${COMPANY} |
| **DateOfIssue** | "freecad:autofill", "date" | ${ISSUE_DATE} |
Expand Down
12 changes: 6 additions & 6 deletions Src/PageLayout/TitleBlock/FreeCADA/freecada.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ void FreeCADA::draw(std::shared_ptr<UniversalDraw> into, QRectF where, QPageLayo
m_currentLanguage["IdentificationNumber"].isEditable);
into->drawText(QPointF{ titleBlockArea().topLeft().x() + 101.25,
titleBlockArea().topLeft().y() + 30.5 },
m_currentLanguage["PageNumberNumbers"].lable, 1.5, TextHeightAnchor::Top,
m_currentLanguage["SheetNumberNumbers"].lable, 1.5, TextHeightAnchor::Top,
TextWidthAnchor::Left, .15, font());
into->drawText(QPointF{ titleBlockArea().topLeft().x() + 109.5,
titleBlockArea().topLeft().y() + 36.15 },
m_currentLanguage["PageNumberNumbers"].text, 3, TextHeightAnchor::Middle,
TextWidthAnchor::Center, .3, font(), "PageNumberNumbers",
m_currentLanguage["PageNumberNumbers"].isEditable);
m_currentLanguage["SheetNumberNumbers"].text, 3, TextHeightAnchor::Middle,
TextWidthAnchor::Center, .3, font(), "SheetNumberNumbers",
m_currentLanguage["SheetNumberNumbers"].isEditable);

// Disclaimer
into->drawText(QPointF{ titleBlockArea().topLeft().x() + 1.25,
Expand Down Expand Up @@ -282,7 +282,7 @@ void FreeCADA::initLanguages()
{ "Scale", ISO7200ATextStruct{ "SCALE:", "Scale" } },
{ "Weight", ISO7200ATextStruct{ "WEIGHT (kg):", "Weight" } },
{ "IdentificationNumber", ISO7200ATextStruct{ "DRAWING NUMBER:", "Drawing number" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "SHEET:", "Sheet" } },
{ "SheetNumberNumbers", ISO7200ATextStruct{ "SHEET:", "Sheet" } },
{ "Disclaimer",
ISO7200ATextStruct{ "",
"This drawing is our property; it can't be reproduced or "
Expand All @@ -307,7 +307,7 @@ void FreeCADA::initLanguages()
{ "Scale", ISO7200ATextStruct{ "MAẞSTAB:", "Scale" } },
{ "Weight", ISO7200ATextStruct{ "GEWICHT (kg):", "Weight" } },
{ "IdentificationNumber", ISO7200ATextStruct{ "ZEICHNUNGS NUMMER:", "Drawing number" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "BLATT:", "Sheet" } },
{ "SheetNumberNumbers", ISO7200ATextStruct{ "BLATT:", "Sheet" } },
{ "Disclaimer",
ISO7200ATextStruct{ "",
"This drawing is our property; it can't be reproduced or "
Expand Down
20 changes: 10 additions & 10 deletions Src/PageLayout/TitleBlock/ISO7200A/iso7200a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,23 @@ void ISO7200A::draw(std::shared_ptr<UniversalDraw> into, QRectF where, QPageLayo

// into->drawText(
// QPointF{ titleBlockArea().topLeft().x() + 173, titleBlockArea().topLeft().y() + 28 },
// m_currentLanguage["PageNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
// m_currentLanguage["SheetNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
// TextWidthAnchor::Left, .18);
// into->drawText(
// QPointF{ titleBlockArea().topLeft().x() + 173, titleBlockArea().topLeft().y() + 34.5
// }, m_currentLanguage["PageNumberNumbers"].text, 1.8, TextHeightAnchor::Bottom,
// TextWidthAnchor::Left, .18, font(), "PageNumberNumbers",
// m_currentLanguage["PageNumberNumbers"].isEditable);
// }, m_currentLanguage["SheetNumberNumbers"].text, 1.8, TextHeightAnchor::Bottom,
// TextWidthAnchor::Left, .18, font(), "SheetNumberNumbers",
// m_currentLanguage["SheetNumberNumbers"].isEditable);

into->drawText(
QPointF{ titleBlockArea().topLeft().x() + 172, titleBlockArea().topLeft().y() + 28 },
m_currentLanguage["PageNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
m_currentLanguage["SheetNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
TextWidthAnchor::Left, .18, font());
into->drawText(
QPointF{ titleBlockArea().topLeft().x() + 172, titleBlockArea().topLeft().y() + 34.5 },
m_currentLanguage["PageNumberNumbers"].text, 2.5, TextHeightAnchor::Bottom,
TextWidthAnchor::Left, .25, font(), "PageNumberNumbers",
m_currentLanguage["PageNumberNumbers"].isEditable);
m_currentLanguage["SheetNumberNumbers"].text, 2.5, TextHeightAnchor::Bottom,
TextWidthAnchor::Left, .25, font(), "SheetNumberNumbers",
m_currentLanguage["SheetNumberNumbers"].isEditable);

if (QFileInfo::exists(m_picturePath)) {
into->drawPicture(m_picturePath,
Expand Down Expand Up @@ -286,7 +286,7 @@ void ISO7200A::initLanguages()
{ "RevisionIndex", ISO7200ATextStruct{ "Rev.", "A" } },
{ "DateOfIssue", ISO7200ATextStruct{ "Release date", "2014-01-15" } },
{ "LanguageCode", ISO7200ATextStruct{ "L.", "en" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "Sheet", "1/3" } }
{ "SheetNumberNumbers", ISO7200ATextStruct{ "Sheet", "1/3" } }
};
m_languageTexts->insert("en_gb", en_gb);
QMap<QString, ISO7200ATextStruct> de_at = {
Expand All @@ -304,7 +304,7 @@ void ISO7200A::initLanguages()
{ "RevisionIndex", ISO7200ATextStruct{ "Änd.", "A" } },
{ "DateOfIssue", ISO7200ATextStruct{ "Ausgabedatum", "2014-01-15" } },
{ "LanguageCode", ISO7200ATextStruct{ "Spr.", "de" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "Blatt", "1/3" } }
{ "SheetNumberNumbers", ISO7200ATextStruct{ "Blatt", "1/3" } }
};
m_languageTexts->insert("de_at", de_at);
}
Expand Down
22 changes: 2 additions & 20 deletions Src/PageLayout/TitleBlock/ISO7200A/iso7200a.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,7 @@

#include "PageLayout/TitleBlock/titleblock.h"

///
/// \brief The ISO7200ATextStruct struct is used to link a lable to a given Text
///
struct ISO7200ATextStruct
{
QString lable;
QString text;
bool isEditable = true;
};
typedef TitleBlockTextStruct ISO7200ATextStruct;

///
/// \brief The ISO7200A class draws a ISO 7200 conform title-block
Expand Down Expand Up @@ -54,21 +46,11 @@ class ISO7200A : public TitleBlock

protected:
// Key/varName, values
///
/// \brief m_currentLanguage is the Map with the current language texts
///
QMap<QString, ISO7200ATextStruct> m_currentLanguage;

///
/// \brief m_languageText a map with all the language texts
///
std::shared_ptr<QMap<QString, QMap<QString, ISO7200ATextStruct>>> m_languageTexts =
std::make_shared<QMap<QString, QMap<QString, ISO7200ATextStruct>>>();

///
/// \brief initLanguages initialises the Languages map(m_languageTexts)
///
virtual void initLanguages();
virtual void initLanguages() override;

///
/// \brief m_picturePath is the Path to a Picture, if it is a waled path to a picture(.svg or
Expand Down
10 changes: 5 additions & 5 deletions Src/PageLayout/TitleBlock/ISO7200B/iso7200b.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ void ISO7200B::draw(std::shared_ptr<UniversalDraw> into, QRectF where, QPageLayo

into->drawText(
QPointF{ titleBlockArea().topLeft().x() + 172, titleBlockArea().topLeft().y() + 19 },
m_currentLanguage["PageNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
m_currentLanguage["SheetNumberNumbers"].lable, 1.8, TextHeightAnchor::Top,
TextWidthAnchor::Left, .18, font());
into->drawText(
QPointF{ titleBlockArea().topLeft().x() + 172, titleBlockArea().topLeft().y() + 25.5 },
m_currentLanguage["PageNumberNumbers"].text, 2.5, TextHeightAnchor::Bottom,
TextWidthAnchor::Left, .25, font(), "PageNumberNumbers", true);
m_currentLanguage["SheetNumberNumbers"].text, 2.5, TextHeightAnchor::Bottom,
TextWidthAnchor::Left, .25, font(), "SheetNumberNumbers", true);

if (QFileInfo::exists(m_picturePath)) {
into->drawPicture(m_picturePath,
Expand Down Expand Up @@ -226,7 +226,7 @@ void ISO7200B::initLanguages()
{ "RevisionIndex", ISO7200ATextStruct{ "Rev.", "A" } },
{ "DateOfIssue", ISO7200ATextStruct{ "Release date", "2014-01-15" } },
{ "LanguageCode", ISO7200ATextStruct{ "L.", "en" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "Sheet", "100/300" } }
{ "SheetNumberNumbers", ISO7200ATextStruct{ "Sheet", "100/300" } }
};
m_languageTexts->insert("en_gb", en_gb);
QMap<QString, ISO7200ATextStruct> de_de = {
Expand All @@ -244,7 +244,7 @@ void ISO7200B::initLanguages()
{ "RevisionIndex", ISO7200ATextStruct{ "Änd.", "A" } },
{ "DateOfIssue", ISO7200ATextStruct{ "Ausgabedatum", "2014-01-15" } },
{ "LanguageCode", ISO7200ATextStruct{ "Spr.", "de" } },
{ "PageNumberNumbers", ISO7200ATextStruct{ "Blatt", "1/3" } }
{ "SheetNumberNumbers", ISO7200ATextStruct{ "Blatt", "1/3" } }
};
m_languageTexts->insert("de_de", de_de);
}
Expand Down
5 changes: 5 additions & 0 deletions Src/PageLayout/TitleBlock/titleblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void TitleBlock::setLanguages(const QList<QString> &newLanguages)
m_languages = newLanguages;
}

void TitleBlock::initLanguages()
{

}

QString TitleBlock::font() const
{
return m_font;
Expand Down
26 changes: 26 additions & 0 deletions Src/PageLayout/TitleBlock/titleblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@

#include "UniversalDraw/universaldraw.h"

///
/// \brief The TitleBlockTextStruct struct is used to link a lable to a given Text
///
struct TitleBlockTextStruct
{
QString lable;
QString text;
bool isEditable = true;
};

///
/// \brief The TitleBlock class is the bases for all Title-blocks and if used for drawing will do
/// nothing
Expand Down Expand Up @@ -96,6 +106,22 @@ class TitleBlock
///
void setLanguages(const QList<QString> &newLanguages);

///
/// \brief m_currentLanguage is the Map with the current language texts
///
QMap<QString, TitleBlockTextStruct> m_currentLanguage;

///
/// \brief m_languageText a map with all the language texts
///
std::shared_ptr<QMap<QString, QMap<QString, TitleBlockTextStruct>>> m_languageTexts =
std::make_shared<QMap<QString, QMap<QString, TitleBlockTextStruct>>>();

///
/// \brief initLanguages initialises the Languages map(m_languageTexts)
///
virtual void initLanguages();

private:
///
/// \brief m_type the type name of the title-block
Expand Down
8 changes: 4 additions & 4 deletions Src/UniversalDraw/FreeCADSvg/freecadsvg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ void FreeCADSvg::drawText(QPointF position, QString text, double textSize,

// Autofill artibute
QList<QString> keyWords = {
"PageNumberNumbers", "LegalOwner", "DateOfIssue", "Title", "Scale",
"Creator", "PageNumber", "NumberOfPages"
"SheetNumberNumbers", "LegalOwner", "DateOfIssue", "Title", "Scale",
"Creator", "SheetNumber", "NumberOfPages"
};

if (keyWords.contains(name)) {
if (name == "PageNumberNumbers") {
if (name == "SheetNumberNumbers") {
obj.setAttribute("freecad:autofill", "sheet");
} else if (name == "PageNumber") {
} else if (name == "SheetNumber") {
obj.setAttribute("freecad:autofill", "page_number");
} else if (name == "NumberOfPages") {
obj.setAttribute("freecad:autofill", "page_count");
Expand Down
6 changes: 3 additions & 3 deletions Src/UniversalDraw/KiCAD8/kicad8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ void KiCAD8::drawText(QPointF position, QString text, double textSize,
anchorString = "(justify right bottom)";
}

QList<QString> keyWords = { "PageNumberNumbers", "PageNumber", "NumberOfPages", "LegalOwner",
QList<QString> keyWords = { "SheetNumberNumbers", "SheetNumber", "NumberOfPages", "LegalOwner",
"DateOfIssue", "RevisionIndex", "Title" };

if (isEditable && !(keyWords.contains(name))) {
text = "${" + name + "}";
} else if (keyWords.contains(name)) {
if (name == "PageNumberNumbers") {
if (name == "SheetNumberNumbers") {
text = "${#}/${##}";
} else if (name == "PageNumber") {
} else if (name == "SheetNumber") {
text = "${#}";
} else if (name == "NumberOfPages") {
text = "${##}";
Expand Down

0 comments on commit df54629

Please sign in to comment.