Beispiel #1
0
bool PointImp::getExtents(double& dMinX, double& dMinY, double& dMaxX, double& dMaxY)
{
   PlotViewImp* pPlot = getPlot();
   VERIFY(pPlot != NULL);

   double dWorldX = 0.0;
   double dWorldY = 0.0;

   pPlot->translateDataToWorld(mLocation.mX, mLocation.mY, dWorldX, dWorldY);

   dMinX = dMaxX = dWorldX;
   dMinY = dMaxY = dWorldY;
   return true;
}
Beispiel #2
0
bool CurveImp::getExtents(double& dMinX, double& dMinY, double& dMaxX, double& dMaxY)
{
   unsigned int numPoints = mPoints.size();
   if (numPoints == 0)
   {
      return false;
   }

   PlotViewImp* pPlot = getPlot();
   VERIFY(pPlot != NULL);

   dMinX = 1e38;
   dMinY = 1e38;
   dMaxX = -1e38;
   dMaxY = -1e38;

   for (unsigned int i = 0; i < numPoints; i++)
   {
      LocationType point = mPoints.at(i);

      double dWorldX = 0.0;
      double dWorldY = 0.0;

      pPlot->translateDataToWorld(point.mX, point.mY, dWorldX, dWorldY);

      if (dWorldX < dMinX)
      {
         dMinX = dWorldX;
      }

      if (dWorldY < dMinY)
      {
         dMinY = dWorldY;
      }

      if (dWorldX > dMaxX)
      {
         dMaxX = dWorldX;
      }

      if (dWorldY > dMaxY)
      {
         dMaxY = dWorldY;
      }
   }

   return true;
}
Beispiel #3
0
bool TextImp::getExtents(double& dMinX, double& dMinY, double& dMaxX, double& dMaxY)
{
   PlotViewImp* pPlot = getPlot();
   if (pPlot == NULL)
   {
      return false;
   }

   double dScreenX = 0;
   double dScreenY = 0;
   pPlot->translateDataToScreen(mLocation.mX, mLocation.mY, dScreenX, dScreenY);

   QFontMetrics ftMetrics(mFont);
   int iHeight = ftMetrics.height();
   int iWidth = ftMetrics.width(mText);

   double dScreenExtentX = dScreenX + iWidth;
   double dScreenExtentY = dScreenY + iHeight;

   pPlot->translateDataToWorld(mLocation.mX, mLocation.mY, dMinX, dMinY);
   pPlot->translateScreenToWorld(dScreenExtentX, dScreenExtentY, dMaxX, dMaxY);

   return true;
}
Beispiel #4
0
void CurveImp::draw()
{
   if (isVisible() == false)
   {
      return;
   }

   unsigned int numPoints = mPoints.size();
   if (numPoints == 0)
   {
      return;
   }

   glColor3ub(mColor.red(), mColor.green(), mColor.blue());
   glLineWidth(mLineWidth);

   if (mLineStyle != SOLID_LINE)
   {
      glEnable(GL_LINE_STIPPLE);

      if (mLineStyle == DASHED)
      {
         glLineStipple(3, 0x3f3f);
      }
      else if (mLineStyle == DOT)
      {
         glLineStipple(2, 0x1111);
      }
      else if (mLineStyle == DASH_DOT)
      {
         glLineStipple(2, 0x11ff);
      }
      else if (mLineStyle == DASH_DOT_DOT)
      {
         glLineStipple(2, 0x24ff);
      }
   }

   glBegin(GL_LINE_STRIP);

   PlotViewImp* pPlot = getPlot();
   VERIFYNRV(pPlot != NULL);

   double dWorldX = 0.0;
   double dWorldY = 0.0;

   unsigned int i = 0;
   for (i = 0; i < numPoints; i++)
   {
      LocationType point = mPoints.at(i);
      pPlot->translateDataToWorld(point.mX, point.mY, dWorldX, dWorldY);
      glVertex2d(dWorldX, dWorldY);
   }

   glEnd();

   if (mLineStyle != SOLID_LINE)
   {
      glDisable(GL_LINE_STIPPLE);
   }

   glLineWidth(1);

   if (isSelected() == true)
   {
      for (i = 0; i < numPoints; i++)
      {
         LocationType point = mPoints.at(i);

         double dScreenX = 0;
         double dScreenY = 0;
         pPlot->translateDataToScreen(point.mX, point.mY, dScreenX, dScreenY);

         double dX1 = dScreenX - 4;
         double dY1 = dScreenY - 4;
         double dX2 = dScreenX + 4;
         double dY2 = dScreenY + 4;

         double dPixelX1 = 0.0;
         double dPixelY1 = 0.0;
         double dPixelX2 = 0.0;
         double dPixelY2 = 0.0;

         pPlot->translateScreenToWorld(dX1, dY1, dPixelX1, dPixelY1);
         pPlot->translateScreenToWorld(dX2, dY2, dPixelX2, dPixelY2);

         glBegin(GL_POLYGON);
         glVertex2d(dPixelX1, (dPixelY1 + dPixelY2) / 2);
         glVertex2d((dPixelX1 + dPixelX2) / 2, dPixelY1);
         glVertex2d(dPixelX2, (dPixelY1 + dPixelY2) / 2);
         glVertex2d((dPixelX1 + dPixelX2) / 2, dPixelY2);
         glEnd();
      }
   }
}
Beispiel #5
0
void PointImp::draw(LocationType pixelSize)
{
   if (isVisible() == false)
   {
      return;
   }

   PlotViewImp* pPlot = dynamic_cast<PlotViewImp*>(getPlot());
   VERIFYNRV(pPlot != NULL);

   if (pixelSize.mX == 0.0)
   {
      pixelSize.mX = 1.0;
   }

   if (pixelSize.mY == 0.0)
   {
      pixelSize.mY = 1.0;
   }

   double dSymbolSizeX = mSymbolSize / pixelSize.mX;
   double dSymbolSizeY = mSymbolSize / pixelSize.mY;
   double dWorldX = 0.0;
   double dWorldY = 0.0;

   pPlot->translateDataToWorld(mLocation.mX, mLocation.mY, dWorldX, dWorldY);

   // Increase point size when selected
   if (isSelected() == true)
   {
      switch (pPlot->getSelectionDisplayMode())
      {
      case SYMBOL_SELECTION: default:
         dSymbolSizeX = (mSymbolSize + 3) / pixelSize.mX;
         dSymbolSizeY = (mSymbolSize + 3) / pixelSize.mY;
         break;

      case INVERT_SELECTION:
         // Invert symbol color and draw slightly enlarged symbol behind it when selected
         glPushMatrix();
         glLineWidth(2);

         // Invert the color
         glColor3ub(255 - mColor.red(), 255 - mColor.green(), 255 - mColor.blue());

         // Draw the inverted symbol
         glTranslatef(dWorldX, dWorldY, 0);
         glScalef( (mSymbolSize + 1) / pixelSize.mX, (mSymbolSize + 1) / pixelSize.mY, 0);
         glCallList(pPlot->getDisplayListIndex() + mSymbol);
         glLineWidth(1);
         glPopMatrix();
         break;
      case BOX_SELECTION:
         // Draw a gray box around the symbol if it is selected
         glPushMatrix();
         glLineWidth(2);
         glColor3ub(212, 208, 200);

         glTranslatef(dWorldX, dWorldY, 0);
         glScalef((mSymbolSize+2) / pixelSize.mX, (mSymbolSize+2) / pixelSize.mY, 0);
         glCallList(pPlot->getDisplayListIndex() + BOX);
         glLineWidth(1);
         glPopMatrix();
         break;
      }
   }

   // Set the color
   glColor3ub(mColor.red(), mColor.green(), mColor.blue());

   glPushMatrix();
   glTranslatef(dWorldX, dWorldY, 0);
   glScalef(dSymbolSizeX, dSymbolSizeY, 0);
   glCallList(pPlot->getDisplayListIndex() + mSymbol);
   glPopMatrix();
}
Beispiel #6
0
void PointSetImp::draw()
{
   if (isVisible() == false)
   {
      return;
   }

   if (mPoints.size() == 0)
   {
      return;
   }

   // Line
   if (mLine == true)
   {
      PlotViewImp* pPlot = getPlot();
      VERIFYNRV(pPlot != NULL);

      if (pPlot->isShadingEnabled() == false)
      {
         glColor3ub(mLineColor.red(), mLineColor.green(), mLineColor.blue());
         glShadeModel(GL_FLAT);
      }
      else
      {
         glShadeModel(GL_SMOOTH);
      }
      glLineWidth(mLineWidth);

      if (mLineStyle != SOLID_LINE)
      {
         glEnable(GL_LINE_STIPPLE);

         if (mLineStyle == DASHED)
         {
            glLineStipple(3, 0x3f3f);
         }
         else if (mLineStyle == DOT)
         {
            glLineStipple(2, 0x1111);
         }
         else if (mLineStyle == DASH_DOT)
         {
            glLineStipple(2, 0x11ff);
         }
         else if (mLineStyle == DASH_DOT_DOT)
         {
            glLineStipple(2, 0x24ff);
         }
      }

      glBegin(GL_LINE_STRIP);

      double dWorldX = 0.0;
      double dWorldY = 0.0;

      vector<Point*>::iterator iter = mPoints.begin();
      while (iter != mPoints.end())
      {
         Point* pPoint = NULL;
         pPoint = *iter;
         if (pPoint != NULL)
         {
            const LocationType& point = pPoint->getLocation();
            pPlot->translateDataToWorld(point.mX, point.mY, dWorldX, dWorldY);
            if (pPlot->isShadingEnabled() == true)
            {
               ColorType color = pPoint->getColor();
               glColor3ub(color.mRed, color.mGreen, color.mBlue);
            }
            glVertex2d(dWorldX, dWorldY);
         }

         ++iter;
      }

      glEnd();

      if (mLineStyle != SOLID_LINE)
      {
         glDisable(GL_LINE_STIPPLE);
      }

      glLineWidth(1);

      // Turn the shade model back to flat to not impact other types of plot objects
      glShadeModel(GL_FLAT);
   }
   
   // Points
   LocationType pixelSize(1.0, 1.0);

   PlotViewImp* pPlot = dynamic_cast<PlotViewImp*> (getPlot());
   if (pPlot != NULL)
   {
      pixelSize = pPlot->getPixelSize();
   }

   vector<Point*>::iterator iter = mPoints.begin();
   while (iter != mPoints.end())
   {
      PointAdapter* pPoint = NULL;
      pPoint = static_cast<PointAdapter*> (*iter);
      if (pPoint != NULL)
      {
         if ((mSymbols == true) || (mLine == false) || (pPoint->isSelected() == true))
         {
            pPoint->draw(pixelSize);
         }
      }

      ++iter;
   }
}
Beispiel #7
0
void PointImp::draw(LocationType pixelSize)
{
   if (isVisible() == false)
   {
      return;
   }

   PlotViewImp* pPlot = dynamic_cast<PlotViewImp*>(getPlot());
   VERIFYNRV(pPlot != NULL);

   if (pixelSize.mX == 0.0)
   {
      pixelSize.mX = 1.0;
   }

   if (pixelSize.mY == 0.0)
   {
      pixelSize.mY = 1.0;
   }

   double dSymbolSizeX = mSymbolSize / pixelSize.mX;
   double dSymbolSizeY = mSymbolSize / pixelSize.mY;
   double dWorldX = 0.0;
   double dWorldY = 0.0;

   pPlot->translateDataToWorld(mLocation.mX, mLocation.mY, dWorldX, dWorldY);

   // Increase point size when selected
   if (isSelected() == true)
   {
      switch (pPlot->getSelectionDisplayMode())
      {
      case SYMBOL_SELECTION: default:
         dSymbolSizeX = (mSymbolSize + 3) / pixelSize.mX;
         dSymbolSizeY = (mSymbolSize + 3) / pixelSize.mY;
         break;

      case INVERT_SELECTION:
      {
         // Invert the background color and draw slightly enlarged symbol behind it when selected
         glPushMatrix();
         glLineWidth(2);

         // Invert the color
         QColor backgroundColor = pPlot->getBackgroundColor();

         int selectionHue = -1;
         int selectionSaturation = 255;
         int selectionValue = 255;

         int pointHue = mColor.hue();
         int backgroundHue = backgroundColor.hue();
         if ((pointHue > -1) && (backgroundHue > -1))
         {
            selectionHue = (pointHue + backgroundHue) / 2;
            if (abs(pointHue - backgroundHue) < 180)
            {
               selectionHue += 180;
            }
         }
         else if (pointHue > -1)
         {
            selectionHue = pointHue + 180;
         }
         else if (backgroundHue > -1)
         {
            selectionHue = backgroundHue + 180;
         }
         else
         {
            int pointValue = mColor.value();
            int backgroundValue = backgroundColor.value();

            selectionValue = (pointValue + backgroundValue) / 2;
            if (abs(pointValue - backgroundValue) < 128)
            {
               selectionValue += 128;
            }
         }

         while (selectionHue >= 360)
         {
            selectionHue -= 360;
         }

         while (selectionValue >= 256)
         {
            selectionValue -= 256;
         }

         QColor selectionColor = QColor::fromHsv(selectionHue, selectionSaturation, selectionValue);
         glColor3ub(selectionColor.red(), selectionColor.green(), selectionColor.blue());

         // Draw the inverted symbol
         glTranslatef(dWorldX, dWorldY, 0);
         glScalef((mSymbolSize + 2) / pixelSize.mX, (mSymbolSize + 2) / pixelSize.mY, 0);
         glCallList(pPlot->getDisplayListIndex() + mSymbol);
         glLineWidth(1);
         glPopMatrix();
         break;
      }

      case BOX_SELECTION:
         // Draw a gray box around the symbol if it is selected
         glPushMatrix();
         glLineWidth(2);
         glColor3ub(212, 208, 200);

         glTranslatef(dWorldX, dWorldY, 0);
         glScalef((mSymbolSize+2) / pixelSize.mX, (mSymbolSize+2) / pixelSize.mY, 0);
         glCallList(pPlot->getDisplayListIndex() + BOX);
         glLineWidth(1);
         glPopMatrix();
         break;
      }
   }

   // Set the color
   glColor3ub(mColor.red(), mColor.green(), mColor.blue());

   glPushMatrix();
   glTranslatef(dWorldX, dWorldY, 0);
   glScalef(dSymbolSizeX, dSymbolSizeY, 0);
   glCallList(pPlot->getDisplayListIndex() + mSymbol);
   glPopMatrix();
}