QPointF intersects(const LineWrapper &other)/* const */{
        KisVector2D n0 = m_lineEquation.normal();
        KisVector2D n1 = other.m_lineEquation.normal();

        // Ensure vectors have the same direction
        if((n0(0) > 0) != (n1(0) > 0)) {
            n1 = -n1;
        }

        if(qFuzzyCompare(n0(0), n1(0)) &&
           qFuzzyCompare(n0(1), n1(1))) {

            const KisVector2D nearPoint(0,0);
            const KisVector2D farPoint(1e10,1e10);

            KisVector2D otherPt = other.m_lineEquation.projection(nearPoint);
            KisVector2D otherPtProj = m_lineEquation.projection(otherPt);

            KisVector2D newOffset = otherPt + 0.5 * (otherPtProj - otherPt);
            LineEquation tempLine(n0, newOffset);
            // Just throw it somewhere towards infinity...
            return toQPointF(tempLine.projection(farPoint));
        }

        return toQPointF(m_lineEquation.intersection(other.m_lineEquation));
    }
Пример #2
0
void appendPdbTraj(const char* fileName, const Vector3* atomPos, int atomNum, Vector3 sysDim, double beta) {
  String tempLine("ATOM      1  CA  MOL S   1      -6.210  -9.711   3.288  0.00  0.00      ION");
  String line;

  FILE* out = fopen(fileName, "a");
  for (int i = 0; i < atomNum; i++) {
    line = makePdbLine(tempLine, i, "ION", i, atomPos[i], beta);
    fprintf(out, line.val());
    fprintf(out, "\n");
  }
  fprintf(out, "END\n");
  fclose(out);
}
Пример #3
0
void writePdbTraj(const char* fileName, const Vector3* atomPos, int atomNum, Vector3 sysDim, double beta) {
  char s[128];
  sprintf(s, "CRYST1   %.3f   %.3f   %.3f  90.00  90.00  90.00 P 1           1\n", sysDim.x, sysDim.y, sysDim.z);
  
  String sysLine(s);
  String tempLine("ATOM      1  CA  MOL S   1      -6.210  -9.711   3.288  0.00  0.00      ION");
  String line;

  FILE* out = fopen(fileName, "w");
  fprintf(out, sysLine.val());

  for (int i = 0; i < atomNum; i++) {
    line = makePdbLine(tempLine, i, "ION", i, atomPos[i], beta);
    fprintf(out, line.val());
    fprintf(out, "\n");
  }
  fprintf(out, "END\n");
  fclose(out);
}
Пример #4
0
bool File::readHeader()
{
  const unsigned int bufferSize = 4096;
  std::unique_ptr<char[]> buffer(new char[bufferSize]);
  std::memset(buffer.get(), 0, bufferSize);

  //read "UHS\r\n"
  m_Stream.read(buffer.get(), 5);
  if (!m_Stream.good())
    return false;
  //Is it a UHS file?
  if (std::string(buffer.get())!="UHS\r\n")
  {
    throw std::runtime_error("File does not have UHS header!");
    return false;
  }


  std::memset(buffer.get(), 0, 6);

  m_Stream.getline(buffer.get(), bufferSize-1, '\n');
  if (!m_Stream.good())
  {
    throw std::runtime_error("Unable to read main title from file!");
    return false;
  }
  m_MainTitle = std::string(buffer.get());
  removeTrailingCarriageReturn(m_MainTitle);

  //read first hint line number
  std::memset(buffer.get(), 0, 4096);
  m_Stream.getline(buffer.get(), bufferSize-1, '\n');
  if (!m_Stream.good())
  {
    throw std::runtime_error("Unable to read number of first hint line number from file!");
    return false;
  }
  std::string tempLine(std::string(buffer.get()));
  removeTrailingCarriageReturn(tempLine);
  if (!stringToUnsignedInt<uint32_t>(tempLine, m_FirstHintLine))
  {
    throw std::runtime_error("\""+tempLine+"\" is not an integer!");
    return false;
  }

  //read last hint line number
  std::memset(buffer.get(), 0, 4096);
  m_Stream.getline(buffer.get(), bufferSize-1, '\n');
  if (!m_Stream.good())
  {
    throw std::runtime_error("Unable to read number of last hint line number from file!");
    return false;
  }
  tempLine = std::string(buffer.get());
  removeTrailingCarriageReturn(tempLine);
  if (!stringToUnsignedInt<uint32_t>(tempLine, m_LastHintLine))
  {
    throw std::runtime_error("\""+tempLine+"\" is not an integer!");
    return false;
  }

  //header part is done here
  return true;
}
Пример #5
0
bool PC_TransparencySpec::TransparencySetup()
{
    int nobj = plotDef.plotObjList.Size();
    objectIsTransparent.AllocAndFill(nobj, false);

    int nanno = plotDef.annoObjList.Size();
    annoIsTransparent.AllocAndFill(nanno, false);
    if (!useTransparency)
        return false;

    // get initial counts & objects
    int tranCount = 0;
    for (int i = 0; i < nobj; i++)
    {
        const PlotObjC& nextObj = plotDef.plotObjList.GetRef(i);

        if (nextObj.doPlot && nextObj.StatusOK() && nextObj.SupportsTransparency())
        {
            int objCount = nextObj.GetnTransObjects();
            if ((objCount > 0) &&
                    (transparencyGroups[nextObj.GetTransGroup()].groupIsTransparent))
            {
                objectIsTransparent[i] = true;
                tranCount += objCount;
            }
        }
    }

    int annoTranCount = 0;
    for (int i = 0; i < nanno; i++)
    {
        const AnnoObjC& nextObj = plotDef.annoObjList.GetRef(i);

        if (nextObj.doPlot && nextObj.StatusOK() && nextObj.SupportsTransparency())
        {
            if (transparencyGroups[nextObj.GetTransGroup()].groupIsTransparent)
            {
                annoIsTransparent[i] = true;
                annoTranCount++;
            }
        }
    }

    annoOnly = (tranCount == 0);
    if (annoOnly)
        return (annoTranCount > 0);

    PC_View currView = plotDef.GetCurrentView();

    Coord3D zeroOffset(0.0, 0.0, 0.0);
    Coord3D minCoord = plotDef.GetNormalizedCoord(currView.viewLimits.minLim, zeroOffset);
    Coord3D maxCoord = plotDef.GetNormalizedCoord(currView.viewLimits.maxLim, zeroOffset);;

    Line3D tempLine(minCoord, maxCoord);
    double maxLength = tempLine.Length() * 2.0;
    Coord3D lookAtPoint = tempLine.PointOnLine(0.5);

    double elevAngle = Radians(currView.elevation);
    double rotAngle = Radians(currView.azimuth);

    double dz = maxLength * sin(elevAngle);
    double xylen = maxLength * cos(elevAngle);

    double dx = - xylen * sin(rotAngle);
    double dy = - xylen * cos(rotAngle);

    eyeCoord = lookAtPoint;
    eyeCoord.cX += dx;
    eyeCoord.cY += dy;
    eyeCoord.cZ += dz;

    tranObjectList.Alloc(tranCount);
    tranCount = 0;
    Coord3D objCoord;
    double minDist, maxDist;
    for (int i = 0; i < nobj; i++)
        if (objectIsTransparent[i])
        {
            PlotObjC& nextObj = plotDef.plotObjList.GetRef(i);
            nextObj.SetupForGetCoord();
            int objCount = nextObj.GetnTransObjects();
            for (int j = 0; j < objCount; j++)
            {
                ObjectTransDesc& nextDesc = tranObjectList[tranCount];
                objCoord = nextObj.GetTransObjectCoord(j);
                if (objCoord.CoordIsNull())
                    continue;

                objCoord = plotDef.GetNormalizedCoord(objCoord, nextObj.offsetCoord);
                if (objCoord.CoordIsNull())
                    continue;

                double nextDist = objCoord.Distance(eyeCoord);
                if (tranCount == 0)
                {
                    minDist = nextDist;
                    maxDist = nextDist;
                }
                else
                {
                    if (nextDist < minDist)
                        minDist = nextDist;
                    else if (nextDist > maxDist)
                        maxDist = nextDist;
                }

                nextDesc.objDist = nextDist;
                nextDesc.objRef = &nextObj;
                nextDesc.objIndex = j;
                nextDesc.objGroup = nextObj.GetTransGroup();
                tranCount++;
            }
        }

    if (tranCount == 0)
    {
        annoOnly = (annoTranCount > 0);
        objectIsTransparent.FillToAlloc(false);
        return annoOnly;
    }

    int ndistanceGroups = tranCount / 500;

    // now place in buckets for sorting
    if (ndistanceGroups < 2)
    {
        ndistanceGroups = 1;
        // easy just use 1 bucket
        objectSortArray.AllocAndSetSize(1);
        objectSortArray[0].Alloc(tranCount);
        for (int i = 0; i < tranCount; i++)
            objectSortArray[0] += &(tranObjectList[i]);
    }
    else
    {
        if (ndistanceGroups > 5000)
            ndistanceGroups = 5000;
        if (ndistanceGroups < 100)
            ndistanceGroups = 100;

        objectSortArray.AllocAndSetSize(ndistanceGroups);
        for (int i = 0; i < ndistanceGroups; i++)
            objectSortArray[i].SetResizable(tranCount / ndistanceGroups * 5);

        double deltaDist = (maxDist - minDist) / double(ndistanceGroups);
        for (int i = 0; i < tranCount; i++)
        {
            ObjectTransDesc& nextDesc = tranObjectList[i];
            int currGroup = int((nextDesc.objDist - minDist) / deltaDist);
            if (currGroup >= ndistanceGroups)
                currGroup = ndistanceGroups - 1;
            if (currGroup < 0)
                currGroup = 0;
            objectSortArray[currGroup] += &nextDesc;
        }
    }

    // now sort each
    for (int k = 0; k < objectSortArray.Size(); k++)
    {
        ObjPtrList& currList = objectSortArray[k];
        QSort(currList, 0, currList.UpperBound());
    }

    return true;
}
/*------------------------------------------------------------------------------
| DrawingArea::mouseMoved                                                      |
|                                                                              |
| Handle button 1 down mouse move events.  This allows data points to be       |
| moved while the object is drawn with a rubber band effect.                   |
------------------------------------------------------------------------------*/
Boolean DrawingArea::mouseMoved( IMouseEvent& event )
{
  IPoint point(event.mousePosition());
  if ( hasPointerCaptured() )
  {
    IRectangle windowRect(this->rect());
    windowRect.moveTo(IPoint(0,0));
    if (!windowRect.contains(point))
    {
      if ((short)point.x() < (short)windowRect.left())
        point.setX(windowRect.left());
      else if ((short)point.x() > (short)windowRect.right())
        point.setX(windowRect.right());
      else if ((short)point.y() < (short)windowRect.bottom())
        point.setY(windowRect.bottom());
      else if ((short)point.y() > (short)windowRect.top())
        point.setY(windowRect.top());

      IPoint mapPt( IWindow::mapPoint( point,
                                       this->handle(),
                                       IWindow::desktopWindow()->handle()));

      IWindow::movePointerTo( mapPt );
    }
  }

  // If we're not moving an object
  if (!moveGraphic)
  {
    if (( drawState() == drawing ) || ( drawState() == waitingForInput ))
    {
      switch (currentObj)
      {
        case move:
        break;
        case eraser:
        break;
        case stylecan:
        break;
        case line:
          ((IGLine*)iGraphic)->drawOn( gc );
          ((IGLine*)iGraphic)->setEndingPoint( point );
          ((IGLine*)iGraphic)->drawOn( gc );
        break;
        case freehand:
          ((IGPolygon*)iGraphic)->addPoint( point );
          ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
        break;
        case rectangle:
        {
          IRectangle rc(((IGRectangle*)iGraphic)->enclosingRect());
          iGraphic->drawOn( gc );
          rc.sizeTo( rc.size() + point - previousPt );
          ((IGRectangle*)iGraphic)->setEnclosingRect( rc );
          iGraphic->drawOn( gc );
          previousPt = point;
        }
        break;
        case ellipse:
        {
          iGraphic->drawOn( gc );
          IRectangle rc(((IGEllipse*)iGraphic)->enclosingRect());
          rc.sizeTo( rc.size() + point - previousPt );
          ((IGEllipse*)iGraphic)->setEnclosingRect( rc );
          iGraphic->drawOn( gc );
          previousPt = point;
        }
        break;
        case polyline:
        case polygon:
          ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
          ((IGPolyline*)iGraphic)->setPoint(
                           ((IGPolyline*)iGraphic)->numberOfPoints()-1, point );
          ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
        break;
        case arc:
          if (drawState() != waitingForInput)
          {
            if ( pointCount == 2 )
            {
              IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), previousPt );
              tempLine.drawOn( gc );
              tempLine.setEndingPoint( point );
              tempLine.drawOn( gc );
              previousPt = point;
            } else if ( pointCount == 3 ) {
              iGraphic->drawOn( gc );
              ((IG3PointArc*)iGraphic)->setEndingPoint( point );
              iGraphic->drawOn( gc );
            }
          } /* endif */
        break;
        case pie:
        case chord:
          if (drawState() != waitingForInput)
          {
            if ( pointCount == 2 )
            {
              IGLine tempLine( ((IGPie*)iGraphic)->enclosingRect().center(), previousPt );
              tempLine.drawOn( gc );
              tempLine.setEndingPoint( point );
              tempLine.drawOn( gc );
              previousPt = point;
            } else if ( pointCount == 3 ) {
              iGraphic->drawOn( gc );
              double sweep(angleFromPoints( ((IGPie*)iGraphic)->enclosingRect().center(), point ));
              if ( sweep < ((IGPie*)iGraphic)->startAngle() )
                ((IGPie*)iGraphic)->setSweepAngle( 360.0 -
                                    ( ((IGPie*)iGraphic)->startAngle() - sweep ));
              else
                ((IGPie*)iGraphic)->setSweepAngle( sweep -
                                                ((IGPie*)iGraphic)->startAngle());
              iGraphic->drawOn( gc );
            }
          } /* endif */
        break;
      } /* endswitch */
    }
  }
  else  // We are moving a graphic
  {
    moveRect.drawOn( gc );
    moveRect.translateBy( point - previousPt );
    moveRect.drawOn( gc );
    previousPt = point;
  }
  return false;
}
/*------------------------------------------------------------------------------
| DrawingArea::button1Up                                                       |
|                                                                              |
| Handle button 1 up events.  This indicates a data points final location.     |
------------------------------------------------------------------------------*/
DrawingArea& DrawingArea::button1Up( const IPoint& point )
{
  if ( drawState() == drawing )
  {
    switch (currentObj)
    {
      case move:
      break;
      case eraser:
      break;
      case stylecan:
      break;
      case line:
        ((IGLine*)iGraphic)->setEndingPoint( point );
        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
      break;
      case freehand:
        ((IGPolygon*)iGraphic)->addPoint( point );
        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
      break;
      case rectangle:
      {
        IRectangle rc(((IGRectangle*)iGraphic)->enclosingRect());
        rc.sizeTo( rc.size() + point - previousPt );
        ((IGRectangle*)iGraphic)->setEnclosingRect( rc );
        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
      }
      break;
      case ellipse:
      {
        IRectangle rc(((IGEllipse*)iGraphic)->enclosingRect());
        rc.sizeTo( rc.size() + point - previousPt );
        ((IGEllipse*)iGraphic)->setEnclosingRect( rc );

        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
      }
      break;
      case polyline:
      case polygon:
        previousPt = point;
        ((IGPolyline*)iGraphic)->setPoint(
                         ((IGPolyline*)iGraphic)->numberOfPoints()-1, point );
        setDrawState( waitingForInput );
      break;
      case arc:
      if ( pointCount == 2 )
      {
        ((IG3PointArc*)iGraphic)->setIntermediatePoint( point );
        gc.setMixMode( IGraphicBundle::xor ).setPenColor( IColor::white );
        IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), previousPt );
        tempLine.drawOn( gc );
        tempLine.setEndingPoint( point );
        tempLine.drawOn( gc );
        setDrawState( waitingForInput );
      }
      else if ( pointCount == 3 )
      {
        gc.setMixMode( IGraphicBundle::xor ).setPenColor( IColor::white );
        iGraphic->drawOn( gc );
        ((IG3PointArc*)iGraphic)->setEndingPoint( point );
        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
        pointCount = 0;
      }
      break;
      case pie:
      case chord:
      if ( pointCount == 2 )
      {
        gc.setMixMode( IGraphicBundle::xor ).setPenColor( IColor::white );
        setDrawState( waitingForInput );
        IPoint centerPt(((IGPie*)iGraphic)->enclosingRect().center());

        ((IGPie*)iGraphic)->setStartAngle( angleFromPoints( centerPt, point ));

        unsigned a(abs(centerPt.x()) - abs(point.x()));
        unsigned b(abs(centerPt.y()) - abs(point.y()));

        unsigned long radius((unsigned long)sqrtl(a*a + b*b));

        ((IGPie*)iGraphic)->setEnclosingRect(
           ((IGPie*)iGraphic)->enclosingRect().expandBy(radius));
      }
      else if ( pointCount == 3 )
      {
        gc.setMixMode( IGraphicBundle::xor ).setPenColor( IColor::white );
        iGraphic->drawOn( gc );

        double sweep(angleFromPoints(
                              ((IGPie*)iGraphic)->enclosingRect().center(), point ));

        if ( sweep < ((IGPie*)iGraphic)->startAngle() )
          ((IGPie*)iGraphic)->setSweepAngle( 360.0 -
                                ( ((IGPie*)iGraphic)->startAngle() - sweep ));
        else
          ((IGPie*)iGraphic)->setSweepAngle( sweep -
                                            ((IGPie*)iGraphic)->startAngle());

        iGraphic->setGraphicBundle( currentBundle );
        iGraphic->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *iGraphic );
        pointCount = 0;
      }
      break;
      case text:
      {
        IString input;

        IDynamicLinkLibrary reslib("CPPWV53R");

        if (point.x() % 2)
          input = reslib.loadString( STRING_SAMPLE1 );
        else if ((point.y() % 5)==1)
          input = reslib.loadString( STRING_SAMPLE3 );
        else if ((point.y() % 5)==3)
          input = reslib.loadString( STRING_SAMPLE4 );
        else
          input = reslib.loadString( STRING_SAMPLE2 );

        IGString* text = new IGString( input.x2c(), point, currentFont());
//      IGString* text = new IGString( "Doodle", point, currentFont());
        text->rotateBy( 10.0, point );
        text->setGraphicBundle( currentBundle );
        text->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *text );
      }
      break;
      case bitmap:
      {
        IGBitmap *bmp;
//      if (bitmapFileName().length() > 0)
//      {
//        bmp = new IGBitmap(bitmapFileName());
//      }

        // Select a bitmap to load
        IDynamicLinkLibrary reslib("CPPWV53R");

        if (point.x() % 2)
          bmp = new IGBitmap(reslib.loadBitmap( BITMAP_SAMPLE1 ));
        else if ((point.y() % 5)==1)
          bmp = new IGBitmap(reslib.loadBitmap( BITMAP_SAMPLE3 ));
        else if ((point.y() % 5)==3)
          bmp = new IGBitmap(reslib.loadBitmap( BITMAP_SAMPLE4 ));
        else
          bmp = new IGBitmap(reslib.loadBitmap( BITMAP_SAMPLE2 ));

        bmp->moveTo( point );
        bmp->drawOn( gc );
        setDrawState( notDrawing );
        graphicList()->addAsLast( *bmp );
      }
      break;
    } /* endswitch */
  } /* endif */
  else  // not drawing
  {
    switch (currentObj)
    {
      case move:
        if (moveGraphic && capturePointer)
        {
          moveRect.translateBy( point - previousPt );
          moveRect.drawOn( gc );
          moveRect.resetTransformMatrix();
          this->refresh( moveRect.boundingRect(gc).expandBy(2) );
          moveGraphic->translateBy( point - startingPt );
          moveGraphic->drawOn( gc );
          moveGraphic = 0;
          capturePointer(false);
        }
      break;
    }
  }
  return *this;
}
/*------------------------------------------------------------------------------
| DrawingArea::button1Down                                                     |
|                                                                              |
| Handle button 1 down messages.  This event indicates a new graphic object is |
| to be created of additional data points to add to an existing graphic object.|
------------------------------------------------------------------------------*/
DrawingArea& DrawingArea::button1Down( const IPoint& point )
{
  switch (currentObj)
  {
    case move: // Button 1 drag
      if (drawState() == notDrawing)
      {
        moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
        if ( moveGraphic )
        {
          moveRect.setEnclosingRect(moveGraphic->boundingRect( gc ));
          previousPt = point;
          startingPt = point;
          capturePointer();
        }
      }
    break;
    case eraser:
      {
        // Delete the object under the pointer
        moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
        if ( moveGraphic )
        {
          moveRect.setEnclosingRect(moveGraphic->boundingRect( gc ));
          IGList::Cursor cursor( *graphicList(), gc, point );
          for (cursor.setToFirst(); cursor.isValid(); cursor.setToNext())
          {
             IGraphic* graphic(&(graphicList()->graphicAt(cursor)));
             if (graphic == moveGraphic)
             {
               graphicList()->removeAt(cursor);
               delete graphic;
               this->refresh( moveRect.boundingRect(gc).expandBy(2) );
               moveRect.resetTransformMatrix();
               moveGraphic = 0;
               break;
             }
          }
        }
      }
    break;
    case stylecan:
    {
      // Change all objects to the current pen and fill color.
      IRectangle tempRect;
      moveGraphic = graphicList()->topGraphicUnderPoint( point, gc );
      if( moveGraphic )
      {
        tempRect = moveGraphic->boundingRect( gc );
        moveGraphic->setGraphicBundle( currentBundle );
        moveGraphic->drawOn( gc );
        tempRect |= moveGraphic->boundingRect( gc );
        this->refresh( tempRect.expandBy(2) );
        moveGraphic = 0;
      }
    }
    break;
    case line:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGLine( startingPt, previousPt );
      setDrawState();
    break;
    case freehand:
      iGraphic = new IGPolygon(IPointArray());
      ((IGPolygon*)iGraphic)->addPoint( point );
      setDrawState();
    break;
    case rectangle:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGRectangle(IRectangle(startingPt, previousPt));
      setDrawState();
    break;
    case ellipse:
      startingPt = point;
      previousPt = point;
      iGraphic = new IGEllipse( startingPt, 0L );
      setDrawState();
    break;
    case polyline:
    case polygon:
      if (drawState() == notDrawing)
      {
        startingPt = point;
        previousPt = point;
        if (currentObj == polyline)
          iGraphic = new IGPolyline(IPointArray());
        else
          iGraphic = new IGPolygon(IPointArray());

        ((IGPolyline*)iGraphic)->addPoint( startingPt );
        ((IGPolyline*)iGraphic)->addPoint( previousPt );
        setDrawState();
      }
      else
      {
        ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
        ((IGPolyline*)iGraphic)->addPoint( point );
        ((IGPolyline*)iGraphic)->IGPolyline::drawOn( gc );
      }
    break;
    case arc:
      pointCount++;
      if (drawState() == notDrawing)
      {
        iGraphic = new IG3PointArc( point, IPoint(0,0), IPoint(0,0) );
        startingPt = point;
        previousPt = point;
      }
      else if ( pointCount == 2 )
      {
        previousPt = point;
        IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), point );
        tempLine.drawOn( gc );
      }
      else if ( pointCount == 3 )
      {
        IGLine tempLine( ((IG3PointArc*)iGraphic)->startingPoint(), previousPt );
        tempLine.drawOn( gc );
        previousPt = point;
        ((IG3PointArc*)iGraphic)->setEndingPoint( point );
        iGraphic->drawOn( gc );
      }
      setDrawState();
    break;
    case pie:
    case chord:
      pointCount++;
      if (drawState() == notDrawing)
      {
        if (currentObj == pie)
          iGraphic = new IGPie( IRectangle(), 0, 0);
        else
          iGraphic = new IGChord( IRectangle(), 0, 0);

        ((IGPie*)iGraphic)->setEnclosingRect(
                             ((IGPie*)iGraphic)->enclosingRect().centerAt( point ));
        startingPt = point;
        previousPt = point;
      }
      else if ( pointCount == 2 )
      {
        previousPt = point;
        IGLine tempLine( ((IGPie*)iGraphic)->enclosingRect().center(), point );
        tempLine.drawOn( gc );
      }
      else if ( pointCount == 3 )
      {
        IGLine tempLine( ((IGPie*)iGraphic)->enclosingRect().center(), previousPt );
        tempLine.drawOn( gc );
        previousPt = point;
        double sweep(angleFromPoints( ((IGPie*)iGraphic)->enclosingRect().center(), point ));
        if ( sweep < ((IGPie*)iGraphic)->startAngle() )
          ((IGPie*)iGraphic)->setSweepAngle( 360.0 -
                                ( ((IGPie*)iGraphic)->startAngle() - sweep ));
        else
          ((IGPie*)iGraphic)->setSweepAngle( sweep -
                                            ((IGPie*)iGraphic)->startAngle());
        iGraphic->drawOn( gc );
      }
      setDrawState();
    break;
    case text:
      setDrawState();
    break;
    case bitmap:
      setDrawState();
    break;
  } /* endswitch */
  return *this;
}