Sun, 19 May 2013 00:47:07 +0300
Added ability to set the depth value to something else than 0.
src/gldraw.cpp | file | annotate | diff | comparison | revisions | |
src/gldraw.h | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/gui_actions.cpp | file | annotate | diff | comparison | revisions | |
src/types.cpp | file | annotate | diff | comparison | revisions | |
src/types.h | file | annotate | diff | comparison | revisions |
--- a/src/gldraw.cpp Sun May 19 00:12:02 2013 +0300 +++ b/src/gldraw.cpp Sun May 19 00:47:07 2013 +0300 @@ -20,6 +20,7 @@ #include <QWheelEvent> #include <QMouseEvent> #include <QContextMenuEvent> +#include <QInputDialog> #include <GL/glu.h> #include "common.h" @@ -47,6 +48,7 @@ }; overlayMeta g_overlays[6]; +double g_depthValues[6]; cfg (str, gl_bgcolor, "#CCCCD9"); cfg (str, gl_maincolor, "#707078"); @@ -117,8 +119,10 @@ info->cam = cam; } - for (int i = 0; i < 6; ++i) + for (int i = 0; i < 6; ++i) { g_overlays[i].img = null; + g_depthValues[i] = 0.0f; + } calcCameraIcons (); } @@ -400,6 +404,8 @@ // ============================================================================= vertex GLRenderer::coordconv2_3 (const QPoint& pos2d, bool snap) const { + assert (camera () != Free); + vertex pos3d; const staticCameraMeta* cam = &g_staticCameras[m_camera]; const Axis axisX = cam->axisX; @@ -422,6 +428,7 @@ pos3d = g_origin; pos3d[axisX] = cx; pos3d[axisY] = cy; + pos3d[3 - axisX - axisY] = depthValue (); return pos3d; } @@ -1357,4 +1364,18 @@ overlayMeta& info = g_overlays[camera ()]; delete info.img; info.img = null; +} + +void GLRenderer::setDepthValue (double depth) { + assert (camera () < Free); + g_depthValues[camera ()] = depth; +} + +double GLRenderer::depthValue () const { + assert (camera () < Free); + return g_depthValues[camera ()]; +} + +const char* GLRenderer::cameraName () const { + return g_CameraNames[camera ()]; } \ No newline at end of file
--- a/src/gldraw.h Sun May 19 00:12:02 2013 +0300 +++ b/src/gldraw.h Sun May 19 00:47:07 2013 +0300 @@ -49,14 +49,15 @@ GLRenderer (QWidget* parent = null); ~GLRenderer (); - void beginPlaneDraw (); Camera camera () const { return m_camera; } Axis cameraAxis (bool y); + const char* cameraName () const; void clearOverlay (); void compileObject (LDObject* obj); void compileAllObjects (); + double depthValue () const; EditMode editMode () const { return m_editmode; } - void endDraw (bool accept); + void endDraw (bool accept); QColor getMainColor (); void hardRefresh (); bool picking () const { return m_picking; } @@ -65,6 +66,7 @@ uchar* screencap (ushort& w, ushort& h); void setBackground (); void setCamera (const Camera cam); + void setDepthValue (double depth); void setEditMode (const EditMode mode); void setupOverlay (); void setZoom (const double zoom) { m_zoom = zoom; }
--- a/src/gui.cpp Sun May 19 00:12:02 2013 +0300 +++ b/src/gui.cpp Sun May 19 00:47:07 2013 +0300 @@ -193,9 +193,6 @@ addMenuAction ("newBFC"); // New BFC Statment addMenuAction ("newVertex"); // New Vertex addMenuAction ("newRadial"); // New Radial - menu->addSeparator (); // ----- - addMenuAction ("modeSelect"); // Select Mode - addMenuAction ("modeDraw"); // Draw Mode // Edit menu initMenu ("&Edit"); @@ -210,6 +207,11 @@ addMenuAction ("selectAll"); // Select All addMenuAction ("selectByColor"); // Select by Color addMenuAction ("selectByType"); // Select by Type + menu->addSeparator (); // ----- + addMenuAction ("modeSelect"); // Select Mode + addMenuAction ("modeDraw"); // Draw Mode + menu->addSeparator (); // ----- + addMenuAction ("setDrawDepth"); // Set Draw Depth initMenu ("&Tools"); addMenuAction ("setColor"); // Set Color @@ -834,7 +836,7 @@ return false; } -short ForgeWindow::getSelectedColor() { +short ForgeWindow::getSelectedColor () { short result = -1; for (LDObject* obj : m_sel) { @@ -855,17 +857,17 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= LDObject::Type ForgeWindow::uniformSelectedType () { - LDObject::Type eResult = LDObject::Unidentified; + LDObject::Type result = LDObject::Unidentified; for (LDObject* obj : m_sel) { - if (eResult != LDObject::Unidentified && obj->color != eResult) + if (result != LDObject::Unidentified && obj->color != result) return LDObject::Unidentified; - if (eResult == LDObject::Unidentified) - eResult = obj->getType (); + if (result == LDObject::Unidentified) + result = obj->getType (); } - return eResult; + return result; } // ============================================================================= @@ -907,12 +909,22 @@ contextMenu->addAction (findAction ("del")); contextMenu->addSeparator (); contextMenu->addAction (findAction ("setColor")); + if (single) contextMenu->addAction (findAction ("setContents")); + contextMenu->addAction (findAction ("makeBorders")); contextMenu->addAction (findAction ("setOverlay")); contextMenu->addAction (findAction ("clearOverlay")); + for (const char* mode : g_modeActionNames) + contextMenu->addAction (findAction (mode)); + + if (R ()->camera () != GL::Free) { + contextMenu->addSeparator (); + contextMenu->addAction (findAction ("setDrawDepth")); + } + contextMenu->exec (pos); }
--- a/src/gui_actions.cpp Sun May 19 00:12:02 2013 +0300 +++ b/src/gui_actions.cpp Sun May 19 00:47:07 2013 +0300 @@ -22,6 +22,7 @@ #include <QBoxLayout> #include <QDialogButtonBox> #include <QPushButton> +#include <QInputDialog> #include "gui.h" #include "file.h" @@ -425,4 +426,18 @@ MAKE_ACTION (modeDraw, "Draw Mode", "mode-draw", "Draw objects into the camera view.", CTRL (2)) { g_win->R ()->setEditMode (GL::Draw); +} + +// ========================================================================================================================================= +MAKE_ACTION (setDrawDepth, "Set Depth Value", "depth-value", "Set the depth coordinate of the current camera.", (0)) { + if (g_win->R ()->camera () == GL::Free) + return; + + bool ok; + double depth = QInputDialog::getDouble (g_win, "Set Draw Depth", + fmt ("Depth value for %s Camera:", g_win->R ()->cameraName ()), + g_win->R ()->depthValue (), -10000.0f, 10000.0f, 3, &ok); + + if (ok) + g_win->R ()->setDepthValue (depth); } \ No newline at end of file
--- a/src/types.cpp Sun May 19 00:12:02 2013 +0300 +++ b/src/types.cpp Sun May 19 00:47:07 2013 +0300 @@ -60,6 +60,14 @@ return coord ((ushort) ax); } +double& vertex::operator[] (const int ax) { + return coord (ax); +} + +const double& vertex::operator[] (const int ax) const { + return coord (ax); +} + bool vertex::operator== (const vertex& other) const { return coord (X) == other[X] && coord (Y) == other[Y] &&
--- a/src/types.h Sun May 19 00:12:02 2013 +0300 +++ b/src/types.h Sun May 19 00:47:07 2013 +0300 @@ -106,6 +106,8 @@ vertex operator- () const; double& operator[] (const Axis ax); const double& operator[] (const Axis ax) const; + double& operator[] (const int ax); + const double& operator[] (const int ax) const; private: double m_coords[3];