diff options
| author | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-21 00:38:36 +0200 |
|---|---|---|
| committer | Mikko Syrjä <mikko@3d-system.fi> | 2019-02-21 00:38:36 +0200 |
| commit | 999080870757af37abc605d728127dc0be64dbc2 (patch) | |
| tree | 291bbe505934d6c85ca9a937edacdd4bf14def4a | |
| parent | 20908c295805d66ede49372ba6ff0c57b8e769d8 (diff) | |
| download | symedit-999080870757af37abc605d728127dc0be64dbc2.tar.gz symedit-999080870757af37abc605d728127dc0be64dbc2.zip | |
Simplified menu and tools.
| -rw-r--r-- | Editor.qml | 81 | ||||
| -rw-r--r-- | image/circle_center.kra | bin | 0 -> 38141 bytes | |||
| -rw-r--r-- | image/circle_corner.kra | bin | 0 -> 40373 bytes | |||
| -rw-r--r-- | image/circle_radius.kra | bin | 0 -> 462027 bytes | |||
| -rw-r--r-- | image/delete.kra | bin | 0 -> 30269 bytes | |||
| -rw-r--r-- | image/line_single.png | bin | 658 -> 0 bytes | |||
| -rw-r--r-- | image/polyline.kra | bin | 0 -> 33500 bytes | |||
| -rw-r--r-- | image/polyline.png (renamed from image/line_poly.png) | bin | 858 -> 858 bytes | |||
| -rw-r--r-- | image/rectangle_center.kra | bin | 0 -> 30647 bytes | |||
| -rw-r--r-- | image/rectangle_corner.kra | bin | 0 -> 33830 bytes | |||
| -rw-r--r-- | image/rotate_left.kra | bin | 0 -> 28905 bytes | |||
| -rw-r--r-- | image/rotate_left.png | bin | 0 -> 596 bytes | |||
| -rw-r--r-- | image/rotate_right.kra | bin | 0 -> 28942 bytes | |||
| -rw-r--r-- | image/rotate_right.png | bin | 0 -> 589 bytes | |||
| -rw-r--r-- | image/text.kra | bin | 0 -> 26752 bytes | |||
| -rw-r--r-- | main.qml | 79 | ||||
| -rw-r--r-- | qml.qrc | 11 | ||||
| -rw-r--r-- | symbol.cpp | 108 | ||||
| -rw-r--r-- | symbol.h | 12 | ||||
| -rw-r--r-- | symedit.cpp | 85 | ||||
| -rw-r--r-- | symedit.h | 15 | ||||
| -rw-r--r-- | symedit.pro | 12 |
22 files changed, 255 insertions, 148 deletions
@@ -5,23 +5,22 @@ Rectangle enum Tool { Select = 1, - LineSingle = 11, - LinePoly = 12, - RectangleCenter = 21, - RectangleCorner = 22, + Line = 11, + RectCenter = 21, + RectCorner = 22, CircleCorner = 31, CircleRadius = 32, CircleCenter = 33, - ArcSemicircle = 41, + ArcSemi = 41, ArcQuarter = 42, Text = 51 } enum Operation { - Move = 85, // U Line = 68, // D - Radius = 82 // R + Rectangle = 66, // B + Circle = 82 // R } property int units: 100 @@ -67,16 +66,9 @@ Rectangle onPressed: { - if ( tool === Editor.Tool.LinePoly ) - { - startx = endx - starty = endy - } - else - { - startx = mousex - starty = mousey - } + startx = mousex + starty = mousey + manager.setActiveIndex(-1); down = true } @@ -91,10 +83,19 @@ Rectangle { endx = mousex endy = mousey - if ( tool === Editor.Tool.LineSingle ) + if ( tool === Editor.Tool.Line ) { - manager.addItem(Editor.Operation.Move, Qt.point(startx, starty), false) - manager.addItem(Editor.Operation.Line, Qt.point(mousex, mousey), false) + manager.addPointItem(Editor.Operation.Line, Qt.point(startx, starty), Qt.point(endx, endy), false) + symbol = manager.getSymbol() + } + else if ( tool === Editor.Tool.RectCenter || tool === Editor.Tool.RectCorner ) + { + if ( tool === Editor.Tool.RectCenter ) + { + startx -= (endx - startx) + starty -= (endy - starty) + } + manager.addPointItem(Editor.Operation.Rectangle, Qt.point(startx, starty), Qt.point(endx, endy), fillitem) symbol = manager.getSymbol() } } @@ -161,36 +162,34 @@ Rectangle { context.lineWidth = linewidth - var previous = Qt.point(0, 0) var active = manager.getActiveIndex(); var index, count = manager.getItemCount() for ( index = 0; index < count; index++ ) { if ( index === active ) - { context.strokeStyle = "red" - } else - { context.strokeStyle = "black" - } var operation = manager.getItemOperation(index) - var position = manager.getItemPoint(index) + var point, position = manager.getItemPosition(index) var fill = manager.getItemFill(index) - if ( operation === Editor.Operation.Move ) + if ( operation === Editor.Operation.Line ) { - previous = position + point = manager.getItemPoint(index) + paintline(context, position, point) } - else if ( operation === Editor.Operation.Line ) + else if ( operation === Editor.Operation.Rectangle ) { - paintline(context, previous, position) - previous = position + point = manager.getItemPoint(index) + var deltax = point.x - position.x + var deltay = position.y - point.y + paintrect(context, position, Qt.size(deltax, deltay), fill) } - else if ( operation === Editor.Operation.Radius ) + else if ( operation === Editor.Operation.Circle ) { - var radius = position.x - paintcircle(context, previous, radius, fill) + var radius = manager.getItemValue(index) + paintcircle(context, position, radius, fill) } } } @@ -208,6 +207,9 @@ Rectangle if ( down ) { + context.strokeStyle = "red" + context.fillStyle = "red" + var cornerx = (mousex < startx ? mousex : startx) var cornery = (mousey > starty ? mousey : starty) var deltax = Math.abs(mousex - startx) @@ -216,21 +218,16 @@ Rectangle var end = Qt.point(mousex, mousey) if ( tool > 10 && tool < 20 ) // line { - if ( tool === Editor.Tool.LineSingle ) + if ( tool === Editor.Tool.Line ) paintline(context, start, end) - else if ( tool === Editor.Tool.Polyline ) - { - paintline(context, start, end) //## - } } else if ( tool > 20 && tool < 30 ) // rectangle { - if ( tool === Editor.Tool.RectangleCenter ) + if ( tool === Editor.Tool.RectCenter ) { cornerx = startx + (mousex < startx ? -deltax : -deltax) cornery = starty + (mousey < starty ? deltay : deltay) - deltax *= 2 - deltay *= 2 + deltax *= 2; deltay *= 2 } paintrect(context, Qt.point(cornerx, cornery), Qt.size(deltax, deltay), fillitem) } diff --git a/image/circle_center.kra b/image/circle_center.kra Binary files differnew file mode 100644 index 0000000..54c58ca --- /dev/null +++ b/image/circle_center.kra diff --git a/image/circle_corner.kra b/image/circle_corner.kra Binary files differnew file mode 100644 index 0000000..64fe0bc --- /dev/null +++ b/image/circle_corner.kra diff --git a/image/circle_radius.kra b/image/circle_radius.kra Binary files differnew file mode 100644 index 0000000..259594e --- /dev/null +++ b/image/circle_radius.kra diff --git a/image/delete.kra b/image/delete.kra Binary files differnew file mode 100644 index 0000000..5c0c795 --- /dev/null +++ b/image/delete.kra diff --git a/image/line_single.png b/image/line_single.png Binary files differdeleted file mode 100644 index dbebfc0..0000000 --- a/image/line_single.png +++ /dev/null diff --git a/image/polyline.kra b/image/polyline.kra Binary files differnew file mode 100644 index 0000000..36e3906 --- /dev/null +++ b/image/polyline.kra diff --git a/image/line_poly.png b/image/polyline.png Binary files differindex 14c85a9..14c85a9 100644 --- a/image/line_poly.png +++ b/image/polyline.png diff --git a/image/rectangle_center.kra b/image/rectangle_center.kra Binary files differnew file mode 100644 index 0000000..c26ead9 --- /dev/null +++ b/image/rectangle_center.kra diff --git a/image/rectangle_corner.kra b/image/rectangle_corner.kra Binary files differnew file mode 100644 index 0000000..a49ba0d --- /dev/null +++ b/image/rectangle_corner.kra diff --git a/image/rotate_left.kra b/image/rotate_left.kra Binary files differnew file mode 100644 index 0000000..01be197 --- /dev/null +++ b/image/rotate_left.kra diff --git a/image/rotate_left.png b/image/rotate_left.png Binary files differnew file mode 100644 index 0000000..f16c1c0 --- /dev/null +++ b/image/rotate_left.png diff --git a/image/rotate_right.kra b/image/rotate_right.kra Binary files differnew file mode 100644 index 0000000..428715e --- /dev/null +++ b/image/rotate_right.kra diff --git a/image/rotate_right.png b/image/rotate_right.png Binary files differnew file mode 100644 index 0000000..0038139 --- /dev/null +++ b/image/rotate_right.png diff --git a/image/text.kra b/image/text.kra Binary files differnew file mode 100644 index 0000000..9365a71 --- /dev/null +++ b/image/text.kra @@ -23,72 +23,49 @@ ApplicationWindow { Menu { - title: qsTr("File") //%% + title: qsTr("File") //%% MenuItem { text: qsTr("Open"); shortcut: "Ctrl+O"; onTriggered: open() } //%% MenuItem { text: qsTr("Save"); shortcut: "Ctrl+S"; onTriggered: save() } //%% MenuSeparator { } - MenuItem - { - text: qsTr("From Clipboard") //%% - shortcut: "Ctrl+Alt+V" - onTriggered: { manager.readClipboard() } - } - MenuItem - { - text: qsTr("To Clipboard") //%% - shortcut: "Ctrl+Alt+C" - onTriggered: { manager.writeClipboard() } - } - MenuSeparator { } MenuItem { text: qsTr("Exit"); shortcut: "F4"; onTriggered: Qt.quit() } //%% } Menu { - title: qsTr("Edit") //%% + title: qsTr("Edit") //%% MenuItem { text: qsTr("Cut"); shortcut: "Ctrl+X"; onTriggered: cut() } //%% MenuItem { text: qsTr("Copy"); shortcut: "Ctrl+C"; onTriggered: copy() } //%% MenuItem { text: qsTr("Paste"); shortcut: "Ctrl+V"; onTriggered: paste() } //%% MenuSeparator { } - MenuItem { text: qsTr("Raise"); shortcut: "Alt+Up"; onTriggered: raise() } //%% - MenuItem { text: qsTr("Lower"); shortcut: "Alt+Down"; onTriggered: lower() } //%% + MenuItem { text: qsTr("Rotate Right"); shortcut: "Alt+Right"; onTriggered: rotate(1) } //%% + MenuItem { text: qsTr("Rotate Left"); shortcut: "Alt+Left"; onTriggered: rotate(-1) } //%% MenuSeparator { } MenuItem { text: qsTr("Delete"); shortcut: "Delete"; onTriggered: remove() } //%% } Menu { - title: qsTr("Tool") //%% + title: qsTr("Tool") //%% MenuTool { text: qsTr("Select"); tool: Editor.Tool.Select } //%% MenuSeparator { } - MenuTool { text: qsTr("Line"); tool: Editor.Tool.LineSingle } //%% - MenuTool { text: qsTr("Polyline"); tool: Editor.Tool.LinePoly } //%% + MenuTool { text: qsTr("Line"); tool: Editor.Tool.Line } //%% MenuSeparator { } - MenuTool { text: qsTr("Rectangle Corner"); tool: Editor.Tool.RectangleCorner } //%% - MenuTool { text: qsTr("Rectangle Center"); tool: Editor.Tool.RectangleCenter } //%% + MenuTool { text: qsTr("Rectangle Corner"); tool: Editor.Tool.RectCorner } //%% + MenuTool { text: qsTr("Rectangle Center"); tool: Editor.Tool.RectCenter } //%% MenuSeparator { } MenuTool { text: qsTr("Circle Corner"); tool: Editor.Tool.CircleCorner } //%% MenuTool { text: qsTr("Circle Radius"); tool: Editor.Tool.CircleRadius } //%% MenuTool { text: qsTr("Circle Center"); tool: Editor.Tool.CircleCenter } //%% MenuSeparator { } - MenuTool { text: qsTr("Semicircle"); tool: Editor.Tool.ArcSemicircle } //%% + MenuTool { text: qsTr("Semicircle"); tool: Editor.Tool.ArcSemi } //%% MenuTool { text: qsTr("Quarter circle"); tool: Editor.Tool.ArcQuarter } //%% MenuSeparator { } MenuTool { text: qsTr("Text"); tool: Editor.Tool.Text } //%% } Menu { - title: qsTr("Help") //%% - MenuItem - { - text: qsTr("Help") //%% - shortcut: "F1" - onTriggered: { help() } - } + title: qsTr("Help") //%% + MenuItem { text: qsTr("Help"); shortcut: "F1"; onTriggered: help() } //%% MenuSeparator { } - MenuItem - { - text: qsTr("About") //%% - onTriggered: { about() } - } + MenuItem { text: qsTr("About"); onTriggered: about() } //%% } } @@ -105,17 +82,16 @@ ApplicationWindow BarTool { image: "image/clipboard_cut_icon&48.png"; onClicked: cut() } BarTool { image: "image/clipboard_copy_icon&48.png"; onClicked: copy() } BarTool { image: "image/clipboard_past_icon&48.png"; onClicked: paste() } - BarTool { image: "image/br_up_icon&48.png"; onClicked: raise() } - BarTool { image: "image/br_down_icon&48.png"; onClicked: lower() } + BarTool { image: "image/rotate_right.png"; onClicked: rotate(1) } + BarTool { image: "image/rotate_left.png"; onClicked: rotate(-1) } BarTool { image: "image/delete.png"; onClicked: remove() } BarSeparator { } BarTool { image: "image/cursor_arrow_icon&48.png"; tool: Editor.Tool.Select } BarSeparator { } - BarTool { image: "image/line_single.png"; tool: Editor.Tool.LineSingle } - BarTool { image: "image/line_poly.png"; tool: Editor.Tool.LinePoly } + BarTool { image: "image/polyline.png"; tool: Editor.Tool.Line } BarSeparator { } - BarTool { image: "image/rectangle_corner.png"; tool: Editor.Tool.RectangleCorner } - BarTool { image: "image/rectangle_center.png"; tool: Editor.Tool.RectangleCenter } + BarTool { image: "image/rectangle_corner.png"; tool: Editor.Tool.RectCorner } + BarTool { image: "image/rectangle_center.png"; tool: Editor.Tool.RectCenter } BarSeparator { } BarTool { image: "image/circle_corner.png"; tool: Editor.Tool.CircleCorner } BarTool { image: "image/circle_radius.png"; tool: Editor.Tool.CircleRadius } @@ -237,27 +213,34 @@ ApplicationWindow function cut() { - + manager.cutClipboard(); + symbol = manager.getSymbol() + editor.update() } function copy() { - + manager.copyClipboard(); } function paste() { - + manager.pasteClipboard(); + symbol = manager.getSymbol() + editor.update() } - function raise() + function rotate(dir) { + if ( dir > 0 ) // right + { - } - function lower() - { + } + else // left + { + } } function remove() @@ -5,20 +5,19 @@ <file>BarSeparator.qml</file> <file>BarTool.qml</file> <file>Editor.qml</file> - <file>image/rectangle_center.png</file> + <file>image/polyline.png</file> + <file>image/rectangle_center.png</file> <file>image/rectangle_corner.png</file> <file>image/circle_corner.png</file> <file>image/circle_radius.png</file> <file>image/circle_center.png</file> - <file>image/line_single.png</file> - <file>image/line_poly.png</file> <file>image/clipboard_copy_icon&48.png</file> <file>image/clipboard_cut_icon&48.png</file> <file>image/clipboard_past_icon&48.png</file> - <file>image/folder_open_icon&48.png</file> + <file>image/rotate_left.png</file> + <file>image/rotate_right.png</file> + <file>image/folder_open_icon&48.png</file> <file>image/save_icon&48.png</file> - <file>image/br_down_icon&48.png</file> - <file>image/br_up_icon&48.png</file> <file>image/text.png</file> <file>image/delete.png</file> <file>image/cursor_arrow_icon&48.png</file> @@ -7,16 +7,30 @@ // // symbol item functions // +//@{ //! Constructor. /*! \param operation Item operation. \param point Item position. + \param value Item value. + \param fill Item area fill. */ -SymEditSymbol::Item::Item(int operation, QPoint point) - : Operation(operation), Point(point), Fill(false), Align(9) +SymEditSymbol::Item::Item(int operation, QPoint point, int value, bool fill) + : Operation(operation), Point(point), Value(value, value), Fill(fill), Align(9) +{ + +} +SymEditSymbol::Item::Item(int operation, QPoint point, QPoint value, bool fill) + : Operation(operation), Point(point), Value(value), Fill(fill), Align(0) +{ + +} +SymEditSymbol::Item::Item(int operation, QPoint point, QString value, int align) + : Operation(operation), Point(point), Text(value), Fill(false), Align(align) { } +//@} // // symbol functions @@ -33,20 +47,25 @@ SymEditSymbol::SymEditSymbol() : ActiveIndex(-1) */ void SymEditSymbol::Load(const QString& buffer) { - QStringList list = buffer.split(';', QString::SkipEmptyParts); - for ( const auto& string : list ) + Items.clear(); + QPoint position(0, 0); + for ( const auto& string : buffer.split(';', QString::SkipEmptyParts) ) { int operation = string.at(0).toLatin1(); - int x, y, comma = string.indexOf(','); + int comma = string.indexOf(','); if ( comma >= 0 ) { - x = string.mid(1, comma - 1).toInt(); - y = string.mid(comma + 1).toInt(); + int x = string.mid(1, comma - 1).toInt(); + int y = string.mid(comma + 1).toInt(); + if ( operation != 'U' ) + Items.push_back(Item(operation, position, QPoint(x, y), false)); + position = QPoint(x, y); } else // single parameter - x = y = string.mid(1).toInt(); - Item item(operation, QPoint(x, y)); - Items.push_back(item); + { + int value = string.mid(1).toInt(); + Items.push_back(Item(operation, position, value, false)); + } } ActiveIndex = static_cast<int>(Items.size()) - 1; } @@ -68,50 +87,70 @@ QString& SymEditSymbol::Save(QString& buffer) const }; buffer.clear(); + QPoint position(0, 0); for ( const auto& item : Items ) switch ( item.Operation ) { - case 'D': appendvalue(buffer.append('D'), item.Point, 2); break; - case 'U': appendvalue(buffer.append('U'), item.Point, 2); break; - case 'R': appendvalue(buffer.append('R'), item.Point, 1); break; + case 'D': // line + case 'B': // rectangle + { + if ( item.Point != position ) + appendvalue(buffer.append('U'), item.Point, 2); + appendvalue(buffer.append(item.Operation), item.Value, 2); + position = item.Value; + break; + } + case 'R': + { + if ( item.Point != position ) + appendvalue(buffer.append('U'), item.Point, 2); + appendvalue(buffer.append(item.Operation), item.Value, 1); + position = item.Point; + break; + } } if ( !buffer.isEmpty() && buffer.back() == ';' ) buffer.chop(1); + return buffer; } +//! Clear symbol. +void SymEditSymbol::Clear() +{ + Items.clear(); +} + +//@{ //! Add symbol item. /*! \param operation Item operation. \param point Item position. + \param value Item value. \param fill Item area fill. \return Reference to item. */ -SymEditSymbol::Item& SymEditSymbol::AddItem(int operation, QPoint point, bool fill) +SymEditSymbol::Item& SymEditSymbol::AddItem(int operation, QPoint point, int value, bool fill) { - Item item(operation, point); - item.Fill = fill; + Item item(operation, point, value, fill); ActiveIndex = static_cast<int>(Items.size()); Items.push_back(item); return Items.back(); } - -//! Add symbol item. -/*! - \param operation Item operation. - \param point Item position. - \param text Item text string. - \param align Item text alignment. - \return Reference to item. -*/ -SymEditSymbol::Item& SymEditSymbol::AddItem(int operation, QPoint point, QString text, int align) +SymEditSymbol::Item& SymEditSymbol::AddItem(int operation, QPoint point, QPoint value, bool fill) +{ + Item item(operation, point, value, fill); + ActiveIndex = static_cast<int>(Items.size()); + Items.push_back(item); + return Items.back(); +} +SymEditSymbol::Item& SymEditSymbol::AddItem(int operation, QPoint point, QString value, int align) { - Item item(operation, point); - item.Text = text; - item.Align = align; + Item item(operation, point, value, align); ActiveIndex = static_cast<int>(Items.size()); Items.push_back(item); return Items.back(); } +//@} //! Remove item. /*! @@ -142,6 +181,11 @@ int SymEditSymbol::SelectItem(QPoint point) const //## break; } + case 'B': // rectangle + { + //## + break; + } case 'R': // circle { double dx = point.x() - previous.x(); @@ -162,6 +206,12 @@ int SymEditSymbol::SelectItem(QPoint point) const } // +void SymEditSymbol::SetActiveIndex(int index) +{ + ActiveIndex = index; +} + +// int SymEditSymbol::GetActiveIndex() const { return static_cast<int>(ActiveIndex); @@ -15,23 +15,29 @@ public: class Item //!< Symbol item. { public: - Item(int operation, QPoint point); + Item(int operation, QPoint point, int value, bool fill); + Item(int operation, QPoint point, QPoint value, bool fill); + Item(int operation, QPoint point, QString value, int align); int Operation; //!< Item operation. QPoint Point; //!< Item coordinates. + QPoint Value; //!< Item value. + QString Text; //!< Text string. bool Fill; //!< Fill area. int Align; //!< Text alignment. - QString Text; //!< Text string. }; void Load(const QString& buffer); QString& Save(QString& buffer) const; + void Clear(); - Item& AddItem(int operation, QPoint point, bool fill); + Item& AddItem(int operation, QPoint point, int value, bool fill); + Item& AddItem(int operation, QPoint point, QPoint end, bool fill); Item& AddItem(int operation, QPoint point, QString text, int align); void RemoveItem(int index); int SelectItem(QPoint point) const; + void SetActiveIndex(int index); int GetActiveIndex() const; int GetItemCount() const; diff --git a/symedit.cpp b/symedit.cpp index 1f60f0a..e350a55 100644 --- a/symedit.cpp +++ b/symedit.cpp @@ -137,25 +137,39 @@ QString SymEditManager::getSymbol() const /*! \param operation Item operation. \param point Item position. + \param value Item value. \param fill Item area fill. \return Reference to item. */ -void SymEditManager::addItem(int operation, QPoint point, bool fill) +void SymEditManager::addValueItem(int operation, QPoint point, int value, bool fill) { - Symbol.AddItem(operation, point, fill); + Symbol.AddItem(operation, point, value, fill); } //! Add symbol item. /*! \param operation Item operation. \param point Item position. - \param text Item text string. + \param value Item value. + \param fill Item area fill. + \return Reference to item. +*/ +void SymEditManager::addPointItem(int operation, QPoint point, QPoint value, bool fill) +{ + Symbol.AddItem(operation, point, value, fill); +} + +//! Add symbol item. +/*! + \param operation Item operation. + \param point Item position. + \param value Item text value. \param align Item text alignment. \return Reference to item. */ -void SymEditManager::addText(int operation, QPoint point, QString text, int align) +void SymEditManager::addTextItem(int operation, QPoint point, QString value, int align) { - Symbol.AddItem(operation, point, text, align); + Symbol.AddItem(operation, point, value, align); } //! Remove active item. @@ -189,18 +203,44 @@ int SymEditManager::getItemOperation(int index) const \param index Item index. \return Item position. */ -QPoint SymEditManager::getItemPoint(int index) const +QPoint SymEditManager::getItemPosition(int index) const { const auto& item = Symbol.GetItem(index); + if ( item.Operation == 'B' ) // normalize to upper left + return QPoint(std::min(item.Value.x(), item.Point.x()), std::max(item.Value.y(), item.Point.y())); return item.Point; } -//! Get item string. +//! Get item int value. +/*! + \param index Item index. + \return Item value. +*/ +int SymEditManager::getItemValue(int index) const +{ + const auto& item = Symbol.GetItem(index); + return item.Value.x(); +} + +//! Get item point value. +/*! + \param index Item index. + \return Item value. +*/ +QPoint SymEditManager::getItemPoint(int index) const +{ + const auto& item = Symbol.GetItem(index); + if ( item.Operation == 'B' ) // normalize to lower right + return QPoint(std::max(item.Value.x(), item.Point.x()), std::min(item.Value.y(), item.Point.y())); + return item.Value; +} + +//! Get item text value. /*! \param index Item index. - \return Item string. + \return Item value. */ -QString SymEditManager::getItemString(int index) const +QString SymEditManager::getItemText(int index) const { const auto& item = Symbol.GetItem(index); return item.Text; @@ -220,22 +260,39 @@ int SymEditManager::selectItem(QPoint point) const } // +void SymEditManager::setActiveIndex(int index) +{ + Symbol.SetActiveIndex(index); +} + +// int SymEditManager::getActiveIndex() const { return Symbol.GetActiveIndex(); } -//! Read symbol from clipboard. -void SymEditManager::readClipboard() +//! Cut symbol to clipboard. +void SymEditManager::cutClipboard() { if ( QClipboard* clipboard = QGuiApplication::clipboard() ) - Symbol.Load(clipboard->text()); + { + clipboard->setText(getSymbol()); + Symbol.Clear(); + } } -//! Write symbol to clipboard. -void SymEditManager::writeClipboard() const +//! Copy symbol to clipboard. +void SymEditManager::copyClipboard() const { if ( QClipboard* clipboard = QGuiApplication::clipboard() ) clipboard->setText(getSymbol()); } +//! Paste symbol from clipboard. +void SymEditManager::pasteClipboard() +{ + if ( QClipboard* clipboard = QGuiApplication::clipboard() ) + Symbol.Load(clipboard->text()); +} + + @@ -61,21 +61,26 @@ public: Q_INVOKABLE QString getSymbol() const; - Q_INVOKABLE void addItem(int operation, QPoint point, bool fill); - Q_INVOKABLE void addText(int operation, QPoint point, QString text, int align); + Q_INVOKABLE void addValueItem(int operation, QPoint point, int value, bool fill); + Q_INVOKABLE void addPointItem(int operation, QPoint point, QPoint value, bool fill); + Q_INVOKABLE void addTextItem(int operation, QPoint point, QString value, int align); Q_INVOKABLE void removeItem(); Q_INVOKABLE int getItemCount() const; Q_INVOKABLE int getItemOperation(int index) const; + Q_INVOKABLE QPoint getItemPosition(int index) const; + Q_INVOKABLE int getItemValue(int index) const; Q_INVOKABLE QPoint getItemPoint(int index) const; - Q_INVOKABLE QString getItemString(int index ) const; + Q_INVOKABLE QString getItemText(int index ) const; Q_INVOKABLE bool getItemFill(int index) const; Q_INVOKABLE int selectItem(QPoint point) const; + Q_INVOKABLE void setActiveIndex(int index); Q_INVOKABLE int getActiveIndex() const; - Q_INVOKABLE void readClipboard(); - Q_INVOKABLE void writeClipboard() const; + Q_INVOKABLE void cutClipboard(); + Q_INVOKABLE void copyClipboard() const; + Q_INVOKABLE void pasteClipboard(); private: bool Initialized = false; //!< Initialization mutex. diff --git a/symedit.pro b/symedit.pro index f90bcd5..4fd41fc 100644 --- a/symedit.pro +++ b/symedit.pro @@ -34,4 +34,14 @@ HEADERS += \ symbol.h DISTFILES += \ - README.md + README.md \ + image/circle_center.kra \ + image/circle_corner.kra \ + image/circle_radius.kra \ + image/delete.kra \ + image/polyline.kra \ + image/rectangle_center.kra \ + image/rectangle_corner.kra \ + image/rotate_left.kra \ + image/rotate_right.kra \ + image/text.kra |
