Beispiel #1
0
void CameraTestTool::drawCleanupCamera(double pixelSize) {
  CleanupParameters *cp =
      CleanupSettingsModel::instance()->getCurrentParameters();

  TRectD rect = cp->m_camera.getStageRect();

  glColor3d(1.0, 0.0, 0.0);
  glLineStipple(1, 0xFFFF);
  glEnable(GL_LINE_STIPPLE);

  // box
  glBegin(GL_LINE_STRIP);
  glVertex2d(rect.x0, rect.y0);
  glVertex2d(rect.x0, rect.y1 - pixelSize);
  glVertex2d(rect.x1 - pixelSize, rect.y1 - pixelSize);
  glVertex2d(rect.x1 - pixelSize, rect.y0);
  glVertex2d(rect.x0, rect.y0);
  glEnd();

  // central cross
  double dx = 0.05 * rect.getP00().x;
  double dy = 0.05 * rect.getP00().y;
  tglDrawSegment(TPointD(-dx, -dy), TPointD(dx, dy));
  tglDrawSegment(TPointD(-dx, dy), TPointD(dx, -dy));

  glDisable(GL_LINE_STIPPLE);

  // camera name
  TPointD pos = rect.getP01() + TPointD(0, 4);
  glPushMatrix();
  glTranslated(pos.x, pos.y, 0);
  glScaled(2, 2, 2);
  tglDrawText(TPointD(), "Cleanup Camera");
  glPopMatrix();
}
void ShiftTraceTool::drawCurve() {
  if (m_curveStatus == NoCurve) return;
  double r = 4 * sqrt(tglGetPixelSize2());
  double u = getPixelSize();
  if (m_curveStatus == TwoPointsCurve) {
    TPixel32 color =
        m_highlightedGadget == 1000 ? TPixel32(200, 100, 100) : TPixel32::White;
    drawDot(m_p0, r, color);
    glColor3d(0.2, 0.2, 0.2);
    tglDrawSegment(m_p0, m_p1);
    drawDot(m_p1, r, TPixel32::Red);
  } else if (m_curveStatus == ThreePointsCurve) {
    TPixel32 color =
        m_highlightedGadget == 1000 ? TPixel32(200, 100, 100) : TPixel32::White;
    drawDot(m_p0, r, color);
    color =
        m_highlightedGadget == 1001 ? TPixel32(200, 100, 100) : TPixel32::White;
    drawDot(m_p1, r, color);

    glColor3d(0.2, 0.2, 0.2);

    TPointD center;
    if (circumCenter(center, m_p0, m_p1, m_p2)) {
      double radius = norm(center - m_p1);
      glBegin(GL_LINE_STRIP);
      int n = 100;
      for (int i = 0; i < n; i++) {
        double t  = (double)i / n;
        TPointD p = (1 - t) * m_p0 + t * m_p2;
        p         = center + radius * normalize(p - center);
        tglVertex(p);
      }
      for (int i = 0; i < n; i++) {
        double t  = (double)i / n;
        TPointD p = (1 - t) * m_p2 + t * m_p1;
        p         = center + radius * normalize(p - center);
        tglVertex(p);
      }
      glEnd();
    } else {
      tglDrawSegment(m_p0, m_p1);
    }
    color =
        m_highlightedGadget == 1002 ? TPixel32(200, 100, 100) : TPixel32::White;
    drawDot(m_p2, r, color);
  }
}
void RotateTool::draw() {
  glColor3f(1, 0, 0);
  double u = 50;
  if (m_cameraCentered.getValue())
    m_center = TPointD(0, 0);
  else {
    TAffine aff                        = m_viewer->getViewMatrix().inv();
    if (m_viewer->getIsFlippedX()) aff = aff * TScale(-1, 1);
    if (m_viewer->getIsFlippedY()) aff = aff * TScale(1, -1);
    u                                  = u * sqrt(aff.det());
    m_center                           = aff * TPointD(0, 0);
  }
  tglDrawSegment(TPointD(-u + m_center.x, m_center.y),
                 TPointD(u + m_center.x, m_center.y));
  tglDrawSegment(TPointD(m_center.x, -u + m_center.y),
                 TPointD(m_center.x, u + m_center.y));
}
void MorphTool::draw()
{
	m_pixelSize = sqrt(tglGetPixelSize2());
	if (m_vi2) {
		TVectorRenderData rd(TTranslation(10, 10), TRect(), 0, 0);
		tglDraw(rd, m_vi2.getPointer());
	}

	double u = m_pixelSize * 5;
	for (int i = 0; i < (int)deformation.m_controlPoints.size(); i++) {
		TPointD p = deformation.m_controlPoints[i];
		bool selected = deformation.m_selected == i;
		bool base = (i & 1) == 0;
		if (base)
			if (selected)
				glColor3d(0.8, 0.8, 0.1);
			else
				glColor3d(0.5, 0.5, 0.1);
		else if (selected)
			glColor3d(0.8, 0.3, 0.1);
		else
			glColor3d(0.5, 0.1, 0.1);

		double r = base ? u * 2 : u * 1;
		tglDrawDisk(p, r);
		glColor3d(0, 0, 0);
		tglDrawCircle(p, r);
	}
	glColor3f(0, 1, 0);
	for (int i = 0; i + 1 < (int)deformation.m_controlPoints.size(); i += 2) {
		TPointD a = deformation.m_controlPoints[i];
		TPointD b = deformation.m_controlPoints[i + 1];
		tglDrawSegment(a, b);
	}
	/*
  deformation.update();
  glBegin(GL_LINES);
  for(double x = -200; x<=200; x+=20)
  for(double y = -200; y<=200; y+=20)
  {
    TPointD p0(x,y);
    TPointD p1 = deformation.apply(p0);
    glColor3d(0,1,0);
    tglVertex(p0);
    glColor3d(1,0,0);
    tglVertex(p1);
  }
  glEnd();
  */
}