Hello all,
I am experiencing an interesting issue.
When I click on the mouse button (left mouse button), I am suppose to draw a blue rectangle with a white rectangle on top of it. In the program, this represents a block label.
The issue is this, when the block label is drawn on the canvas, it is a block node and not a blue node (yes, I have the glColor set correctly, this was the first thing that I checked).
Now, I also know that it is being “drawn correctly” because I noticed that when I rapid clicked on the mouse while moving it around, I was able to get some nodes to be drawn as blue and others black.
I would love to post some code here but I am not entirely sure what code to post that would be relevent to the discussion.
For now, I am posting my draw code for the block label. Please let me know if you need anymore code posted.
I should also mention that the block label object inherits from another object called node. I will also be posting the draw code, too.
Also, I have noticed that when I draw a new node or block label, a black rectangle is drawn ontop of the nore or block label. I am thinking that these two issues are related to each other; however, after looking through the draw code many times, I am not sure where the issue lies. Perhaps another pair of eyes will be able to help me determine the best fix:
void draw()
{
// The draw code for the block label
glPointSize(6.0);
if(isSelected)
glColor3d(1.0, 0.0, 0.0);
else
glColor3d(0.0, 0.0, 1.0);
glBegin(GL_POINTS);
glVertex2d(xCenterCoordinate, yCenterCoordinate);
glEnd();
glColor3d(1.0, 1.0, 1.0);
glPointSize(4.25);
glBegin(GL_POINTS);
glVertex2d(xCenterCoordinate, yCenterCoordinate);
glEnd();
}
//! The draw code for the node
virtual void draw()
{
if(isSelected)
glColor3d(1.0, 0.0, 0.0);
else
glColor3d(0.0, 0.0, 0.0);
glPointSize(6.0);
glBegin(GL_POINTS);
glVertex2d(xCenterCoordinate, yCenterCoordinate);
glEnd();
glColor3d(1.0, 1.0, 1.0);
glPointSize(4.25);
glBegin(GL_POINTS);
glVertex2d(xCenterCoordinate, yCenterCoordinate);
glEnd();
}
/* This function gets called everytime a draw routine is needed */
void modelDefinition::onPaintCanvas(wxPaintEvent &event)
{
wxGLCanvas::SetCurrent(*_geometryContext);// This will make sure the the openGL commands are routed to the wxGLCanvas object
wxPaintDC dc(this);// This is required for drawing
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT);
updateProjection();
drawGrid();
glMatrixMode(GL_MODELVIEW);
if(_editor.getLineList()->size() > 0)
{
for(std::vector<edgeLineShape>::iterator lineIterator = _editor.getLineList()->begin(); lineIterator != _editor.getLineList()->end(); ++lineIterator)
{
lineIterator->draw();
}
}
if(_editor.getArcList()->size() > 0)
{
for(std::vector<arcShape>::iterator arcIterator = _editor.getArcList()->begin(); arcIterator != _editor.getArcList()->end(); ++arcIterator)
{
arcIterator->draw();
}
}
if(_editor.getBlockLabelList()->size() > 0)
{
for(std::vector<blockLabel>::iterator blockIterator = _editor.getBlockLabelList()->begin(); blockIterator != _editor.getBlockLabelList()->end(); ++blockIterator)
{
blockIterator->draw();
}
}
if(_editor.getNodeList()->size() > 0)
{
for(std::vector<node>::iterator nodeIterator = _editor.getNodeList()->begin(); nodeIterator != _editor.getNodeList()->end(); ++nodeIterator)
{
nodeIterator->draw();
}
}
SwapBuffers();// This outputs everything to the screen
}
Please let me know if you need more source code posted. This issue has been plagueing me for a few days now! I am also attaching a picture of what I was describing above
Ok, So I seem to be having some difficulty attaching the image. Instead, I will be posting a link.