#include <BuildGLWidget.h>
Inherits GLWidget.
Inheritance diagram for BuildGLWidget:
Public Types | |
enum | EActStatus { ADD, REMOVE, CANT_REMOVE, EDIT_DISABLE } |
the action a double click would cause More... | |
Public Slots | |
virtual void | updateView (int hint) |
void | setSelectYellow (bool v) |
void | setUnSetBlueMode (bool v) |
void | showAllBlue () |
void | fadeTimeout () |
void | enableEdit (bool v) |
void | slvProgStatsUpdate (int hint, int data) |
void | switchIn () |
void | switchOut () |
void | changeAction (bool remove) |
Signals | |
void | changedAction (bool remove) |
void | changedTilesCount (int count) |
void | changedTileHover (int tile, BuildGLWidget::EActStatus act) |
Public Member Functions | |
BuildGLWidget (QWidget *parent, CubeDoc *document) | |
virtual | ~BuildGLWidget () |
void | keyEvent (QKeyEvent *event) |
keyboard events are delegated from MainWindow to this widget using this method. | |
Protected Member Functions | |
virtual void | drawTargets (bool inChoise) |
this is a call back to whoever subclasses this widget and calls DoChoise the default implementation does nothing. | |
virtual void | myPaintGL () |
virtual void | mouseDoubleClickEvent (QMouseEvent *event) |
virtual void | mouseMoveEvent (QMouseEvent *event) |
Private Member Functions | |
void | tiledDblClick (int choise, QMouseEvent *event) |
void | boxedDblClick (int choise, QMouseEvent *event) |
bool | doMouseMove (QMouseEvent *event, bool remove) |
bool | getChoiseTiles (int choise, bool remove, CoordBuild bb[6], Coord3d &g) |
void | drawTargetsPart (bool fTrans, bool fLines) |
void | drawErrorCyliders () |
void | checkSides () |
void | reCalcBldMinMax () |
Private Attributes | |
CubeDoc * | m_doc |
the document is needed for access to the current BuildWorld data | |
bool | m_bEditEnabled |
bool | m_fSetStrtMode |
bool | m_fUnSetBlueMode |
bool | m_bBoxedMode |
bool | m_bInternalBoxRemove |
bool | m_bBoxRemove |
bool | m_bLastBoxRemove |
used in mouseMoveEvent() | |
int | m_lastChoise |
used in mouseMoveEvent() | |
Coord3d | m_lastCubeChoise |
used in mouseMoveEvent() | |
int | m_nMarkedTiles |
number of valid tiles in m_curMarkedTiles | |
CoordBuild | m_curMarkedTiles [6] |
the tiles marked with blue or red under the mouse pointer | |
QTimer * | m_fadeTimer |
this timer is used to produce the slight fade effect of the transparent blue outline of a potential box to be added or the red outline of a box to be removed. | |
float | m_errCylindrAlpha |
when a D2 error occur the offending sides are marked by blinking cylinders to make the blinking effect we need to remember theie current alpha and the direction where that alpha was going. | |
float | m_errCylindrAlphaDt |
advancing of the alpha | |
bool | m_bDoneUpdate |
optmization. avoiding multiple updates in mouseMoveEvent() |
The current design displayed in this view is maintained at all times in its rawest form in the BuildWorld instance in CubeDoc. The method drawTargets() mades several passes on this structure to display it, polygon by polygon on the view area.
The structure is edited by the user by double clicking an existing tile to add another 1x1x1 box infront of it. The editing mode is called "boxed editing". boxed editing was introduced in version 2.0. Earlier structured were edited in what is called "tiled editing" where the user adds every tile seperatly. Boxed editing is more intuitive to the user and faster to learn and master and can express most of the structures the user would ever want to build. The only exception to that is the class of structures which are open shapes, for instance a 3x3x0 floor. These shapes cannot be build using boxed editing simply because they are not made of whole cube boxes. Tiled editing is not supported as of Version 2.0 although the code is still around.
The user uses this view to create and edit his design. When he is satisfied with the design he may click "Solve It" in order to find solution for it. Prior to finding solutions, the raw design data from BuildWorld needs to be transformed in to an instance of Shape for the solution engine to work on. This transformation is implemented in Shape::generate().
When editing a structure one needs to consider the case where the user creates a errornous structure. such structures are:
In the retired tiled editing mode the user was prohibited by the editor from creating errornous structures of type D2 although he still could created structures of classes D1 and D3. In boxed editing however the user can create stuructures of all three classes and needs to be notified about it when he does. This notification is achieved by generating the Shape from the sturucture with every edit the user makes. and keeping it in the BuildWorld::m_testShape member.
the action a double click would cause
BuildGLWidget::BuildGLWidget | ( | QWidget * | parent, | |
CubeDoc * | document | |||
) |
virtual BuildGLWidget::~BuildGLWidget | ( | ) | [inline, virtual] |
void BuildGLWidget::keyEvent | ( | QKeyEvent * | event | ) |
keyboard events are delegated from MainWindow to this widget using this method.
key delegation is needed in the case this widget is not the one in focus and we still want it to respond to ctrl presses that switch from EActStatus::ADD to EActStatus::REMOVE
void BuildGLWidget::updateView | ( | int | hint | ) | [virtual, slot] |
Reimplemented from GLWidget.
void BuildGLWidget::setSelectYellow | ( | bool | v | ) | [inline, slot] |
void BuildGLWidget::setUnSetBlueMode | ( | bool | v | ) | [inline, slot] |
void BuildGLWidget::showAllBlue | ( | ) | [slot] |
void BuildGLWidget::fadeTimeout | ( | ) | [slot] |
void BuildGLWidget::enableEdit | ( | bool | v | ) | [inline, slot] |
void BuildGLWidget::slvProgStatsUpdate | ( | int | hint, | |
int | data | |||
) | [slot] |
void BuildGLWidget::switchIn | ( | ) | [slot] |
void BuildGLWidget::switchOut | ( | ) | [slot] |
void BuildGLWidget::changeAction | ( | bool | remove | ) | [slot] |
void BuildGLWidget::changedAction | ( | bool | remove | ) | [signal] |
void BuildGLWidget::changedTilesCount | ( | int | count | ) | [signal] |
void BuildGLWidget::changedTileHover | ( | int | tile, | |
BuildGLWidget::EActStatus | act | |||
) | [signal] |
void BuildGLWidget::drawTargets | ( | bool | inChoise | ) | [protected, virtual] |
this is a call back to whoever subclasses this widget and calls DoChoise the default implementation does nothing.
inChoise
a helper argument for user specified functionality. GLWidget always calls this method with inChoise == true. if the user calls this function on his own he may want to do so with inChoise == false and do slightly differnt things, such us use more color and textures. Reimplemented from GLWidget.
void BuildGLWidget::myPaintGL | ( | ) | [protected, virtual] |
Reimplemented from GLWidget.
void BuildGLWidget::mouseDoubleClickEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
void BuildGLWidget::mouseMoveEvent | ( | QMouseEvent * | event | ) | [protected, virtual] |
Reimplemented from GLWidget.
void BuildGLWidget::tiledDblClick | ( | int | choise, | |
QMouseEvent * | event | |||
) | [private] |
void BuildGLWidget::boxedDblClick | ( | int | choise, | |
QMouseEvent * | event | |||
) | [private] |
bool BuildGLWidget::doMouseMove | ( | QMouseEvent * | event, | |
bool | remove | |||
) | [private] |
bool BuildGLWidget::getChoiseTiles | ( | int | choise, | |
bool | remove, | |||
CoordBuild | bb[6], | |||
Coord3d & | g | |||
) | [private] |
void BuildGLWidget::drawTargetsPart | ( | bool | fTrans, | |
bool | fLines | |||
) | [private] |
void BuildGLWidget::drawErrorCyliders | ( | ) | [private] |
void BuildGLWidget::checkSides | ( | ) | [private] |
void BuildGLWidget::reCalcBldMinMax | ( | ) | [private] |
CubeDoc* BuildGLWidget::m_doc [private] |
the document is needed for access to the current BuildWorld data
bool BuildGLWidget::m_bEditEnabled [private] |
bool BuildGLWidget::m_fSetStrtMode [private] |
bool BuildGLWidget::m_fUnSetBlueMode [private] |
bool BuildGLWidget::m_bBoxedMode [private] |
bool BuildGLWidget::m_bInternalBoxRemove [private] |
bool BuildGLWidget::m_bBoxRemove [private] |
bool BuildGLWidget::m_bLastBoxRemove [private] |
used in mouseMoveEvent()
int BuildGLWidget::m_lastChoise [private] |
used in mouseMoveEvent()
Coord3d BuildGLWidget::m_lastCubeChoise [private] |
used in mouseMoveEvent()
int BuildGLWidget::m_nMarkedTiles [private] |
number of valid tiles in m_curMarkedTiles
CoordBuild BuildGLWidget::m_curMarkedTiles[6] [private] |
the tiles marked with blue or red under the mouse pointer
QTimer* BuildGLWidget::m_fadeTimer [private] |
this timer is used to produce the slight fade effect of the transparent blue outline of a potential box to be added or the red outline of a box to be removed.
float BuildGLWidget::m_errCylindrAlpha [private] |
when a D2 error occur the offending sides are marked by blinking cylinders to make the blinking effect we need to remember theie current alpha and the direction where that alpha was going.
float BuildGLWidget::m_errCylindrAlphaDt [private] |
advancing of the alpha
bool BuildGLWidget::m_bDoneUpdate [private] |
optmization. avoiding multiple updates in mouseMoveEvent()