View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002574 | DarkRadiant | Map Editing | public | 24.01.2011 06:43 | 24.09.2011 08:20 |
| Reporter | radon | Assigned To | greebo | ||
| Priority | normal | Severity | feature | Reproducibility | N/A |
| Status | closed | Resolution | fixed | ||
| Platform | amd64 | OS | Linux | OS Version | 2.6.28 |
| Product Version | 1.6.0 | ||||
| Target Version | 1.6.0 | Fixed in Version | 1.6.0 | ||
| Summary | 0002574: Grid cuelines visualy interfere with map objects | ||||
| Description | Visual representation of editing grid may be hard to distinguish from representation of map objects. Included patch add more subtle graphical representations of editing grid - dots and crosses at snap points and dotted lines. Major and minor grid can be configured independently. Ordinary lines remain default. | ||||
| Additional Information | http://modetwo.net/darkmod/index.php?/topic/12190-quark-like-grid-for-darkradiant/ | ||||
| Tags | No tags attached. | ||||
| Attached Files | quarkishgrid.patch (5,949 bytes)
Index: plugins/grid/Grid.cpp
===================================================================
--- plugins/grid/Grid.cpp (revision 6271)
+++ plugins/grid/Grid.cpp (working copy)
@@ -20,6 +20,8 @@
namespace {
const std::string RKEY_DEFAULT_GRID_SIZE = "user/ui/grid/defaultGridPower";
+ const std::string RKEY_GRID_LOOK_MAJOR = "user/ui/grid/majorGridLook";
+ const std::string RKEY_GRID_LOOK_MINOR = "user/ui/grid/minorGridLook";
}
class GridManager :
@@ -150,6 +152,17 @@
PreferencesPagePtr page = GlobalPreferenceSystem().getPage(_("Settings/Grid"));
page->appendCombo(_("Default Grid Size"), RKEY_DEFAULT_GRID_SIZE, getGridList());
+
+ ComboBoxValueList looks;
+
+ looks.push_back(_("Lines"));
+ looks.push_back(_("Dots"));
+ looks.push_back(_("Dotted Lines"));
+ looks.push_back(_("More Dotted Lines"));
+ looks.push_back(_("Crosses"));
+
+ page->appendCombo(_("Major Grid Style"), RKEY_GRID_LOOK_MAJOR, looks);
+ page->appendCombo(_("Minor Grid Style"), RKEY_GRID_LOOK_MINOR, looks);
}
std::size_t addGridChangeCallback(const GridChangedFunc& callback)
@@ -219,6 +232,21 @@
GlobalMainFrame().updateAllWindows();
}
+ static GridLook getLookFromNumber(int i) {
+ if (i >= 0 and i < sizeof(int2gridlook) / sizeof(GridLook)) {
+ return int2gridlook[i];
+ }
+ return GRIDLOOK_LINES;
+ }
+
+ GridLook getMajorLook() const {
+ return getLookFromNumber( GlobalRegistry().getInt(RKEY_GRID_LOOK_MAJOR) );
+ }
+
+ GridLook getMinorLook() const {
+ return getLookFromNumber( GlobalRegistry().getInt(RKEY_GRID_LOOK_MINOR) );
+ }
+
}; // class GridManager
typedef boost::shared_ptr<GridManager> GridManagerPtr;
Index: radiant/xyview/XYWnd.cpp
===================================================================
--- radiant/xyview/XYWnd.cpp (revision 6271)
+++ radiant/xyview/XYWnd.cpp (working copy)
@@ -896,42 +896,93 @@
Vector3 colourGridMinor = ColourSchemes().getColour("grid_minor");
Vector3 colourGridMajor = ColourSchemes().getColour("grid_major");
- // draw minor blocks
- if (colourGridMinor != colourGridBack) {
- glColor3dv(colourGridMinor);
-
- glBegin (GL_LINES);
- int i = 0;
- for (x = xb ; x < xe ; x += minor_step, ++i) {
- if ((i & mask) != 0) {
- glVertex2d (x, yb);
- glVertex2d (x, ye);
- }
+ // run grid rendering twice, first run is minor grid, then major
+ // NOTE: with a bit more work, we can have variable number of grids
+ for (int gf = 0 ; gf < 2 ; ++gf ) {
+ double cur_step, density, sizeFactor;
+ GridLook look;
+
+ if (gf) {
+ // major grid
+ if (colourGridMajor == colourGridBack)
+ continue;
+
+ glColor3dv(colourGridMajor);
+ look = GlobalGrid().getMajorLook();
+ cur_step = step;
+ density = 4;
+ // slightly bigger crosses
+ sizeFactor = 1.95;
+ } else {
+ // minor grid (rendered first)
+ if (colourGridMinor == colourGridBack)
+ continue;
+ glColor3dv(colourGridMinor);
+ look = GlobalGrid().getMinorLook();
+ cur_step = minor_step;
+ density = 4;
+ sizeFactor = 0.95;
}
- i = 0;
- for (y = yb ; y < ye ; y += minor_step, ++i) {
- if ((i & mask) != 0) {
- glVertex2d (xb, y);
- glVertex2d (xe, y);
- }
- }
- glEnd();
- }
- // draw major blocks
- if (colourGridMajor != colourGridBack) {
- glColor3dv(colourGridMajor);
-
- glBegin (GL_LINES);
- for (x=xb ; x<=xe ; x+=step) {
- glVertex2d (x, yb);
- glVertex2d (x, ye);
- }
- for (y=yb ; y<=ye ; y+=step) {
- glVertex2d (xb, y);
- glVertex2d (xe, y);
+ switch (look) {
+ case GRIDLOOK_DOTS:
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += cur_step) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_MOREDOTLINES:
+ density = 8;
+ case GRIDLOOK_DOTLINES:
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += minor_step / density) {
+ glVertex2d (x, y);
+ }
+ }
+
+ for (y = yb ; y < ye ; y += cur_step) {
+ for (x = xb ; x < xe ; x += minor_step / density) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_CROSSES:
+ glBegin (GL_LINES);
+ for (x=xb ; x<=xe ; x+=cur_step) {
+ for (y=yb ; y<=ye ; y+=cur_step) {
+ glVertex2d (x - sizeFactor / m_fScale, y);
+ glVertex2d (x + sizeFactor / m_fScale, y);
+ glVertex2d (x, y - sizeFactor / m_fScale);
+ glVertex2d (x, y + sizeFactor / m_fScale);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_LINES:
+ default:
+ glBegin (GL_LINES);
+ int i = 0;
+ for (x = xb ; x < xe ; x += cur_step, ++i) {
+ if ((i & mask) != 0) {
+ glVertex2d (x, yb);
+ glVertex2d (x, ye);
+ }
+ }
+ i = 0;
+ for (y = yb ; y < ye ; y += cur_step, ++i) {
+ if ((i & mask) != 0) {
+ glVertex2d (xb, y);
+ glVertex2d (xe, y);
+ }
+ }
+ glEnd();
+ break;
}
- glEnd();
}
}
Index: include/igrid.h
===================================================================
--- include/igrid.h (revision 6271)
+++ include/igrid.h (working copy)
@@ -24,6 +24,24 @@
GRID_256 = 8,
};
+
+// grid renderings
+enum GridLook {
+ GRIDLOOK_LINES,
+ GRIDLOOK_DOTS,
+ GRIDLOOK_DOTLINES,
+ GRIDLOOK_MOREDOTLINES,
+ GRIDLOOK_CROSSES,
+};
+
+static const GridLook int2gridlook[] = {
+ GRIDLOOK_LINES,
+ GRIDLOOK_DOTS,
+ GRIDLOOK_DOTLINES,
+ GRIDLOOK_MOREDOTLINES,
+ GRIDLOOK_CROSSES
+};
+
const std::string MODULE_GRID("Grid");
class IGridManager :
@@ -38,6 +56,9 @@
virtual void gridDown() = 0;
virtual void gridUp() = 0;
+ virtual GridLook getMajorLook() const = 0;
+ virtual GridLook getMinorLook() const = 0;
+
typedef boost::function<void()> GridChangedFunc;
virtual std::size_t addGridChangeCallback(const GridChangedFunc& callback) = 0;
}; // class IGridManager
quarkishgrid_v2.patch (6,695 bytes)
Index: plugins/grid/Grid.cpp
===================================================================
--- plugins/grid/Grid.cpp (revision 6271)
+++ plugins/grid/Grid.cpp (working copy)
@@ -20,6 +20,8 @@
namespace {
const std::string RKEY_DEFAULT_GRID_SIZE = "user/ui/grid/defaultGridPower";
+ const std::string RKEY_GRID_LOOK_MAJOR = "user/ui/grid/majorGridLook";
+ const std::string RKEY_GRID_LOOK_MINOR = "user/ui/grid/minorGridLook";
}
class GridManager :
@@ -150,6 +152,19 @@
PreferencesPagePtr page = GlobalPreferenceSystem().getPage(_("Settings/Grid"));
page->appendCombo(_("Default Grid Size"), RKEY_DEFAULT_GRID_SIZE, getGridList());
+
+ ComboBoxValueList looks;
+
+ looks.push_back(_("Lines"));
+ looks.push_back(_("Dotted Lines"));
+ looks.push_back(_("More Dotted Lines"));
+ looks.push_back(_("Crosses"));
+ looks.push_back(_("Dots"));
+ looks.push_back(_("Big Dots"));
+ looks.push_back(_("Squares"));
+
+ page->appendCombo(_("Major Grid Style"), RKEY_GRID_LOOK_MAJOR, looks);
+ page->appendCombo(_("Minor Grid Style"), RKEY_GRID_LOOK_MINOR, looks);
}
std::size_t addGridChangeCallback(const GridChangedFunc& callback)
@@ -219,6 +234,21 @@
GlobalMainFrame().updateAllWindows();
}
+ static GridLook getLookFromNumber(int i) {
+ if (i >= 0 and i < sizeof(int2gridlook) / sizeof(GridLook)) {
+ return int2gridlook[i];
+ }
+ return GRIDLOOK_LINES;
+ }
+
+ GridLook getMajorLook() const {
+ return getLookFromNumber( GlobalRegistry().getInt(RKEY_GRID_LOOK_MAJOR) );
+ }
+
+ GridLook getMinorLook() const {
+ return getLookFromNumber( GlobalRegistry().getInt(RKEY_GRID_LOOK_MINOR) );
+ }
+
}; // class GridManager
typedef boost::shared_ptr<GridManager> GridManagerPtr;
Index: radiant/xyview/XYWnd.cpp
===================================================================
--- radiant/xyview/XYWnd.cpp (revision 6271)
+++ radiant/xyview/XYWnd.cpp (working copy)
@@ -896,42 +896,117 @@
Vector3 colourGridMinor = ColourSchemes().getColour("grid_minor");
Vector3 colourGridMajor = ColourSchemes().getColour("grid_major");
- // draw minor blocks
- if (colourGridMinor != colourGridBack) {
- glColor3dv(colourGridMinor);
-
- glBegin (GL_LINES);
- int i = 0;
- for (x = xb ; x < xe ; x += minor_step, ++i) {
- if ((i & mask) != 0) {
- glVertex2d (x, yb);
- glVertex2d (x, ye);
- }
+ // run grid rendering twice, first run is minor grid, then major
+ // NOTE: with a bit more work, we can have variable number of grids
+ for (int gf = 0 ; gf < 2 ; ++gf ) {
+ double cur_step, density, sizeFactor;
+ GridLook look;
+
+ if (gf) {
+ // major grid
+ if (colourGridMajor == colourGridBack)
+ continue;
+
+ glColor3dv(colourGridMajor);
+ look = GlobalGrid().getMajorLook();
+ cur_step = step;
+ density = 4;
+ // slightly bigger crosses
+ sizeFactor = 1.95;
+ } else {
+ // minor grid (rendered first)
+ if (colourGridMinor == colourGridBack)
+ continue;
+ glColor3dv(colourGridMinor);
+ look = GlobalGrid().getMinorLook();
+ cur_step = minor_step;
+ density = 4;
+ sizeFactor = 0.95;
}
- i = 0;
- for (y = yb ; y < ye ; y += minor_step, ++i) {
- if ((i & mask) != 0) {
- glVertex2d (xb, y);
- glVertex2d (xe, y);
- }
- }
- glEnd();
- }
- // draw major blocks
- if (colourGridMajor != colourGridBack) {
- glColor3dv(colourGridMajor);
-
- glBegin (GL_LINES);
- for (x=xb ; x<=xe ; x+=step) {
- glVertex2d (x, yb);
- glVertex2d (x, ye);
- }
- for (y=yb ; y<=ye ; y+=step) {
- glVertex2d (xb, y);
- glVertex2d (xe, y);
+ switch (look) {
+ case GRIDLOOK_DOTS:
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += cur_step) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_BIGDOTS:
+ glPointSize(3);
+ glEnable(GL_POINT_SMOOTH);
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += cur_step) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ glDisable(GL_POINT_SMOOTH);
+ glPointSize(1);
+ break;
+ case GRIDLOOK_SQUARES:
+ glPointSize(3);
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += cur_step) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ glPointSize(1);
+ break;
+ case GRIDLOOK_MOREDOTLINES:
+ density = 8;
+ case GRIDLOOK_DOTLINES:
+ glBegin (GL_POINTS);
+ for (x = xb ; x < xe ; x += cur_step) {
+ for (y = yb ; y < ye ; y += minor_step / density) {
+ glVertex2d (x, y);
+ }
+ }
+
+ for (y = yb ; y < ye ; y += cur_step) {
+ for (x = xb ; x < xe ; x += minor_step / density) {
+ glVertex2d (x, y);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_CROSSES:
+ glBegin (GL_LINES);
+ for (x=xb ; x<=xe ; x+=cur_step) {
+ for (y=yb ; y<=ye ; y+=cur_step) {
+ glVertex2d (x - sizeFactor / m_fScale, y);
+ glVertex2d (x + sizeFactor / m_fScale, y);
+ glVertex2d (x, y - sizeFactor / m_fScale);
+ glVertex2d (x, y + sizeFactor / m_fScale);
+ }
+ }
+ glEnd();
+ break;
+ case GRIDLOOK_LINES:
+ default:
+ glBegin (GL_LINES);
+ int i = 0;
+ for (x = xb ; x < xe ; x += cur_step, ++i) {
+ if ((i & mask) != 0) {
+ glVertex2d (x, yb);
+ glVertex2d (x, ye);
+ }
+ }
+ i = 0;
+ for (y = yb ; y < ye ; y += cur_step, ++i) {
+ if ((i & mask) != 0) {
+ glVertex2d (xb, y);
+ glVertex2d (xe, y);
+ }
+ }
+ glEnd();
+ break;
}
- glEnd();
}
}
Index: include/igrid.h
===================================================================
--- include/igrid.h (revision 6271)
+++ include/igrid.h (working copy)
@@ -24,6 +24,28 @@
GRID_256 = 8,
};
+
+// grid renderings
+enum GridLook {
+ GRIDLOOK_LINES,
+ GRIDLOOK_DOTLINES,
+ GRIDLOOK_MOREDOTLINES,
+ GRIDLOOK_CROSSES,
+ GRIDLOOK_DOTS,
+ GRIDLOOK_BIGDOTS,
+ GRIDLOOK_SQUARES,
+};
+
+static const GridLook int2gridlook[] = {
+ GRIDLOOK_LINES,
+ GRIDLOOK_DOTLINES,
+ GRIDLOOK_MOREDOTLINES,
+ GRIDLOOK_CROSSES,
+ GRIDLOOK_DOTS,
+ GRIDLOOK_BIGDOTS,
+ GRIDLOOK_SQUARES,
+};
+
const std::string MODULE_GRID("Grid");
class IGridManager :
@@ -38,6 +60,9 @@
virtual void gridDown() = 0;
virtual void gridUp() = 0;
+ virtual GridLook getMajorLook() const = 0;
+ virtual GridLook getMinorLook() const = 0;
+
typedef boost::function<void()> GridChangedFunc;
virtual std::size_t addGridChangeCallback(const GridChangedFunc& callback) = 0;
}; // class IGridManager
| ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 24.01.2011 06:43 | radon | New Issue | |
| 24.01.2011 06:43 | radon | File Added: quarkishgrid.patch | |
| 24.01.2011 21:54 | radon | File Added: quarkishgrid_v2.patch | |
| 20.02.2011 06:34 | greebo | Status | new => confirmed |
| 23.02.2011 08:46 | greebo | Assigned To | => greebo |
| 23.02.2011 08:46 | greebo | Status | confirmed => assigned |
| 23.02.2011 08:47 | greebo | Product Version | => 1.6.0 |
| 23.02.2011 08:47 | greebo | Target Version | => 1.6.0 |
| 23.02.2011 08:48 | greebo | Note Added: 0003640 | |
| 23.02.2011 08:48 | greebo | Status | assigned => resolved |
| 23.02.2011 08:48 | greebo | Fixed in Version | => 1.6.0 |
| 23.02.2011 08:48 | greebo | Resolution | open => fixed |
| 02.04.2011 04:53 | greebo | Relationship added | related to 0002718 |
| 02.04.2011 04:55 | greebo | Relationship added | related to 0002719 |
| 24.09.2011 08:20 | greebo | Status | resolved => closed |