Beispiel #1
0
void QPaintWidget::drawCircleLine(QPainter *ppainter)
{

//    double x1 = kPadding;
//    double x2 = canvasWidth();

//    double a = ( triangle.points[triangle.i].y() -  triangle.points[triangle.j].y() ) /   ( triangle.points[triangle.i].x() -  triangle.points[triangle.j].x() );
//    double b =  triangle.points[triangle.i].y()  - a * triangle.points[triangle.i].x();

//    double y1 = scalePointX( a*x1  +b );
//    double y2 = scalePointY( a*x2 + b );

    if (triangle.min)
    {
        double x1 = circle.pos.x();
        double y1 = circle.pos.y();
        double x2 = triangle.points[triangle.j].x();
        double y2 = triangle.points[triangle.j].y();

        ppainter->save();

        ppainter->setPen(QPen(Qt::red,2,Qt::SolidLine));
        ppainter->drawLine(  scalePoint ( QPointF(x1,y1) ),  scalePoint ( QPointF(x2, y2) ) );

        ppainter->restore();
    }
}
Beispiel #2
0
void AusReihe::OnLButtonDown(UINT nFlags, CPoint point)
{

	if (rahmen.PtInRect(point))
	{
		CSize dataRangeHeight, dataRangeWidth, windowRangeHeight, windowRangeWidth;
		dataRangeHeight = CSize(DemoData.minimum(m_selection), DemoData.maximum(m_selection));
		dataRangeWidth = CSize(0, DemoData.get_anz_s()-1);
		windowRangeHeight = CSize(paddingTop, rahmen.Height() - paddingHeight);
		windowRangeWidth = CSize(rahmen.left + paddingLeft, rahmen.right - paddingRight);
		
		//int spalte = scalePoint(point.x, &windowRangeWidth, &dataRangeWidth);
		for (int spalte = 0; spalte < DemoData.get_anz_s(); spalte++)
		{
			CPoint p = CPoint(
				scalePoint(spalte, &dataRangeWidth, &windowRangeWidth),
				rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, spalte), &dataRangeHeight, &windowRangeHeight)
				);
			CRect hitF = CRect(p.x - 10, p.y - 10, p.x + 10, p.y + 10);
			if (hitF.PtInRect(point))
			{
				infoflag[spalte] = !infoflag[spalte];
				hitF.InflateRect(40, 40);
				RedrawWindow(hitF);
				break;
			}
		}

	}
	CDialog::OnLButtonDown(nFlags, point);
}
Beispiel #3
0
void AusReihe::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	if (rahmen.PtInRect(point))
	{
		CSize dataRangeHeight, dataRangeWidth, windowRangeHeight, windowRangeWidth;
		dataRangeHeight = CSize(DemoData.minimum(m_selection), DemoData.maximum(m_selection));
		dataRangeWidth = CSize(0, DemoData.get_anz_s() - 1);
		windowRangeHeight = CSize(paddingTop, rahmen.Height() - paddingHeight);
		windowRangeWidth = CSize(rahmen.left + paddingLeft, rahmen.right - paddingRight);

		//int spalte = scalePoint(point.x, &windowRangeWidth, &dataRangeWidth);
		for (int spalte = 0; spalte < DemoData.get_anz_s(); spalte++)
		{
			CPoint p = CPoint(
				scalePoint(spalte, &dataRangeWidth, &windowRangeWidth),
				rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, spalte), &dataRangeHeight, &windowRangeHeight)
				);
			CRect hitF = CRect(p.x - 10, p.y - 10, p.x + 10, p.y + 10);
			if (hitF.PtInRect(point))
			{
				AusReiheEin ein;
				ein.wert = DemoData.get_wert(m_selection, spalte);
				if (ein.DoModal() == IDOK)
				{
					DemoData.set_wert(m_selection, spalte, ein.wert);
					GetParentFrame()->GetActiveDocument()->SetModifiedFlag();
					RedrawWindow();
				}
				break;
			}
		}

	}
	CDialog::OnLButtonDblClk(nFlags, point);
}
Beispiel #4
0
Datei: k.cpp Projekt: mayah/ICPC
point calculateTwoTetrahedraCenter(const point &a, const point &b, const point &c, const point &d, const point &e) {
	double volumeABCD = calculateTetrahedraVolume(a, b, c, d);
	double volumeABCE = calculateTetrahedraVolume(a, b, c, e);
	point centerABCD = calculaTetetrahedraCenter(a, b, c, d);
	point centerABCE = calculaTetetrahedraCenter(a, b, c, e);
	
	return scalePoint(addPoints(scalePoint(centerABCD, volumeABCD), scalePoint(centerABCE, volumeABCE)), 1.0 / (volumeABCD + volumeABCE));
}
Beispiel #5
0
QTriangle QPaintWidget::scaleTrianglePoints(QTriangle triangle)
{
    for (int i = 0; i < 3; i++)
        triangle.points[i] = scalePoint(triangle.points[i]);
    return triangle;

}
QRect RedEyeDetection::getStartingRectangle(const QSize &imageSize,
                                            const QSize &fullImageSize) const
{
    int tolerance = (priv->tapErrorTolerance <= 0 ? priv->eyeRadius : priv->tapErrorTolerance);
    //if tapErrorTolerance is unset, we user eyeRadius
    QRect rect = QRect(scalePoint(QPoint(priv->center.x() - tolerance,
					 priv->center.y() - tolerance),
                                  fullImageSize, imageSize),
		       scalePoint(QPoint(priv->center.x() + tolerance,
					 priv->center.y() + tolerance),
                                  fullImageSize, imageSize));

    rect &= QRect(QPoint(0, 0), imageSize);

    return rect;
}
Beispiel #7
0
    void QuatTrackBall::roll_ball(const Vec2i& v)
    {
        if(v[0] < 0 || v[0] >= static_cast<int>(width)
           || v[1] < 0 || v[1] >= static_cast<int>(height))
            return;
        
        Vec2f w = scalePoint(v);
        
        switch (current_action)
        {
			case ROTATE_ACTION:
                rotate(w);
                break;
                
			case PAN_ACTION:
                pan(w);
                break;
                
			case ZOOM_ACTION:
                zoom(w);
                break;
            case NO_ACTION:
            default:
                break;
        }
        last_pos = w;
    }
Point* findFourthVertex(Point * a, Point *b ,Point *c ){
	//http://math.stackexchange.com/questions/463867/find-the-corner-of-a-tetrahedron
	//https://answers.yahoo.com/question/index?qid=20091025020201AAYTQrJ
	//Want to find Perpendicular bisector plane for AB and AC

	//Find legnth of side. 
	Vector * ab = subPointsNew(a,b);
	float side = magnitude(ab);
	free(ab);
	//Finding PBP for AB
	Point * centroid = findCentroid(a,b,c);
	Plane * pbp_ab = findPBP(a,b);
	Plane * pbp_ac = findPBP(a,c);
	
	//Finding plane intersection line
	Vector * dirVect = crossProduct((Point *)pbp_ab, (Point*) pbp_ac);
	//Calculate direction vector
	normalizeVector(dirVect, magnitude(dirVect));
	
	//Want to calculate amount to extend from centroid to get forth point
	scalePoint(dirVect, side * SIDE_TO_AH_RATIO);
	Point * ans = addPointsNew(dirVect, centroid);	
		
	free(centroid);
	free(dirVect);
	free(pbp_ab);
	free(pbp_ac);
	return ans;
}
Beispiel #9
0
int
CurveOHLC::command (PluginData *pd)
{
  int rc = 0;

  QStringList cl;
  cl << "type" << "info" << "scalePoint" << "highLowRange" << "fill";
  
  switch (cl.indexOf(pd->command))
  {
    case 0: // type
      pd->type = QString("curve");
      rc = 1;
      break;
    case 1: // info
      rc = info(pd);
      break;
    case 2: // scalePoint
      rc = scalePoint(pd);
      break;
    case 3: // highLowRange
      rc = highLowRange(pd);
      break;
    case 4: // fill
      rc = fill(pd);
      break;
    default:
      break;
  }
  
  return rc;
}
Beispiel #10
0
static void paintStuff(QPainter *p)
{
    QPaintDevice *screenDevice = QApplication::desktop();
    p->drawRect(scaleRect(QRectF(100, 100, 100, 100), screenDevice, p->device()));
    p->save();
    p->translate(scalePoint(QPointF(10, 10), screenDevice, p->device()));
    p->restore();
    p->drawRect(scaleRect(QRectF(100, 100, 100, 100), screenDevice, p->device()));
}
Beispiel #11
0
 void QuatTrackBall::grab_ball(TrackBallAction act, const Vec2i& v)
 {
     if(v[0] < 0 || v[0] >= static_cast<int>(width)
        || v[1] < 0 || v[1] >= static_cast<int>(height))
         return;
     
     set_position(scalePoint(v));
     current_action = act;
 }
QPolygon RedEyeDetection::scalePolygon(const QPolygon &polygon,
                                       const QSize &scaleBefore,
                                       const QSize &scaleAfter) const
{
    QPolygon newPolygon(polygon);

    for (int i=0; i<newPolygon.size(); i++)
        newPolygon.setPoint(i, scalePoint(newPolygon.point(i),
                                          scaleBefore, scaleAfter));
    return newPolygon;
}
Beispiel #13
0
void QPaintWidget::drawPoints(QPainter *ppainter)
{

    ppainter->save();

    // Drawing general points
    ppainter->setBrush(QBrush(triangle.min ? Qt::gray : Qt::red));
    ppainter->setPen(QPen(triangle.min ? Qt::gray : Qt::red, kDrawPenWidth));
    foreach (QPointF point, points)
    {
        QPointF scalePos = scalePoint(point);
        ppainter->drawEllipse(scalePos.x()-kDrawPointRadius, scalePos.y()-kDrawPointRadius, 2*kDrawPointRadius, 2*kDrawPointRadius);
    }
Beispiel #14
0
TestPoint NelderMead::reflectOrExpand(std::vector<double> centroid, double scale)
{
    TestPoint *maxPoint = worstTestPoint();
    
    std::vector<double> diffVec = centroid;
    subtractPoints(&diffVec, maxPoint->first);
    scalePoint(&diffVec, scale);
    std::vector<double> reflectedVec = centroid;
    addPoints(&reflectedVec, diffVec);
    
    TestPoint reflection = std::make_pair(reflectedVec, 0);
    evaluateTestPoint(&reflection);
    
    return reflection;
}
Beispiel #15
0
Datei: k.cpp Projekt: mayah/ICPC
bool normalizePosition(vector<point> &points) {
	point originalAPosition = points[0];
	
//	printPoints(points);
	for (int i = 0; i < POINT_SIZE; i++) {
		points[i] = subPoints(points[i], originalAPosition);
	}
//	printPoints(points);
	rotator r1 = getRotatorPointMoveXAxis(points[1]);
	for (int i = 0; i < POINT_SIZE; i++) {
		points[i] = rotate(r1, points[i]);
	}
//	printPoints(points);
	if (abs(points[2][1]) < EPS && abs(points[2][2]) < EPS) {
		return false;
	}
	rotator r2 = getRotatorPointMoveXYSurface(points[2]);
	for (int i = 0; i < POINT_SIZE; i++) {
		points[i] = rotate(r2, points[i]);
	}
//	printPoints(points);
	
	double maxHeight = -100000.0;
	double minHeight =  100000.0;
	for (int i = 0; i < POINT_SIZE; i++) {
		maxHeight = max(maxHeight, points[i][2]);
		minHeight = min(minHeight, points[i][2]);
	}
	if (maxHeight > EPS && minHeight < -EPS){
		return false;
	} else if (maxHeight > EPS) {
		return true;
	} else if (minHeight < -EPS) {
		for (int i = 0; i < POINT_SIZE; i++) {
			points[i] = scalePoint(points[i], -1.0);
		}
		return true;
	} else {
		//(maxHeight <= EPS && minHeight >= -EPS)
		//maybe input is broken.
		return false;
	}
	
}
Beispiel #16
0
void NelderMead::reduction()
{
    TestPoint bestPoint = testPoints[0];
    
    for (int i = 1; i < testPoints.size(); i++)
    {
        TestPoint point = testPoints[i];
        
        std::vector<double> diffVec = point.first;
        subtractPoints(&diffVec, bestPoint.first);
        scalePoint(&diffVec, sigma);
        std::vector<double> finalVec = bestPoint.first;
        addPoints(&finalVec, diffVec);
        
        TestPoint contractPoint = std::make_pair(finalVec, 0);
        evaluateTestPoint(&contractPoint);
        
        testPoints[i] = contractPoint;
    }
}
Beispiel #17
0
void TextPlot::printFence(const IFenceDrawPacket & fpacket) {
  // Bouml preserved body begin 00024F85

    Utils::Point2D scaled_point;
    Utils::Point2D prevPoint = fpacket.getFencePoint(0); // Tady by bylo lepsi vrace ukazatel na point...

    unsigned int pointCount = fpacket.getFencePointCount();
    for(unsigned int pointIndex = 1; pointIndex < pointCount; pointIndex++)
    {
        Utils::Point2D currentPoint = fpacket.getFencePoint(pointIndex);
        Utils::Point2D deltaPoint = currentPoint;

        deltaPoint -= prevPoint;

        Q_ASSERT(abs(deltaPoint.x()) <= 1);
        Q_ASSERT(abs(deltaPoint.y()) <= 1);

        char line = ' ';
        if(deltaPoint.x())   // Horizontal line
            line = '_';
        else      // Vertical line
            line = '|';

        scaled_point = scalePoint(currentPoint, 2.0);
        scaled_point += deltaPoint;
        TextScreen[scaled_point.x()][scaled_point.y()].content = line;

        prevPoint = currentPoint;
    }

    /****/
            /*get point

            loop
            get point
            urci smer
            scale 2;
            nacpi do pole*/
                   //
  // Bouml preserved body end 00024F85
}
Beispiel #18
0
void AusReihe::OnPaint()
{
	UpdateData(TRUE);
	CPaintDC dc(this); // device context for painting
	dc.FillRect(rahmen, &stdbrush.white);
	CPen *oldPen = dc.SelectObject(&stdpen.gray1);


	if (m_xraster)
	{
		for (int index = 0; index < DemoData.get_anz_s(); index++)
		{
			int x = paddingLeft + rahmen.left + (index*(rahmen.Width() - paddingWidth)) / (DemoData.get_anz_s() - 1);
			dc.MoveTo(x, rahmen.top + paddingTop);
			dc.LineTo(x, rahmen.bottom - paddingBottom);
		}
	}
	if (m_yraster)
	{
		for (int index = 0; index < anzHorizontalLines; index++)
		{
			int y = paddingTop + rahmen.top + (index*(rahmen.Height() - paddingHeight)) / (anzHorizontalLines-1);
			/*if (y > rahmen.bottom - paddingBottom)
				y = rahmen.bottom - paddingBottom;*/
			dc.MoveTo(rahmen.left + paddingLeft, y);
			dc.LineTo(rahmen.right - paddingRight, y);
		}
	}

	CSize dataRangeHeight, dataRangeWidth, windowRangeHeight, windowRangeWidth;
	dataRangeHeight = CSize(DemoData.minimum(m_selection), DemoData.maximum(m_selection));
	dataRangeWidth = CSize(0, DemoData.get_anz_s()-1);
	//windowRangeHeight = CSize(rahmen.top + 1*paddingTop, rahmen.bottom - 1*paddingBottom);
	windowRangeHeight = CSize(paddingTop, rahmen.Height()-paddingHeight);
	windowRangeWidth = CSize(rahmen.left + paddingLeft, rahmen.right - 1*paddingRight);
	//draw null line
	dc.SelectObject(&stdpen.black2);
	if ((DemoData.minimum(m_selection) < 0) && (DemoData.maximum(m_selection) > 0))
	{
		int nullLine = rahmen.bottom-scalePoint(0, &dataRangeHeight, &windowRangeHeight);
		dc.MoveTo(rahmen.left + paddingLeft, nullLine);
		dc.LineTo(rahmen.right - paddingRight, nullLine);
	}

	if (m_darstellung == 0)
	{
		CPoint oldP, newP;
		oldP = CPoint(
			scalePoint(0, &dataRangeWidth, &windowRangeWidth),
			rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, 0), &dataRangeHeight, &windowRangeHeight)
			);
		dc.MoveTo(oldP);
		for (int index = 0; index < DemoData.get_anz_s(); index++)
		{
			dc.SelectObject(&stdpen.black5);
			newP = CPoint(
				scalePoint(index, &dataRangeWidth, &windowRangeWidth),
				rahmen.bottom -scalePoint(DemoData.get_wert(m_selection, index), &dataRangeHeight, &windowRangeHeight)
				);
			dc.LineTo(newP);
			dc.SelectObject(&stdpen.gray3);
			dc.MoveTo(oldP);
			dc.LineTo(newP);
			oldP = newP;
		}
		//draw the points

		dc.SelectObject(&stdbrush.gray);
		dc.SelectObject(&stdpen.black1);
		for (int index = 0; index < DemoData.get_anz_s(); index++)
		{
			CPoint loc = CPoint(
				scalePoint(index, &dataRangeWidth, &windowRangeWidth),
				rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, index), &dataRangeHeight, &windowRangeHeight)
				);
			dc.Ellipse(loc.x - 5, loc.y - 5, loc.x + 5, loc.y + 5);
		}
	}
	else
	{
		dc.SelectObject(&stdbrush.gray);
		dc.SelectObject(&stdpen.black1);
		for (int index = 0; index < DemoData.get_anz_s(); index++)
		{
			int loc = scalePoint(index, &dataRangeWidth, &windowRangeWidth);
			//dc.Rectangle(loc - 5, rahmen.bottom - scalePoint(0, &dataRangeHeight, &windowRangeHeight), loc + 5, rahmen.bottom - paddingBottom + nullLine - scalePoint(DemoData.get_wert(m_selection, index), &CSize(DemoData.minimum(m_selection), DemoData.maximum(m_selection)), &CSize(0, rahmen.Height() - paddingHeight)));
			dc.Rectangle(loc, rahmen.bottom - scalePoint(0, &dataRangeHeight, &windowRangeHeight), loc + 10, rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, index), &dataRangeHeight, &windowRangeHeight));
		}
	}

	//Draw all Selected 
	dc.SelectObject(&stdfont.norm);
	dc.SelectObject(&stdpen.black1);
	dc.SelectObject(&stdbrush.yellow);
	dc.SetBkMode(TRANSPARENT);
	for (int index = 0; index < DemoData.get_anz_s(); index++)
	{
		if (infoflag[index])
		{
			CPoint loc = CPoint(
				scalePoint(index, &dataRangeWidth, &windowRangeWidth),
				rahmen.bottom - scalePoint(DemoData.get_wert(m_selection, index), &dataRangeHeight, &windowRangeHeight)
				);
			CRect r = CRect(loc.x, loc.y, 0, 0);
			CString str;
			str.Format("%d", DemoData.get_wert(m_selection, index));
			dc.DrawText(str, &r, DT_CALCRECT);
			r.OffsetRect(0, -r.Height());
			r.right += 6;
			dc.Rectangle(&r);
			dc.DrawText(str, &r, DT_SINGLELINE | DT_CENTER | DT_VCENTER);
		}
	}
	dc.SelectObject(oldPen);
}
Beispiel #19
0
int
spadAction (void)
{
  int code, viewCommand;
  float f1, f2, f3;
  int i1, i2, i3;


  if (viewAloned==yes) {
      close(0);
      return(-1);
      }
  readViewman(&viewCommand, intSize);

  switch (viewCommand) {

  case rotate:
    readViewman(&f1, floatSize);
    readViewman(&f2, floatSize);
    viewport->theta = f1;
    viewport->phi   = f2;
    while (viewport->theta >= two_pi) viewport->theta -= two_pi;
    while (viewport->theta < 0.0)     viewport->theta += two_pi;
    while (viewport->phi > pi)        viewport->phi   -= two_pi;
    while (viewport->phi <= -pi)      viewport->phi   += two_pi;
    viewport->axestheta = viewport->theta;
    viewport->axesphi = viewport->phi;
    spadDraw=yes;
    rotated=yes;
    viewport->yzOn = viewport->xzOn = viewport->xyOn = no;

    break;

  case zoom:
    readViewman(&f1, floatSize);
    viewport->scale = f1;
    if (viewport->scale > maxScale) viewport->scale = maxScale;
    else if (viewport->scale < minScale) viewport->scale = minScale;

    spadDraw=yes;
    zoomed = yes;
    break;

  case zoomx:
    readViewman(&f1, floatSize);
    readViewman(&f2, floatSize);
    readViewman(&f3, floatSize);
    viewport->scaleX = f1;  viewport->scaleY = f2;  viewport->scaleZ = f3;
    if ((viewport->scaleX == 1.0) &&
        (viewport->scaleY == 1.0) &&
        (viewport->scaleZ == 1.0)) {
      viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes;
    } else {
      if (viewport->scaleX == 1.0) viewport->zoomXOn = no;
      else {
        if (viewport->scaleX > maxScale) viewport->scaleX = maxScale;
        else if (viewport->scaleX < minScale) viewport->scaleX = minScale;
      }
      if (viewport->scaleY == 1.0) viewport->zoomYOn = no;
      else {
        if (viewport->scaleY > maxScale) viewport->scaleY = maxScale;
        else if (viewport->scaleY < minScale) viewport->scaleY = minScale;
      }
      if (viewport->scaleZ == 1.0) viewport->zoomZOn = no;
      else {
        if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale;
        else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale;
      }
    }

    spadDraw=yes;
    zoomed = yes;
    break;

  case translate:
    readViewman(&(viewport->deltaX),floatSize);
    readViewman(&(viewport->deltaY),floatSize);
    if (viewport->deltaX > maxDeltaX) viewport->deltaX = maxDeltaX;
    else if (viewport->deltaX < -maxDeltaX) viewport->deltaX = -maxDeltaX;
    if (viewport->deltaY > maxDeltaY) viewport->deltaY = maxDeltaY;
    else if (viewport->deltaY < -maxDeltaY) viewport->deltaY = -maxDeltaY;
    spadDraw=yes;
    translated = yes;
    break;

  case modifyPOINT:
    readViewman(&i1,intSize);
    i1--;
    readViewman(&(refPt3D(viewData,i1)->x),floatSize);
    readViewman(&(refPt3D(viewData,i1)->y),floatSize);
    readViewman(&(refPt3D(viewData,i1)->z),floatSize);
    readViewman(&(refPt3D(viewData,i1)->c),floatSize);
    scalePoint(refPt3D(viewData,i1));
    spadDraw=yes;
    break;

  case hideControl:
    readViewman(&i1,intSize);
    if (i1) {                         /* show control panel */
      if (viewport->haveControl)
        XUnmapWindow(dsply,control->controlWindow);
      putControlPanelSomewhere(someInt);
    } else {    /* turn off control panel */
      if (viewport->haveControl) {
        viewport->haveControl = no;
        XUnmapWindow(dsply,control->controlWindow);
      }
    }
    break;

  case axesOnOff:
    readViewman(&i1,intSize);
    viewport->axesOn = i1;
    spadDraw=yes;
    if (viewData.style == smooth) {
      if (multiColorFlag) redoDither = yes;
      else redoColor = yes;
    }
    if (viewport->haveControl) drawControlPanel();
    break;

/* Non-uniform scaling is not in AXIOM yet. */
/* Neither is object or origin rotation. */

  case perspectiveOnOff:
    readViewman(&i1,intSize);
    viewData.perspective = i1;
    switchedPerspective = yes;
    spadDraw=yes;
    break;

  case region3D:
    readViewman(&i1,intSize);
    viewport->regionOn = i1;
    viewData.box = i1;
    spadDraw=yes;
    if (viewport->haveControl) drawControlPanel();
    redoSmooth = yes;
    break;

  case clipRegionOnOff:
    readViewman(&i1,intSize);
    viewData.clipbox = i1;
    spadDraw=yes;
    break;

  case clipSurfaceOnOff:
    readViewman(&i1,intSize);
    viewData.clipStuff = i1;
    spadDraw=yes;
    break;

  case eyeDistanceData:
    readViewman(&f1,floatSize);
    viewData.eyeDistance = f1;
    if (viewData.eyeDistance > maxEyeDistance)
      viewData.eyeDistance = maxEyeDistance;
    else if (viewData.eyeDistance < minEyeDistance)
           viewData.eyeDistance = minEyeDistance;
    spadDraw=yes;
    changedEyeDistance = yes;
    break;

  case hitherPlaneData:
    readViewman(&f1,floatSize);
    viewData.clipPlane = f1;
    spadDraw=yes;
    changedEyeDistance = yes;
    break;

  case queryVIEWPOINT:
    f1 = viewport->deltaX;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->deltaY;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->scale;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->scaleX;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->scaleY;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->scaleZ;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->theta;
    code = check(write(Socket, &f1, floatSize));
    f1 = viewport->phi;
    code = check(write(Socket, &f1, floatSize));
    break;

  case changeVIEWPOINT:
    readViewman(&f1, floatSize);
    readViewman(&f2, floatSize);
    viewport->deltaX = f1;
    viewport->deltaY = f2;
    if (viewport->deltaX > maxDeltaX) viewport->deltaX = maxDeltaX;
    else if (viewport->deltaX < -maxDeltaX) viewport->deltaX = -maxDeltaX;
    if (viewport->deltaY > maxDeltaY) viewport->deltaY = maxDeltaY;
    else if (viewport->deltaY < -maxDeltaY) viewport->deltaY = -maxDeltaY;
    translated = yes;

    readViewman(&f1, floatSize);
    viewport->scale = f1;
    if (viewport->scale > maxScale) viewport->scale = maxScale;
    else if (viewport->scale < minScale) viewport->scale = minScale;
    zoomed = yes;

    readViewman(&f1, floatSize);
    readViewman(&f2, floatSize);
    readViewman(&f3, floatSize);
    viewport->scaleX = f1;
    viewport->scaleY = f2;
    viewport->scaleZ = f3;
    if ((viewport->scaleX == 1.0) &&
        (viewport->scaleY == 1.0) &&
        (viewport->scaleZ == 1.0)) {
      viewport->zoomXOn = viewport->zoomYOn = viewport->zoomZOn = yes;
    } else {
      if (viewport->scaleX == 1.0) viewport->zoomXOn = no;
      else {
        if (viewport->scaleX > maxScale) viewport->scaleX = maxScale;
        else if (viewport->scaleX < minScale) viewport->scaleX = minScale;
      }
      if (viewport->scaleY == 1.0) viewport->zoomYOn = no;
      else {
        if (viewport->scaleY > maxScale) viewport->scaleY = maxScale;
        else if (viewport->scaleY < minScale) viewport->scaleY = minScale;
      }
      if (viewport->scaleZ == 1.0) viewport->zoomZOn = no;
      else {
        if (viewport->scaleZ > maxScale) viewport->scaleZ = maxScale;
        else if (viewport->scaleZ < minScale) viewport->scaleZ = minScale;
      }
    }

    readViewman(&f1, floatSize);
    readViewman(&f2, floatSize);
    viewData.theta = f1;
    viewData.phi = f2;
    while (viewport->theta >= two_pi) viewport->theta -= two_pi;
    while (viewport->theta < 0.0)     viewport->theta += two_pi;
    while (viewport->phi > pi)        viewport->phi   -= two_pi;
    while (viewport->phi <= -pi)      viewport->phi   += two_pi;
    viewport->axestheta = viewport->theta;
    viewport->axesphi = viewport->phi;
    spadDraw=yes;
    rotated=yes;
    break;

  case colorDef:
    readViewman(&(viewport->hueOffset),intSize);
    readViewman(&(viewport->numberOfHues),intSize);
    /* spadcolors is indexed by 0 */
    viewport->hueOffset --;
    viewport->numberOfHues --;
    viewport->hueTop = viewport->numberOfHues;
    if (viewport->hueOffset < 0) viewport->hueOffset = 0;
    if (viewport->hueTop < 0) viewport->hueTop = 0;
    if (viewport->hueOffset >= totalHues)
      viewport->hueOffset = totalHues-1;
    if (viewport->hueTop >= totalHues) viewport->hueTop = totalHues-1;
    viewport->numberOfHues = viewport->hueTop - viewport->hueOffset;
    if ((viewport->hueTop == viewport->hueOffset) && (!viewport->monoOn))
      redoColor = yes;
    else {
      redoColor = no;
      redoDither = yes;
    }
    if (viewport->haveControl) drawColorMap();
    break;

  case closeAll:
    code = check(write(Socket,&ack,intSize));
    goodbye(-1);


  case moveViewport:
    readViewman(&i1,intSize);
    readViewman(&i2,intSize);
    XMoveWindow(dsply,viewport->titleWindow,i1,i2);
    XSync(dsply,0);
    break;

 case resizeViewport:
    readViewman(&i1,intSize);
    readViewman(&i2,intSize);
    XResizeWindow(dsply,viewport->titleWindow,i1,i2+titleHeight);
    XResizeWindow(dsply,viewport->viewWindow,i1,i2);
    spadDraw=yes;
    redoSmooth =yes;
    break;

  case transparent:
  case opaqueMesh:
  case render:
  case smooth:
    viewData.style = viewCommand;
    spadDraw=yes;
    redoSmooth =yes;
    break;

  case lightDef:
    readViewman(&(viewport->lightVector[0]),floatSize);
    readViewman(&(viewport->lightVector[1]),floatSize);
    readViewman(&(viewport->lightVector[2]),floatSize);
    normalizeVector(viewport->lightVector);
    movingLight = yes;
    drawLightingAxes();
    XSync(dsply,0);
    break;

  case translucenceDef:
    readViewman(&backLightIntensity,floatSize);
    tempLightIntensity = backLightIntensity;
    lightIntensity = tempLightIntensity;
    changedIntensity = yes;
    drawLightTransArrow();
    XSync(dsply,0);
    break;

  case changeTitle:
    readViewman(&i1,intSize);
    readViewman(viewport->title,i1);
    viewport->title[i1] = '\0';
    writeTitle();
    switch (doingPanel) {
    case CONTROLpanel:
    case CONTOURpanel:
      writeControlTitle(control->controlWindow);
      break;
    case VOLUMEpanel:
      writeControlTitle(volumeWindow);
      break;
    case LIGHTpanel:
      writeControlTitle(lightingWindow);
      break;
    } /* switch */
    XFlush(dsply);
    break;

  case writeView:
    readViewman(&i1,intSize);
    readViewman(filename,i1);
    filename[i1] = '\0';
    sprintf(errorStr,"writing of viewport data");
    i3 = 0;
    readViewman(&i2,intSize);
    while (i2) {
      i3 = i3 | (1<<i2);
      readViewman(&i2,intSize);
    }
    if (writeViewport(i3) < 0)
      fprintf(stderr,"          Nothing was written\n");
    break;

  case diagOnOff:
    readViewman(&i1,intSize);
    if (viewData.outlineRenderOn) {
      viewport->diagonals = i1;
      spadDraw=yes;
    } else {
      strcpy(control->message,"  Use this option with Outline  ");
      writeControlMessage();
    }
    break;

  case outlineOnOff:
    readViewman(&i1,intSize);
    if (viewData.style == render) {
      viewData.outlineRenderOn = i1;
      spadDraw=yes;
      if (viewport->haveControl) drawControlPanel();
    } else {
      strcpy(control->message," Use this option in Shaded mode ");
      writeControlMessage();
    }
    break;

  case spadPressedAButton:
    readViewman(&i1,intSize);
    buttonAction(i1);
    break;
  default:
    return(-1);
  } /* switch */


  ack++;
  code = check(write(Socket,&ack,intSize));
  return(0);

}
Beispiel #20
0
void Application::readPoints()
{
    assert( _pointVec.empty() && "Input point vector not empty!" );

    Config& config = getConfig();

    std::ifstream inFile( config._inFilename.c_str() );

    if ( !inFile )
    {
        std::cout << "Error opening input file: " << config._inFilename << " !!!\n";
        exit( 1 );
    }

    ////
    // Read input points
    ////

    std::string strVal;
    Point3 point;
    Point3HVec inPointVec;
    Point3Set pointSet;
    int idx         = 0;
    int orgCount    = 0;
    float val       = 0.0f;
    float minVal    = 999.0f;
    float maxVal    = -999.0f;

    while ( inFile >> strVal )
    {
        std::istringstream iss( strVal );

        // Read a coordinate
        iss >> val;
        point._p[ idx ] = val;
        ++idx;

        // Compare bounds
        if ( val < minVal ) minVal = val;
        if ( val > maxVal ) maxVal = val;

        // Read a point
        if ( 3 == idx )
        {
            idx = 0;

            ++orgCount;

            // Check if point unique
            if ( pointSet.end() == pointSet.find( point ) )
            {
                pointSet.insert( point );
                inPointVec.push_back( point );
            }
        }
    }

    ////
    // Check for duplicate points
    ////

    const int dupCount = orgCount - ( int ) inPointVec.size();

    if ( dupCount > 0 )
    {
        std::cout << dupCount << " duplicate points in input file!" << std::endl;
    }

    ////
    // Scale points and store them
    ////

    pointSet.clear();

    // Iterate input points
    for ( int ip = 0; ip < ( int ) inPointVec.size(); ++ip )
    {
        Point3& inPt = inPointVec[ ip ];

        // Iterate coordinates
        for ( int vi = 0; vi < 3; ++vi )
        {
            const RealType inVal  = inPt._p[ vi ];
            const RealType outVal = scalePoint( ( RealType ) config._gridSize, minVal, maxVal, inVal );
            inPt._p[ vi ]         = outVal;
        }

        // Check if point unique
        if ( pointSet.end() == pointSet.find( inPt ) )
        {
            pointSet.insert( inPt );
            _pointVec.push_back( inPt );
        }
    }

    // Update
    config._pointNum = _pointVec.size();

    cout << "Unique points: " << _pointVec.size() << endl;

    return;
}
Beispiel #21
0
Datei: k.cpp Projekt: mayah/ICPC
point calculaTetetrahedraCenter(const point &a, const point &b, const point &c, const point &d) {
	point g = addPoints(a, b);
	g = addPoints(g, c);
	g = addPoints(g, d);
	return scalePoint(g, 0.25);
}
Beispiel #22
0
/**
 * Retrieve the scaled point from plot coordinates to widget coordinates.
 *
 * @param[in] point Point in plot coordinates.
 *
 * @return Point in widget coordinates.
 */
QPointF Plot2D::scalePoint(const QPointF &point) const {
    return scalePoint(point.x(), point.y());
}