diff --git a/Pdf4QtEditorPlugins/EditorPlugin/editorplugin.cpp b/Pdf4QtEditorPlugins/EditorPlugin/editorplugin.cpp index 93dd4f9..df8fac9 100644 --- a/Pdf4QtEditorPlugins/EditorPlugin/editorplugin.cpp +++ b/Pdf4QtEditorPlugins/EditorPlugin/editorplugin.cpp @@ -50,8 +50,6 @@ EditorPlugin::EditorPlugin() : } // TODO: When text is edited, old text remains -// TODO: Color of the text is unchanged -// TODO: Moznost nastavit fill / stroke bool void EditorPlugin::setWidget(pdf::PDFWidget* widget) { diff --git a/Pdf4QtLibCore/sources/pdfblpainter.cpp b/Pdf4QtLibCore/sources/pdfblpainter.cpp index 8ae39e9..567a076 100644 --- a/Pdf4QtLibCore/sources/pdfblpainter.cpp +++ b/Pdf4QtLibCore/sources/pdfblpainter.cpp @@ -971,6 +971,14 @@ void PDFBLPaintEngine::setBLPen(BLContext& context, const QPen& pen) break; } + case Qt::CustomDashLine: + { + auto dashPattern = pen.dashPattern(); + strokeOptions.dashArray.assignData(dashPattern.data(), dashPattern.size()); + strokeOptions.dashOffset = pen.dashOffset(); + break; + } + default: break; } diff --git a/Pdf4QtLibCore/sources/pdfpainterutils.cpp b/Pdf4QtLibCore/sources/pdfpainterutils.cpp index 83f0e1d..80c3b3b 100644 --- a/Pdf4QtLibCore/sources/pdfpainterutils.cpp +++ b/Pdf4QtLibCore/sources/pdfpainterutils.cpp @@ -143,11 +143,19 @@ void PDFPainterHelper::applyPenToGraphicState(PDFPageContentProcessorState* grap } else { - // TODO: Line Dash Pattern - /* - pen.setStyle(Qt::CustomDashLine); - pen.setDashPattern(lineDashPattern.createForQPen(pen.widthF())); - pen.setDashOffset(lineDashPattern.getDashOffset());*/ + PDFLineDashPattern lineDashPattern; + QList penPattern = pen.dashPattern(); + PDFReal penWidth = pen.widthF(); + + std::vector dashArray; + for (qreal value : penPattern) + { + dashArray.push_back(value * penWidth); + } + + lineDashPattern.setDashArray(std::move(dashArray)); + lineDashPattern.setDashOffset(pen.dashOffset()); + graphicState->setLineDashPattern(std::move(lineDashPattern)); } } } diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.cpp b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.cpp index 001d81a..7c9fe6b 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.cpp +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.cpp @@ -48,14 +48,12 @@ PDFPageContentEditorEditedItemSettings::PDFPageContentEditorEditedItemSettings(Q ui->brushColorCombo->addItem(icon, colorName, color); } - ui->penStyleCombo->addItem(tr("None"), int(Qt::NoPen)); ui->penStyleCombo->addItem(tr("Solid"), int(Qt::SolidLine)); ui->penStyleCombo->addItem(tr("Dashed"), int(Qt::DashLine)); ui->penStyleCombo->addItem(tr("Dotted"), int(Qt::DotLine)); ui->penStyleCombo->addItem(tr("Dash-dot"), int(Qt::DashDotLine)); ui->penStyleCombo->addItem(tr("Dash-dot-dot"), int(Qt::DashDotDotLine)); - - ui->brushStyleCombo->addItem(tr("None"), int(Qt::NoBrush)); + ui->penStyleCombo->addItem(tr("Custom"), int(Qt::CustomDashLine)); ui->brushStyleCombo->addItem(tr("Solid"), int(Qt::SolidPattern)); connect(ui->selectPenColorButton, &QToolButton::clicked, this, &PDFPageContentEditorEditedItemSettings::onSelectPenColorButtonClicked); @@ -137,6 +135,7 @@ void PDFPageContentEditorEditedItemSettings::loadFromElement(PDFPageContentEleme features.setFlag(Pen); features.setFlag(PenColor); features.setFlag(Brush); + features.setFlag(StrokeFill); } if (element->asText()) @@ -147,6 +146,7 @@ void PDFPageContentEditorEditedItemSettings::loadFromElement(PDFPageContentEleme const bool hasPen = features.testFlag(Pen); const bool hasPenColor = features.testFlag(PenColor); const bool hasBrush = features.testFlag(Brush); + const bool hasStrokeFill = features.testFlag(StrokeFill); ui->penWidthEdit->setEnabled(hasPen); ui->penWidthLabel->setEnabled(hasPen); @@ -165,6 +165,15 @@ void PDFPageContentEditorEditedItemSettings::loadFromElement(PDFPageContentEleme ui->brushColorLabel->setEnabled(hasBrush); ui->selectBrushColorButton->setEnabled(hasBrush); + ui->strokePathCheckBox->setEnabled(hasStrokeFill); + ui->fillPathCheckBox->setEnabled(hasStrokeFill); + + if (const PDFEditedPageContentElementPath* pathElement = element->asPath()) + { + ui->strokePathCheckBox->setChecked(pathElement->getStrokePath()); + ui->fillPathCheckBox->setChecked(pathElement->getFillPath()); + } + const PDFPageContentProcessorState& graphicState = element->getState(); QPen pen = pdf::PDFPainterHelper::createPenFromState(&graphicState, graphicState.getAlphaStroking()); @@ -241,6 +250,12 @@ void PDFPageContentEditorEditedItemSettings::saveToElement(PDFPageContentElement textElement->setItemsAsText(ui->plainTextEdit->toPlainText()); } + if (PDFEditedPageContentElementPath* pathElement = editedElement->getElement()->asPath()) + { + pathElement->setStrokePath(ui->strokePathCheckBox->isChecked()); + pathElement->setFillPath(ui->fillPathCheckBox->isChecked()); + } + PDFTransformationDecomposition decomposedTransformation; decomposedTransformation.rotationAngle = ui->rotationAngleEdit->value(); decomposedTransformation.shearFactor = ui->shearFactorEdit->value(); diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.h b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.h index f81d134..19a0248 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.h +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.h @@ -69,7 +69,8 @@ private: None = 0, Pen = 1 << 0, PenColor = 1 << 1, - Brush = 1 << 2 + Brush = 1 << 2, + StrokeFill = 1 << 3, }; Q_DECLARE_FLAGS(StyleFeatures, StyleFeature) diff --git a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.ui b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.ui index 8e86601..790879f 100644 --- a/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.ui +++ b/Pdf4QtLibWidgets/sources/pdfpagecontenteditorediteditemsettings.ui @@ -139,13 +139,16 @@ Style - - - - true + + + + ... + + + @@ -153,20 +156,10 @@ - - - - - + + - Brush Color - - - - - - - ... + Pen Color @@ -180,13 +173,6 @@ - - - - Pen Width - - - @@ -194,24 +180,21 @@ - - + + - Pen Color - - - - - - - - - - true + Pen Width + + + Stroke path + + + + Qt::Vertical @@ -224,6 +207,37 @@ + + + + + + + Brush Color + + + + + + + true + + + + + + + true + + + + + + + Fill path + + +