Logo Search packages:      
Sourcecode: pfstools version File versions  Download package

void Histogram::processSliderSelection ( int  xCoord,
int  yCoord 
)

Checks what part of slider was touched.

Definition at line 428 of file histogram.cpp.

References drawSlider().

                                                             {

      redrawStart();

      // Hits counter and viewport martix
      GLint hits, viewp[4];
      // Get actual viewport
      glGetIntegerv(GL_VIEWPORT, viewp);
      
      #define BUFFER_SIZE 64
      // Table for selection buffer data
      GLuint selectionBuffer[BUFFER_SIZE];
      // Prepare selection buffer
      glSelectBuffer(BUFFER_SIZE, selectionBuffer);
      
      // Change rendering mode
      glRenderMode(GL_SELECT);
      // Initializes the Name Stack
      glInitNames();
      // Push 0 (at least one entry) Onto the Stack
      glPushName(NONE);
      // Set new projection matrix as a box around xPos, yPos
      glLoadIdentity();
            
      int hh = glutGet(GLUT_WINDOW_HEIGHT);
      // Picking matrix at position xCoord, windowSize - yCoord (fliped window Y axis)
      // and size of 4 units in depth
      gluPickMatrix(xCoord, hh - yCoord, 4, 4, viewp);

      glOrtho(0.0f, viewp[2], 0.0f, viewp[3], -10.0f, 10.0f); // last 1.0 -1.0 it's enough
      drawSlider(); // draw only picked parts
      
      hits = glRenderMode(GL_RENDER);

      if(hits > 0) {
            for(int i=3; i < BUFFER_SIZE; i+=4) {
                  switch(selectionBuffer[i]) {
                  
                        case 1 :selectionState = LEFT_BAR; break;
                        case 2 :selectionState = RIGHT_BAR; break; 
                        case 3 :selectionState = WHOLE_SLIDER; break;
                        default:selectionState = NONE; break;
                  }
                  if(selectionState != NONE)
                        break;
            }
      }
            
      redrawEnd();
}


Generated by  Doxygen 1.6.0   Back to index