コード例 #1
0
ファイル: cleanuppreview.cpp プロジェクト: walkerka/opentoonz
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();
}
コード例 #2
0
ファイル: tgl.cpp プロジェクト: guozanhua/opentoonz
void tglFillRect(const TRectD &rect)
{
	glBegin(GL_POLYGON);
	tglVertex(rect.getP00());
	tglVertex(rect.getP10());
	tglVertex(rect.getP11());
	tglVertex(rect.getP01());
	glEnd();
}
コード例 #3
0
ファイル: tgl.cpp プロジェクト: guozanhua/opentoonz
void tglDrawRect(const TRectD &rect)
{
	glBegin(GL_LINE_LOOP);
	tglVertex(rect.getP00());
	tglVertex(rect.getP10());
	tglVertex(rect.getP11());
	tglVertex(rect.getP01());
	glEnd();
}
コード例 #4
0
ファイル: tgeometry.cpp プロジェクト: AmEv7Fam/opentoonz
TRectD TAffine::operator*(const TRectD &rect) const
{
	if (rect != TConsts::infiniteRectD) {
		TPointD p1 = *this * rect.getP00(),
				p2 = *this * rect.getP01(),
				p3 = *this * rect.getP10(),
				p4 = *this * rect.getP11();
		return TRectD(tmin(p1.x, p2.x, p3.x, p4.x), tmin(p1.y, p2.y, p3.y, p4.y),
					  tmax(p1.x, p2.x, p3.x, p4.x), tmax(p1.y, p2.y, p3.y, p4.y));
	} else
		return TConsts::infiniteRectD;
}
コード例 #5
0
void ShiftTraceTool::drawControlRect() {
  if (m_ghostIndex < 0 || m_ghostIndex > 1) return;
  int row = m_row[m_ghostIndex];
  if (row < 0) return;
  int col       = TApp::instance()->getCurrentColumn()->getColumnIndex();
  TXsheet *xsh  = TApp::instance()->getCurrentXsheet()->getXsheet();
  TXshCell cell = xsh->getCell(row, col);
  if (cell.isEmpty()) return;
  TImageP img = cell.getImage(false);
  if (!img) return;
  TRectD box;
  if (TRasterImageP ri = img) {
    TRasterP ras = ri->getRaster();
    box =
        (convert(ras->getBounds()) - ras->getCenterD()) * ri->getSubsampling();
  } else if (TToonzImageP ti = img) {
    TRasterP ras = ti->getRaster();
    box =
        (convert(ras->getBounds()) - ras->getCenterD()) * ti->getSubsampling();
  } else if (TVectorImageP vi = img) {
    box = vi->getBBox();
  } else {
    return;
  }
  glPushMatrix();
  tglMultMatrix(getGhostAff());
  TPixel32 color;
  color = m_highlightedGadget == TranslateGadget ? TPixel32(200, 100, 100)
                                                 : TPixel32(120, 120, 120);
  tglColor(color);
  glBegin(GL_LINE_STRIP);
  glVertex2d(box.x0, box.y0);
  glVertex2d(box.x1, box.y0);
  glVertex2d(box.x1, box.y1);
  glVertex2d(box.x0, box.y1);
  glVertex2d(box.x0, box.y0);
  glEnd();
  color =
      m_highlightedGadget == 2000 ? TPixel32(200, 100, 100) : TPixel32::White;
  double r = 4 * sqrt(tglGetPixelSize2());
  drawDot(box.getP00(), r, color);
  drawDot(box.getP01(), r, color);
  drawDot(box.getP10(), r, color);
  drawDot(box.getP11(), r, color);
  if (m_curveStatus == NoCurve) {
    color =
        m_highlightedGadget == 2001 ? TPixel32(200, 100, 100) : TPixel32::White;
    TPointD c = m_center[m_ghostIndex];
    drawDot(c, r, color);
  }
  glPopMatrix();
}
コード例 #6
0
ShiftTraceTool::GadgetId ShiftTraceTool::getGadget(const TPointD &p) {
  std::vector<std::pair<TPointD, GadgetId>> gadgets;
  gadgets.push_back(std::make_pair(m_p0, CurveP0Gadget));
  gadgets.push_back(std::make_pair(m_p1, CurveP1Gadget));
  gadgets.push_back(std::make_pair(m_p2, CurvePmGadget));
  TAffine aff = getGhostAff();
  if (0 <= m_ghostIndex && m_ghostIndex < 2) {
    gadgets.push_back(std::make_pair(aff * m_box.getP00(), RotateGadget));
    gadgets.push_back(std::make_pair(aff * m_box.getP01(), RotateGadget));
    gadgets.push_back(std::make_pair(aff * m_box.getP10(), RotateGadget));
    gadgets.push_back(std::make_pair(aff * m_box.getP11(), RotateGadget));
    gadgets.push_back(
        std::make_pair(aff * m_center[m_ghostIndex], MoveCenterGadget));
  }
  int k           = -1;
  double minDist2 = pow(10 * getPixelSize(), 2);
  for (int i = 0; i < (int)gadgets.size(); i++) {
    double d2 = norm2(gadgets[i].first - p);
    if (d2 < minDist2) {
      minDist2 = d2;
      k        = i;
    }
  }
  if (k >= 0) return gadgets[k].second;

  // rect-point
  if (0 <= m_ghostIndex && m_ghostIndex < 2) {
    TPointD q = aff.inv() * p;

    double big = 1.0e6;
    double d = big, x = 0, y = 0;
    if (m_box.x0 < q.x && q.x < m_box.x1) {
      x         = q.x;
      double d0 = fabs(m_box.y0 - q.y);
      double d1 = fabs(m_box.y1 - q.y);
      if (d0 < d1) {
        d = d0;
        y = m_box.y0;
      } else {
        d = d1;
        y = m_box.y1;
      }
    }
    if (m_box.y0 < q.y && q.y < m_box.y1) {
      double d0 = fabs(m_box.x0 - q.y);
      double d1 = fabs(m_box.x1 - q.y);
      if (d0 < d) {
        d = d0;
        y = q.y;
        x = m_box.x0;
      }
      if (d1 < d) {
        d = d1;
        y = q.y;
        x = m_box.x1;
      }
    }
    if (d < big) {
      TPointD pp = aff * TPointD(x, y);
      double d   = norm(p - pp);
      if (d < 10 * getPixelSize()) {
        return TranslateGadget;
      }
    }
  }
  return NoGadget;
}