diff --git a/Doc/Img/Frame_ISO5457.png b/Doc/Img/Frame_ISO5457.png new file mode 100644 index 00000000..c7bdb816 Binary files /dev/null and b/Doc/Img/Frame_ISO5457.png differ diff --git a/Doc/Img/Frame_Plain.png b/Doc/Img/Frame_Plain.png new file mode 100644 index 00000000..015bdddc Binary files /dev/null and b/Doc/Img/Frame_Plain.png differ diff --git a/Doc/Img/TitleBlock_FreeCAD_Style_A.png b/Doc/Img/TitleBlock_FreeCAD_Style_A.png new file mode 100644 index 00000000..342ceb47 Binary files /dev/null and b/Doc/Img/TitleBlock_FreeCAD_Style_A.png differ diff --git a/Doc/Img/TitleBlock_ISO7200_Style_A.png b/Doc/Img/TitleBlock_ISO7200_Style_A.png new file mode 100644 index 00000000..8a30aa84 Binary files /dev/null and b/Doc/Img/TitleBlock_ISO7200_Style_A.png differ diff --git a/Doc/Img/TitleBlock_ISO7200_Style_B.png b/Doc/Img/TitleBlock_ISO7200_Style_B.png new file mode 100644 index 00000000..f83f7986 Binary files /dev/null and b/Doc/Img/TitleBlock_ISO7200_Style_B.png differ diff --git a/README.md b/README.md index 761cca97..50bdcbea 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,11 @@ For the font [osifont](https://github.com/hikikomori82/osifont) was used. ISO fo ## Styles +### Frames + +* Plain +![Plain Frame](/Doc/Img/Frame_Plain.png) + ## Limitations ### KiCAD 8 diff --git a/Src/Threads/universaldrawthread.cpp b/Src/Threads/universaldrawthread.cpp index a6a8f554..10e09311 100644 --- a/Src/Threads/universaldrawthread.cpp +++ b/Src/Threads/universaldrawthread.cpp @@ -7,6 +7,7 @@ #include "UniversalDraw/FreeCADSvg/freecadsvg.h" #include "UniversalDraw/KiCAD8/kicad8.h" #include "UniversalDraw/Html/htmldraw.h" +#include "UniversalDraw/PngQtPaint/pngqtpaint.h" UniversalDrawThread::UniversalDrawThread() { } @@ -48,6 +49,10 @@ void UniversalDrawThread::run() qInfo() << "Html"; runHtml(); break; + case DrawingFormate::PngQtPaint: + qInfo() << "Png"; + runPng(); + break; default: break; } @@ -139,3 +144,12 @@ void UniversalDrawThread::runHtml() m_pageStyle.draw(draw); } + +void UniversalDrawThread::runPng() +{ + std::shared_ptr draw = std::make_shared(); + + draw->setFileName(m_fileName + ".qt.png"); + + m_pageStyle.draw(draw); +} diff --git a/Src/Threads/universaldrawthread.h b/Src/Threads/universaldrawthread.h index d8a6ed59..14a768cc 100644 --- a/Src/Threads/universaldrawthread.h +++ b/Src/Threads/universaldrawthread.h @@ -27,6 +27,8 @@ enum class DrawingFormate { SvgQtPaint, /// Html, + /// + PngQtPaint, }; /// @@ -130,6 +132,8 @@ class UniversalDrawThread : public QThread void runSvgQtPaint(); void runHtml(); + + void runPng(); }; #endif // UNIVERSALDRAWTHREAD_H diff --git a/Src/UniversalDraw/CMakeLists.txt b/Src/UniversalDraw/CMakeLists.txt index b14b5aa8..89b1e691 100644 --- a/Src/UniversalDraw/CMakeLists.txt +++ b/Src/UniversalDraw/CMakeLists.txt @@ -19,6 +19,8 @@ add_library(UniversalDraw STATIC KiCAD8/kicad8.cpp Html/htmldraw.h Html/htmldraw.cpp + PngQtPaint/pngqtpaint.h + PngQtPaint/pngqtpaint.cpp ) target_link_libraries(UniversalDraw PRIVATE diff --git a/Src/UniversalDraw/PngQtPaint/pngqtpaint.cpp b/Src/UniversalDraw/PngQtPaint/pngqtpaint.cpp new file mode 100644 index 00000000..f9f685d5 --- /dev/null +++ b/Src/UniversalDraw/PngQtPaint/pngqtpaint.cpp @@ -0,0 +1,93 @@ +#include "pngqtpaint.h" +#include "qcolor.h" +#include "qnamespace.h" +#include "qpixmap.h" + +#include + +PngQtPaint::PngQtPaint() : QtPainterDrawer() { } + +// void PngQtPaint::drawText(QPointF position, QString text, double textSize, +// TextHeightAnchor textHeightAnchor, TextWidthAnchor textWidthAnchor, +// double lineWidth, QString font, QString name, bool isEditable) +// { +// if (isEditable && !this->showEditable()) { +// return; +// } + +// QFont qFont(font); +// QFont qFontA(font); +// qFont.setPointSizeF(((textSize * std::sqrt(2)) / m_resolutionPMM) +// * 2.8346456692913); // 18897.6378 +// qFontA.setPointSizeF(100); +// double posX = position.x(); +// double posY = position.y(); +// QFontMetrics fm(qFontA); + +// if (textWidthAnchor == TextWidthAnchor::Left) { +// } else if (textWidthAnchor == TextWidthAnchor::Center) { +// posX -= (textSize * (fm.size(Qt::TextDontPrint, text).width() / double(100))) / 2; +// } else if (textWidthAnchor == TextWidthAnchor::Right) { +// posX -= (textSize * (fm.size(Qt::TextDontPrint, text).width() / double(100))); +// } + +// if (textHeightAnchor == TextHeightAnchor::Top) { +// posY += textSize; +// } else if (textHeightAnchor == TextHeightAnchor::Middle) { +// posY += (textSize / 2); +// } else if (textHeightAnchor == TextHeightAnchor::Bottom) { +// } + +// QPen pen(Qt::black); +// if (editableBlue() && isEditable) { +// pen = QPen(Qt::blue); +// } + +// pen.setStyle(Qt::SolidLine); +// pen.setWidthF(lineWidth); +// painter()->setPen(pen); +// painter()->setBrush(Qt::NoBrush); + +// painter()->setFont(qFont); +// painter()->drawText(QPointF(posX, posY), text); +// } + +bool PngQtPaint::start() +{ + m_image = std::shared_ptr(new QImage((int)(this->width() * m_resolutionPMM), + (int)(this->height() * m_resolutionPMM), + QImage::Format_ARGB32)); + this->setPainter(std::shared_ptr(new QPainter(m_image.get()))); + this->painter()->setTransform(QTransform().scale(m_resolutionPMM, m_resolutionPMM)); + return true; +} + +bool PngQtPaint::end() +{ + // this->painter()->drawPixmap(10, 130, 50, 50, pixmap); + this->painter()->end(); + m_image->save(this->fileName()); + return true; +} + +int PngQtPaint::resolutionDPI() const +{ + return m_resolutionDPI; +} + +void PngQtPaint::setResolutionDPI(int newResolutionDPI) +{ + m_resolutionDPI = newResolutionDPI; + m_resolutionPMM = m_resolutionDPI * (1 / 25.4); +} + +double PngQtPaint::resolutionPMM() const +{ + return m_resolutionPMM; +} + +void PngQtPaint::setResolutionPMM(double newResolutionPMM) +{ + m_resolutionPMM = newResolutionPMM; + m_resolutionDPI = int(m_resolutionPMM * 25.4); +} diff --git a/Src/UniversalDraw/PngQtPaint/pngqtpaint.h b/Src/UniversalDraw/PngQtPaint/pngqtpaint.h new file mode 100644 index 00000000..24e15037 --- /dev/null +++ b/Src/UniversalDraw/PngQtPaint/pngqtpaint.h @@ -0,0 +1,90 @@ +#ifndef PNGQTPAINT_H +#define PNGQTPAINT_H + +#include +#include +#include + +#include "UniversalDraw/universaldraw.h" +#include "UniversalDraw/QtPaint/qtpainterdrawer.h" + +/// +/// \brief The PngQtPaint class is used to draw a PDF with the Qt Painter +/// +class PngQtPaint : public QtPainterDrawer +{ +public: + /// + /// \brief PngQtPaint is a class that uses the QPainter class to draw + /// + explicit PngQtPaint(); + + /// + /// \brief drawText draws Text on the given position + /// \param position is the Position of the Text(Text Anchor) in mm + /// \param text is the text that needs to be drawn + /// \param textSize is the height/size of the text in mm + /// \param textHeightAnchor is the position of the text anchor in the height + /// \param textWidthAnchor is the position of the text anchor in the width + /// \param lineWidth is the width of the text line in mm + /// \param font is the name of the font + /// \param isEditable defines if the text field is editable(true) or not(false), this does + /// nothing with base + /// \param name is the name that the text field is given, often used for + /// variable/editable text + /// + // virtual void drawText(QPointF position, QString text, double textSize, + // TextHeightAnchor textHeightAnchor, TextWidthAnchor textWidthAnchor, + // double lineWidth, QString font = QString::fromLatin1("osifont"), + // QString name = QString::fromLatin1(""), bool isEditable = false) + // override; + + /// + /// \brief start initialises the file and make everything ready to be drawn in to + /// \return true if successful + /// + virtual bool start() override; + + /// + /// \brief end finishes and closes the file + /// \return true if successful + /// + virtual bool end() override; + + /// + /// \brief resolutionDPI is the general resolution the PDF is generated with in DPI + /// \return + /// + int resolutionDPI() const; + /// + /// \brief setResolutionDPI sets the general resolution the PDF is generated with in DPI + /// \param newResolutionDPI + /// + void setResolutionDPI(int newResolutionDPI); + + /// + /// \brief resolutionPMM is the general resolution the PDF is generated with in Px Per mm + /// \return + /// + double resolutionPMM() const; + /// + /// \brief setResolutionPMM sets the general resolution the PDF is generated with in Px Per mm + /// \param newResolutionPMM + /// + void setResolutionPMM(double newResolutionPMM); + +private: + /// + std::shared_ptr m_image; + + /// + /// \brief m_resolutionDPI the used resolution of the drawing coordinates + /// + int m_resolutionDPI = 1200; + /// + /// \brief m_resolutionPMM the used resolution of the drawing coordinates in Px per mm + /// + double m_resolutionPMM = m_resolutionDPI * (1 / 25.4); +}; + +#endif // PNGQTPAINT_H diff --git a/Src/Window/mainwindow.cpp b/Src/Window/mainwindow.cpp index fe166e1f..ab3dfdf2 100644 --- a/Src/Window/mainwindow.cpp +++ b/Src/Window/mainwindow.cpp @@ -356,6 +356,10 @@ QList UTGMainWindow::getDrawingFormates() ret.append(DrawingFormate::Html); } + if (m_ui->QtPngCheckBox->isChecked()) { + ret.append(DrawingFormate::PngQtPaint); + } + return ret; } diff --git a/Src/Window/mainwindow.ui b/Src/Window/mainwindow.ui index 8e5febfa..d753e23a 100644 --- a/Src/Window/mainwindow.ui +++ b/Src/Window/mainwindow.ui @@ -272,6 +272,20 @@ + + + + + + Qt PNG + + + true + + + + +