From b48731917964d263175716a29a58d965cb726798 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Mon, 13 Apr 2020 14:39:51 +0100 Subject: logo tikzstyles --- tex/logo.tikzstyles | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tex/logo.tikzstyles (limited to 'tex/logo.tikzstyles') diff --git a/tex/logo.tikzstyles b/tex/logo.tikzstyles new file mode 100644 index 0000000..4e05673 --- /dev/null +++ b/tex/logo.tikzstyles @@ -0,0 +1,11 @@ +% TiKZ style file generated by TikZiT. You may edit this file manually, +% but some things (e.g. comments) may be overwritten. To be readable in +% TikZiT, the only non-comment lines must be of the form: +% \tikzstyle{NAME}=[PROPERTY LIST] + +% Node styles + +% Edge styles +\tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}] +\tikzstyle{fg}=[-, fill=black] +\tikzstyle{dir}=[->] -- cgit v1.2.3 From 706b7fc38c4ed4769a3a1a8602e729b672f13118 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sat, 18 Apr 2020 23:05:52 +0100 Subject: set no fill and no draw --- src/data/style.cpp | 10 ++++++ src/data/style.h | 11 ++++--- src/gui/styleeditor.cpp | 81 ++++++++++++++++++++++++++++++++++--------------- src/gui/styleeditor.h | 2 ++ src/gui/styleeditor.ui | 38 +++++++++++++++++++++++ tex/logo.tikzstyles | 1 + 6 files changed, 115 insertions(+), 28 deletions(-) (limited to 'tex/logo.tikzstyles') diff --git a/src/data/style.cpp b/src/data/style.cpp index fe33ee0..af6a13f 100644 --- a/src/data/style.cpp +++ b/src/data/style.cpp @@ -67,6 +67,16 @@ QBrush Style::brush() const else return QBrush(tikzit->colorByName(col)); } +bool Style::hasFill() const +{ + return (propertyWithDefault("fill", "none") != "none"); +} + +bool Style::hasStroke() const +{ + return (propertyWithDefault("draw", "none") != "none"); +} + QString Style::shape(bool tikzitOverride) const { return propertyWithDefault("shape", "circle", tikzitOverride); diff --git a/src/data/style.h b/src/data/style.h index 78e11dc..0e795e1 100644 --- a/src/data/style.h +++ b/src/data/style.h @@ -57,18 +57,21 @@ public: void setName(const QString &name); QString propertyWithDefault(QString prop, QString def, bool tikzitOverride=true) const; QString tikz() const; - void setArrowAtom(QString atom); - - // only relevant for node styles QColor fillColor(bool tikzitOverride=true) const; QBrush brush() const; + bool hasFill() const; + bool hasStroke() const; + + // only relevant for node styles QString shape(bool tikzitOverride=true) const; + QString category() const; // only relevant for edge styles Style::ArrowTipStyle arrowHead() const; Style::ArrowTipStyle arrowTail() const; Style::DrawStyle drawStyle() const; - QString category() const; + void setArrowAtom(QString atom); + protected: QString _name; diff --git a/src/gui/styleeditor.cpp b/src/gui/styleeditor.cpp index e2ade45..f8972b1 100644 --- a/src/gui/styleeditor.cpp +++ b/src/gui/styleeditor.cpp @@ -32,8 +32,8 @@ StyleEditor::StyleEditor(QWidget *parent) : { ui->setupUi(this); _formWidgets << ui->name << ui->category << - ui->fillColor << ui->hasTikzitFillColor << ui->tikzitFillColor << - ui->drawColor << ui->hasTikzitDrawColor << ui->tikzitDrawColor << + ui->fillColor << ui->noFill << ui->hasTikzitFillColor << ui->tikzitFillColor << + ui->drawColor << ui->noDraw << ui->hasTikzitDrawColor << ui->tikzitDrawColor << ui->shape << ui->hasTikzitShape << ui->tikzitShape << ui->leftArrow << ui->rightArrow << ui->properties; @@ -283,8 +283,16 @@ void StyleEditor::refreshDisplay() // draw QColor realDraw = s->strokeColor(false); QColor draw = s->strokeColor(); - ui->drawColor->setEnabled(true); - setColor(ui->drawColor, realDraw); + + ui->noDraw->setEnabled(true); + if (s->hasStroke()) { + ui->drawColor->setEnabled(true); + setColor(ui->drawColor, realDraw); + ui->noDraw->setChecked(false); + } else { + ui->noDraw->setChecked(true); + ui->drawColor->setEnabled(false); + } // tikzit draw bool drawOverride = s->data()->hasProperty("tikzit draw"); @@ -294,6 +302,27 @@ void StyleEditor::refreshDisplay() ui->tikzitDrawColor->setEnabled(drawOverride); if (drawOverride) setColor(ui->tikzitDrawColor, draw); + // fill + QColor realFill = s->fillColor(false); + QColor fill = s->fillColor(); + + ui->noFill->setEnabled(true); + if (s->hasFill()) { + ui->fillColor->setEnabled(true); + setColor(ui->fillColor, realFill); + ui->noFill->setChecked(false); + } else { + ui->noFill->setChecked(true); + ui->fillColor->setEnabled(false); + } + + // tikzit fill + bool fillOverride = s->data()->hasProperty("tikzit fill"); + ui->hasTikzitFillColor->setEnabled(true); + ui->hasTikzitFillColor->setChecked(fillOverride); + ui->tikzitFillColor->setEnabled(fillOverride); + if (fillOverride) setColor(ui->tikzitFillColor, fill); + if (!s->isEdgeStyle()) { // qDebug() << "node style update"; // category @@ -301,19 +330,6 @@ void StyleEditor::refreshDisplay() ui->category->setCurrentText( s->propertyWithDefault("tikzit category", "", false)); - // fill - QColor realFill = s->fillColor(false); - QColor fill = s->fillColor(); - ui->fillColor->setEnabled(true); - setColor(ui->fillColor, realFill); - - // tikzit fill - bool fillOverride = s->data()->hasProperty("tikzit fill"); - ui->hasTikzitFillColor->setEnabled(true); - ui->hasTikzitFillColor->setChecked(fillOverride); - ui->tikzitFillColor->setEnabled(fillOverride); - if (fillOverride) setColor(ui->tikzitFillColor, fill); - // shape QString realShape = s->propertyWithDefault("shape", "", false); QString shape = s->propertyWithDefault("tikzit shape", "", false); @@ -327,13 +343,6 @@ void StyleEditor::refreshDisplay() ui->tikzitShape->setEnabled(shapeOverride); if (shapeOverride) ui->tikzitShape->setCurrentText(shape); } else { -// qDebug() << "edge style update"; - - // set fill to gray (disabled) - ui->fillColor->setEnabled(false); - ui->tikzitFillColor->setEnabled(false); - ui->hasTikzitFillColor->setEnabled(false); - ui->shape->setEnabled(false); ui->tikzitShape->setEnabled(false); ui->hasTikzitShape->setEnabled(false); @@ -425,6 +434,30 @@ void StyleEditor::on_hasTikzitDrawColor_stateChanged(int state) } } +void StyleEditor::on_noFill_stateChanged(int state) +{ + Style *s = activeStyle(); + if (s != nullptr) { + if (state == Qt::Checked) s->data()->setProperty("fill", "none"); + else s->data()->setProperty("fill", "white"); + refreshActiveStyle(); + refreshDisplay(); + setDirty(true); + } +} + +void StyleEditor::on_noDraw_stateChanged(int state) +{ + Style *s = activeStyle(); + if (s != nullptr) { + if (state == Qt::Checked) s->data()->setProperty("draw", "none"); + else s->data()->setProperty("draw", "black"); + refreshActiveStyle(); + refreshDisplay(); + setDirty(true); + } +} + void StyleEditor::on_hasTikzitShape_stateChanged(int state) { Style *s = activeStyle(); diff --git a/src/gui/styleeditor.h b/src/gui/styleeditor.h index 2c35d56..7fc62c0 100644 --- a/src/gui/styleeditor.h +++ b/src/gui/styleeditor.h @@ -68,6 +68,8 @@ public slots: void on_tikzitDrawColor_clicked(); void on_hasTikzitFillColor_stateChanged(int state); void on_hasTikzitDrawColor_stateChanged(int state); + void on_noFill_stateChanged(int state); + void on_noDraw_stateChanged(int state); void on_hasTikzitShape_stateChanged(int state); void on_tikzitShape_currentIndexChanged(int); diff --git a/src/gui/styleeditor.ui b/src/gui/styleeditor.ui index 9c06894..22b04a6 100644 --- a/src/gui/styleeditor.ui +++ b/src/gui/styleeditor.ui @@ -822,6 +822,44 @@ true + + + + 340 + 110 + 71 + 17 + + + + + 9 + false + + + + none + + + + + + 340 + 140 + 71 + 17 + + + + + 9 + false + + + + none + + diff --git a/tex/logo.tikzstyles b/tex/logo.tikzstyles index 4e05673..3419ee3 100644 --- a/tex/logo.tikzstyles +++ b/tex/logo.tikzstyles @@ -4,6 +4,7 @@ % \tikzstyle{NAME}=[PROPERTY LIST] % Node styles +\tikzstyle{test}=[fill=none, draw=black, shape=circle] % Edge styles \tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}] -- cgit v1.2.3 From 8f3f804990387607b7e52b5550ebce52e36aa619 Mon Sep 17 00:00:00 2001 From: Aleks Kissinger Date: Sun, 19 Apr 2020 18:15:26 +0100 Subject: add path as background --- src/gui/mainmenu.cpp | 8 +++++++- src/gui/mainmenu.h | 1 + src/gui/mainmenu.ui | 9 ++++++++ src/gui/tikzscene.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++--------- src/gui/tikzscene.h | 2 +- tex/logo.tikzstyles | 5 ++++- 6 files changed, 69 insertions(+), 13 deletions(-) (limited to 'tex/logo.tikzstyles') diff --git a/src/gui/mainmenu.cpp b/src/gui/mainmenu.cpp index 092d8b4..efd453d 100644 --- a/src/gui/mainmenu.cpp +++ b/src/gui/mainmenu.cpp @@ -242,7 +242,13 @@ void MainMenu::on_actionMerge_Nodes_triggered() void MainMenu::on_actionMake_Path_triggered() { if (tikzit->activeWindow() != 0) - tikzit->activeWindow()->tikzScene()->makePath(); + tikzit->activeWindow()->tikzScene()->makePath(false); +} + +void MainMenu::on_actionMake_Path_as_Background_triggered() +{ + if (tikzit->activeWindow() != 0) + tikzit->activeWindow()->tikzScene()->makePath(true); } void MainMenu::on_actionSplit_Path_triggered() diff --git a/src/gui/mainmenu.h b/src/gui/mainmenu.h index 431e43a..d0d73e9 100644 --- a/src/gui/mainmenu.h +++ b/src/gui/mainmenu.h @@ -68,6 +68,7 @@ public slots: void on_actionReverse_Edge_Direction_triggered(); void on_actionMerge_Nodes_triggered(); void on_actionMake_Path_triggered(); + void on_actionMake_Path_as_Background_triggered(); void on_actionSplit_Path_triggered(); // Tools diff --git a/src/gui/mainmenu.ui b/src/gui/mainmenu.ui index 2e390f9..11778db 100644 --- a/src/gui/mainmenu.ui +++ b/src/gui/mainmenu.ui @@ -64,6 +64,7 @@ + @@ -485,6 +486,14 @@ Ctrl+Shift+P + + + Make Path as Background + + + Ctrl+B + + diff --git a/src/gui/tikzscene.cpp b/src/gui/tikzscene.cpp index 9da8639..33e4710 100644 --- a/src/gui/tikzscene.cpp +++ b/src/gui/tikzscene.cpp @@ -314,11 +314,14 @@ void TikzScene::reverseSelectedEdges() _tikzDocument->undoStack()->push(cmd); } -void TikzScene::makePath() +void TikzScene::makePath(bool duplicateEdges) { QSet selNodes; + QSet selEdges; QSet edges; - getSelection(selNodes, edges); + getSelection(selNodes, selEdges); + + edges = selEdges; // if no edges are selected, try to infer edges from nodes if (edges.isEmpty()) { @@ -334,13 +337,29 @@ void TikzScene::makePath() } foreach (Edge *e, edges) { - if (e->path() != nullptr) { + if (e->path() != nullptr && !duplicateEdges) { //QMessageBox::warning(nullptr, "Error", "Edges must not already be in another path."); // TODO: maybe we want to automatically split paths if edges are in a path already? return; } } + _tikzDocument->undoStack()->beginMacro("Make Path"); + + QVector oldEdgeOrder = graph()->edges(); + QSet oldEdges, newEdges; + oldEdges = edges; + + if (duplicateEdges) { + foreach (Edge *e, edges) { + Edge *e1 = e->copy(); + _tikzDocument->undoStack()->push(new AddEdgeCommand(this, e1, false, selNodes, selEdges)); + newEdges << e1; + oldEdgeOrder << e1; + } + edges = newEdges; + } + // try to turn selected edges into one contiguous chain or cycle, recording // which edges need to be flipped. @@ -387,16 +406,33 @@ void TikzScene::makePath() return; } - //qDebug() << p; - //qDebug() << flip; + _tikzDocument->undoStack()->push(new ReverseEdgesCommand(this, flip)); + + // order all of the edges together, and in the case of + // duplicate edges, just below the first original. + QVector newEdgeOrder; + bool firstEdge = true; + foreach (Edge *e, oldEdgeOrder) { + if (oldEdges.contains(e)) { + if (firstEdge) { + newEdgeOrder += p; + firstEdge = false; + } + + if (duplicateEdges) newEdgeOrder << e; + } else if (!newEdges.contains(e)) { + newEdgeOrder << e; + } + } + + _tikzDocument->undoStack()->push(new ReorderCommand(this, + graph()->nodes(), graph()->nodes(), oldEdgeOrder, newEdgeOrder)); QMap oldEdgeData; foreach (Edge *e, p) { if (e != p.first()) oldEdgeData[e] = e->data()->copy(); } - _tikzDocument->undoStack()->beginMacro("Make Path"); - _tikzDocument->undoStack()->push(new ReverseEdgesCommand(this, flip)); _tikzDocument->undoStack()->push(new MakePathCommand(this, p, oldEdgeData)); _tikzDocument->undoStack()->endMacro(); } @@ -754,10 +790,11 @@ void TikzScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) nodeItems()[e->source()]->setSelected(sel); nodeItems()[e->target()]->setSelected(sel); } - } else { - nodeItems()[_selectingEdge->source()]->setSelected(sel); - nodeItems()[_selectingEdge->target()]->setSelected(sel); } +// else { +// nodeItems()[_selectingEdge->source()]->setSelected(sel); +// nodeItems()[_selectingEdge->target()]->setSelected(sel); +// } } if (_rubberBandItem->isVisible()) { diff --git a/src/gui/tikzscene.h b/src/gui/tikzscene.h index 3f035e2..e1d30d2 100644 --- a/src/gui/tikzscene.h +++ b/src/gui/tikzscene.h @@ -83,7 +83,7 @@ public: void reverseSelectedEdges(); - void makePath(); + void makePath(bool duplicateEdges); void splitPath(); void getSelection(QSet &selNodes, QSet &selEdges) const; diff --git a/tex/logo.tikzstyles b/tex/logo.tikzstyles index 3419ee3..1103b0b 100644 --- a/tex/logo.tikzstyles +++ b/tex/logo.tikzstyles @@ -4,9 +4,12 @@ % \tikzstyle{NAME}=[PROPERTY LIST] % Node styles -\tikzstyle{test}=[fill=none, draw=black, shape=circle] +\tikzstyle{white dot}=[fill=white, draw=black, shape=circle] % Edge styles \tikzstyle{bg}=[-, line width=0.5mm, fill={rgb,255: red,217; green,217; blue,217}] \tikzstyle{fg}=[-, fill=black] \tikzstyle{dir}=[->] +\tikzstyle{region A}=[-, draw=none, fill={rgb,255: red,255; green,160; blue,162}, opacity=0.8] +\tikzstyle{region B}=[-, draw=none, fill={rgb,255: red,190; green,185; blue,255}, opacity=0.8] +\tikzstyle{region C}=[-, fill={rgb,255: red,179; green,255; blue,192}, draw=none, opacity=0.8] -- cgit v1.2.3