[vtkusers] GLSliceView frozes when parallely using vtkFlRenderWindowInteractor

karenkawing dorafriends at gmail.com
Thu Dec 16 03:10:52 EST 2010


Though this is a rather old thread, I am posting my solution in case anyone
is also trying hard to solve this problem just like what I did before...

I got stuck in this problem for a long time and could not find any suitable
answer.
After lots of trial, I found that if I commented out the following code in
the draw() function of glsliceview.h, I got both the glsliceciew and
vtkFlRenderWindowInteractor work! (though I do not know why yet...):

if( this->cViewClickedPoints )
    {
        glColor3f( 0.8, 0.4, 0.4 );
        glPointSize( 3.0 );
        glBegin(GL_POINTS);
        {
            for ( int ii = 0; ii < this->numClickedPointsStored(); ii++ )
            {
                ClickPoint p;
                this->getClickedPoint( ii, p );
                float pts[3] = { p.x, p.y, p.z };

                if ( static_cast<int>( pts[this->cWinOrder[2]] ) ==
                     (int)this->sliceNum() )
                {
                    float xx;
                    if(this->cFlipX[this->cWinOrientation])
                    {
                        xx = this->cW - (pts[this->cWinOrder[0]]
                                        - this->cWinMinX) * scale0
                            - originX;
                    }
                    else
                    {
                        xx = (pts[this->cWinOrder[0]] - this->cWinMinX) *
scale0
                            + originX;
                    }

                    float yy;
                    if(this->cFlipY[this->cWinOrientation])
                    {
                        yy = this->cH - (pts[this->cWinOrder[1]]
                                        - this->cWinMinY) * scale1
                            - originY;
                    }
                    else
                    {
                        yy = (pts[this->cWinOrder[1]] - this->cWinMinY) *
scale1
                             + originY;
                    }
                    glVertex2f( xx, yy );
                }
            }
        }
        glEnd();
    }

    if( this->cViewAxisLabel )
      {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glColor4f(0.2, 0.2, 0.78, (float)0.75);
      gl_font(FL_TIMES_BOLD, 12);
     
      if( !this->cFlipX[this->cWinOrientation] )
        {
        const int yy = static_cast<int>(  this->cH/2-gl_height()/2  );
        gl_draw( this->cAxisLabelX[this->cWinOrientation],
          this->cW-(gl_width(this->cAxisLabelX[this->cWinOrientation])+10),
          static_cast<float>( yy ) );
        }
      else
        {
        const int yy = static_cast<int>( this->cH/2-gl_height()/2  );
        gl_draw( this->cAxisLabelX[this->cWinOrientation],
          (gl_width(this->cAxisLabelX[this->cWinOrientation])+10),
          static_cast<float>( yy ));
        }
     
      if(!this->cFlipY[this->cWinOrientation])
        {
        const int yy = static_cast<int>( this->cH-gl_height()-10 ) ;
        gl_draw( this->cAxisLabelY[this->cWinOrientation],
          this->cW/2-(gl_width(this->cAxisLabelY[this->cWinOrientation])/2),
          static_cast<float>(yy) );
        }
      else
        {
        const int yy = static_cast<int>( gl_height()+10 );
        gl_draw( this->cAxisLabelY[this->cWinOrientation],
          this->cW/2-(gl_width(this->cAxisLabelY[this->cWinOrientation])/2),
          static_cast<float>(yy));
        }
     
      glDisable(GL_BLEND);
      }
    if( this->cViewValue )
      {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glColor4f(0.1, 0.64, 0.2, (float)0.75);
      gl_font(FL_TIMES_BOLD, 12);
      char s[80];
      float px, py, pz, val = this->cClickSelectV;
      const char * suffix = "";
      if( this->cViewValuePhysicalUnits )
        {
        IndexType index;
        typedef typename IndexType::IndexValueType    IndexValueType;
        index[0] = static_cast< IndexValueType >( this->cClickSelect[0] );
        index[1] = static_cast< IndexValueType >( this->cClickSelect[1] );
        index[2] = static_cast< IndexValueType >( this->cClickSelect[2] );
        PointType point;
        this->cImData->TransformIndexToPhysicalPoint( index, point );
        px = point[0];
        py = point[1];
        pz = point[2];
        suffix = this->cPhysicalUnitsName;
        }
       else
        {
        px = this->cClickSelect[0];
        py = this->cClickSelect[1];
        pz = this->cClickSelect[2];
        }
      if((ImagePixelType)1.5==1.5)
        {
        sprintf(s, "(%0.1f%s,  %0.1f%s,  %0.1f%s) = %0.3f",
                px, suffix,
                py, suffix,
                pz, suffix,
                val);
        }
      else
        {
        sprintf(s, "(%0.1f%s,  %0.1f%s,  %0.1f%s) = %d",
                px, suffix,
                py, suffix,
                pz, suffix,
                (int)val);
        }
      gl_draw( s,
        (int)(this->cW-(gl_width(s)+2)), 2);
      glDisable(GL_BLEND);
     
      }
    if( this->cViewDetails )
      {
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
      glColor4f(0.9, 0.4, 0.1, (float)0.75);
      gl_font(FL_TIMES_BOLD, 12);
      char s[80];
      if(this->cWinOrientation == 0)
        sprintf(s, "X - Slice: %3d", this->cWinCenter[0]);
      else if(this->cWinOrientation == 1)
        sprintf(s, "Y - Slice: %3d", this->cWinCenter[1]);
      else
        sprintf(s, "Z - Slice: %3d", this->cWinCenter[2]);
      gl_draw( s, 2, 2+5*(gl_height()+2) );
      sprintf(s, "Dims: %3d x %3d x %3d",
        (int)this->cDimSize[0], (int)this->cDimSize[1],
(int)this->cDimSize[2]);
      gl_draw( s, 2, 2+4*(gl_height()+2) );
      sprintf(s, "Voxel: %0.3f x %0.3f x %0.3f",
        this->cSpacing[0], this->cSpacing[1], this->cSpacing[2]);
      gl_draw( s, 2, 2+3*(gl_height()+2) );
      sprintf(s, "Int. Range: %0.3f - %0.3f", (float)this->cDataMin,
              (float)this->cDataMax);
      gl_draw( s, 2, 2+2*(gl_height()+2) );
      sprintf(s, "Int. Window: %0.3f(%s) - %0.3f(%s)",
        (float)this->cIWMin, IWModeTypeName[this->cIWModeMin],
        (float)this->cIWMax, IWModeTypeName[this->cIWModeMax]);
      gl_draw( s, 2, 2+1*(gl_height()+2) );
      sprintf(s, "View Mode: %s", ImageModeTypeName[this->cImageMode]);
      gl_draw( s, 2, 2+0*(gl_height()+2) );
      glDisable(GL_BLEND);
      }

If you do not want to change glsliceview.h, simply create a subclass of
glsliceview and override the draw() function. Hope this solution is helpful~
-- 
View this message in context: http://vtk.1045678.n5.nabble.com/GLSliceView-frozes-when-parallely-using-vtkFlRenderWindowInteractor-tp1239557p3307549.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list