0
def paintEvent(self, event):
    """ Paint scene and selected region"""

    super(self.__class__, self).paintGL()
    #Draw selected region

    if self.selectionMode:
        painter = QtGui.QPainter(self)
        painter.setRenderHint(QtGui.QPainter.Antialiasing, True)
        dxx = self.lastPos.x()-self.lastPosInit.x()
        dyy = self.lastPos.y()- self.lastPosInit.y()
        painter.drawRect(self.lastPosInit.x(), self.lastPosInit.y(), self.pose[0]+dxx, self.pose[1]+dyy)

        # Paint vertexes inside selected volume box
        #for vert in self.meshmodel.point_to_draw:
         #   painter.drawEllipse(vert[0] - 5, vert[1] - 5, 10, 10)
        painter.end()

where the parent class is painting OpenGL stuff. When I load the configure file everything is fine:

image

My issue is after drawing the bounding box, the mesh colours change:

image2

Can anyone give help me?

genpfault
  • 47,669
  • 9
  • 68
  • 119
Bruno Santos
  • 23
  • 1
  • 7
  • I added glEnable(GL_DEPTH_TEST); at the top and glDisable(GL_DEPTH_TEST); between the OpenGL and QPainter stuff - and yikes, it works! – Bruno Santos Mar 06 '18 at 17:39
  • instead of comment you must write a solution and mark it as correct – eyllanesc Mar 06 '18 at 19:26
  • Thanks Eyllanesc. But unfortunately stackoverflow is not accepting my answers. What should I do ? – Bruno Santos Mar 07 '18 at 09:49
  • "But unfortunately stackoverflow is not accepting my answers." The [privilege to asking or answering questions](https://stackoverflow.com/help/privileges/create-posts) is granted from the 1st point. (AFAIK, you cannot get less once you are a registered user.) The only exception would be if you were temporarily banned but this doesn't seem to be the case. Thus, why SO shouldn't accept your [self-answer](https://stackoverflow.com/help/self-answer) if it accepted your question? (The only thing: you have to wait 48 hours to _accept_ your own answer.) – Scheff's Cat Mar 07 '18 at 11:54
  • May be interesting: a similar Q/A for [tag:qt] in [tag:c++]: [SO: Paint a rect on qglwidget at specifit times](https://stackoverflow.com/q/42417987/7478597) – Scheff's Cat Mar 07 '18 at 12:04

0 Answers0