From 0d622d4bf038db01f80b38e12b767eb918800637 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Sep 19 2023 04:56:03 +0000 Subject: #assistants: perspective: show box --- diff --git a/toonz/sources/tnztools/assistants/assistantperspective.cpp b/toonz/sources/tnztools/assistants/assistantperspective.cpp index 3913eed..3aabbe3 100644 --- a/toonz/sources/tnztools/assistants/assistantperspective.cpp +++ b/toonz/sources/tnztools/assistants/assistantperspective.cpp @@ -24,6 +24,7 @@ public: const TStringId m_idGridXY; const TStringId m_idGridYZ; const TStringId m_idGridZX; + const TStringId m_idShowBox; protected: TAssistantPoint &m_o; @@ -46,6 +47,7 @@ public: m_idGridXY("gridXY"), m_idGridYZ("gridYZ"), m_idGridZX("gridZX"), + m_idShowBox("showBox"), m_o ( addPoint("o", TAssistantPoint::CircleCross) ), m_x ( addPoint("x", TAssistantPoint::CircleFill, TPointD( 50, 0 )) ), m_y ( addPoint("y", TAssistantPoint::CircleFill, TPointD( 0, 50 )) ), @@ -63,6 +65,7 @@ public: addProperty( new TBoolProperty(m_idGridXY.str(), getGridXY()) ); addProperty( new TBoolProperty(m_idGridYZ.str(), getGridYZ()) ); addProperty( new TBoolProperty(m_idGridZX.str(), getGridZX()) ); + addProperty( new TBoolProperty(m_idShowBox.str(), getShowBox()) ); } @@ -78,6 +81,7 @@ public: setTranslation(m_idGridXY, tr("Grid XY")); setTranslation(m_idGridYZ, tr("Grid YZ")); setTranslation(m_idGridZX, tr("Grid ZX")); + setTranslation(m_idShowBox, tr("Show Box")); } @@ -93,6 +97,8 @@ public: { return data()[m_idGridYZ].getBool(); } inline bool getGridZX() const { return data()[m_idGridZX].getBool(); } + inline bool getShowBox() const + { return data()[m_idShowBox].getBool(); } void onDataChanged(const TVariant &value) override { TAssistant::onDataChanged(value); @@ -393,6 +399,24 @@ public: drawSegment(p-dx+dy, p+dx-dy, pixelSize, alpha); } + void drawBox(double alpha) const { + double pixelSize = sqrt(tglGetPixelSize2()); + TPointD xyz; + fixSidePoint(xyz, m_xy.position, m_zx.position, m_vz, m_vy); + drawSegment(xyz, m_xy.position, pixelSize, alpha); + drawSegment(xyz, m_yz.position, pixelSize, alpha); + drawSegment(xyz, m_zx.position, pixelSize, alpha); + drawSegment(m_xy.position, m_x.position, pixelSize, alpha); + drawSegment(m_xy.position, m_y.position, pixelSize, alpha); + drawSegment(m_yz.position, m_y.position, pixelSize, alpha); + drawSegment(m_yz.position, m_z.position, pixelSize, alpha); + drawSegment(m_zx.position, m_z.position, pixelSize, alpha); + drawSegment(m_zx.position, m_x.position, pixelSize, alpha); + drawSegment(m_o.position, m_x.position, pixelSize, alpha); + drawSegment(m_o.position, m_y.position, pixelSize, alpha); + drawSegment(m_o.position, m_z.position, pixelSize, alpha); + } + void draw(TToolViewer*, bool enabled) const override { double pixelSize = sqrt(tglGetPixelSize2()); double alpha = getDrawingAlpha(enabled); @@ -411,24 +435,12 @@ public: drawGrid(m_vz, m_vx, m_x.position); drawGrid(m_vx, m_vz, m_z.position); } + if (getShowBox()) + drawBox(alpha); } void drawEdit(TToolViewer *viewer) const override { - double pixelSize = sqrt(tglGetPixelSize2()); - TPointD xyz; - fixSidePoint(xyz, m_xy.position, m_zx.position, m_vz, m_vy); - drawSegment(xyz, m_xy.position, pixelSize); - drawSegment(xyz, m_yz.position, pixelSize); - drawSegment(xyz, m_zx.position, pixelSize); - drawSegment(m_xy.position, m_x.position, pixelSize); - drawSegment(m_xy.position, m_y.position, pixelSize); - drawSegment(m_yz.position, m_y.position, pixelSize); - drawSegment(m_yz.position, m_z.position, pixelSize); - drawSegment(m_zx.position, m_z.position, pixelSize); - drawSegment(m_zx.position, m_x.position, pixelSize); - drawSegment(m_o.position, m_x.position, pixelSize); - drawSegment(m_o.position, m_y.position, pixelSize); - drawSegment(m_o.position, m_z.position, pixelSize); + if (!getShowBox()) drawBox(getDrawingAlpha(false)); TAssistant::drawEdit(viewer); } };