Toshihiro Shimizu 890ddd
#include "ext/OverallDesigner.h"
Toshihiro Shimizu 890ddd
//#include "ext/StrokeParametricDeformer.h"
Toshihiro Shimizu 890ddd
#include "ext/StrokeDeformation.h"
Toshihiro Shimizu 890ddd
#include "ext/SmoothDeformation.h"
Toshihiro Shimizu 890ddd
#include "ext/CornerDeformation.h"
Toshihiro Shimizu 890ddd
#include "ext/StraightCornerDeformation.h"
Toshihiro Shimizu 890ddd
#include "ext/Selector.h"
Toshihiro Shimizu 890ddd
#include "ext/ContextStatus.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcurves.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <tstroke.h></tstroke.h>
Toshihiro Shimizu 890ddd
#include <tgl.h></tgl.h>
Toshihiro Shimizu 890ddd
#include <tgeometry.h></tgeometry.h>
Toshihiro Shimizu 890ddd
#include <drawutil.h></drawutil.h>
Toshihiro Shimizu 890ddd
#include <sstream></sstream>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
#ifdef  _DEBUG
Toshihiro Shimizu 890ddd
#undef  _DEBUG
Toshihiro Shimizu 890ddd
#define RESTORE_DEBUG
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
//*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
void extglDrawText(const TPointD &p, const std::string &s,
Shinya Kitaoka 120a6e
                   void *character = GLUT_BITMAP_TIMES_ROMAN_10) {
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  glTranslated(p.x, p.y, 0);
Shinya Kitaoka 120a6e
  if (character <= GLUT_STROKE_MONO_ROMAN) {
Shinya Kitaoka 120a6e
    double factor = 0.07;
Shinya Kitaoka 120a6e
    glScaled(factor, factor, factor);
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)s.size(); i++)
Shinya Kitaoka 120a6e
      glutStrokeCharacter(character, s[i]);
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)s.size(); i++)
Shinya Kitaoka 120a6e
      glutBitmapCharacter(character, s[i]);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawSign(const TPointD &p, const TPointD &v, double size) {
Shinya Kitaoka 120a6e
  if (size == 0.0) return;
Shinya Kitaoka 120a6e
  size = fabs(size);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPointD v90  = rotate90(v);
Shinya Kitaoka 120a6e
  TPointD v270 = rotate270(v);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glBegin(GL_LINES);
Shinya Kitaoka 120a6e
  glVertex2d(p.x, p.y);
Shinya Kitaoka 120a6e
  v90 = normalize(v90);
Shinya Kitaoka 120a6e
  v90 = v90 * size;
Shinya Kitaoka 120a6e
  v90 = p + v90;
Shinya Kitaoka 120a6e
  glVertex2d(v90.x, v90.y);
Shinya Kitaoka 120a6e
  glEnd();
Shinya Kitaoka 120a6e
  glBegin(GL_LINES);
Shinya Kitaoka 120a6e
  glVertex2d(p.x, p.y);
Shinya Kitaoka 120a6e
  v270 = normalize(v270);
Shinya Kitaoka 120a6e
  v270 = v270 * size;
Shinya Kitaoka 120a6e
  v270 = p + v270;
Shinya Kitaoka 120a6e
  glVertex2d(v270.x, v270.y);
Shinya Kitaoka 120a6e
  glEnd();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawCross(const TPointD &p, double size) {
Shinya Kitaoka 120a6e
  TPointD v1 = TPointD(1, 1);
Shinya Kitaoka 120a6e
  TPointD v2 = TPointD(1, -1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  drawSign(p, v1, size);
Shinya Kitaoka 120a6e
  drawSign(p, v2, size);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/**
Toshihiro Shimizu 890ddd
   * Try to verify if it is possible to call
Toshihiro Shimizu 890ddd
   * some method of this stroke.
Toshihiro Shimizu 890ddd
   */
Shinya Kitaoka 120a6e
bool isValid(const TStroke *s) {
Shinya Kitaoka 120a6e
  if (!s) return false;
Shinya Kitaoka 120a6e
  const int cpCount = s->getControlPointCount();
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i               = 0; i < cpCount; ++i) s->getControlPoint(i);
Shinya Kitaoka 120a6e
  const int chunkCount = s->getChunkCount();
Shinya Kitaoka 120a6e
  for (i = 0; i < chunkCount; ++i) s->getChunk(i);
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void showCP(const TStroke *s, double pixelSize) {
Shinya Kitaoka 120a6e
  if (!s) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // show control points
Shinya Kitaoka 120a6e
  const int countCP = s->getControlPointCount();
Shinya Kitaoka 120a6e
  TThickPoint p1;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  for (int i = 0; i < countCP; ++i) {
Shinya Kitaoka 120a6e
    p1 = s->getControlPoint(i);
Shinya Kitaoka 120a6e
    if (i & 1)
Shinya Kitaoka 120a6e
      glColor3d(1.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      glColor3d(1.0, 1.0, 0.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    drawCross(convert(p1), p1.thick * pixelSize);
Shinya Kitaoka 120a6e
    tglDrawCircle(convert(p1), p1.thick * pixelSize);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void drawStrokeCenterLine(const TStroke *stroke, double pixelSize,
Shinya Kitaoka 120a6e
                          const ToonzExt::Interval &vals) {
Shinya Kitaoka 120a6e
  double from = vals.first, to = vals.second;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (!stroke || pixelSize < 0.0) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  from = std::max(std::min(from, 1.0), 0.0);
Shinya Kitaoka 120a6e
  to   = std::max(std::min(to, 1.0), 0.0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (from < to) {
Shinya Kitaoka 120a6e
    drawStrokeCenterline(*stroke, pixelSize, from, to);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    drawStrokeCenterline(*stroke, pixelSize, from, 1.0);
Shinya Kitaoka 120a6e
    drawStrokeCenterline(*stroke, pixelSize, 0.0, to);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  tglDrawDisk(stroke->getPoint(from), 5.0 * pixelSize);
Shinya Kitaoka 120a6e
  tglDrawDisk(stroke->getPoint(to), 5.0 * pixelSize);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  glColor3d(1.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
  tglDrawDisk(stroke->getPoint(0.0), 9.0 * pixelSize);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void showCorners(const TStroke *s, int cornerSize, double pixelSize) {
Shinya Kitaoka 120a6e
  if (!s) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TPointD offset(20, 20);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // show corners
Shinya Kitaoka 120a6e
  std::vector<double> corners;</double>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToonzExt::cornersDetector(s, cornerSize, corners);
Shinya Kitaoka 120a6e
  if (corners.empty()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int i, size = corners.size();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  glColor3d(0.8, 1.0, 0.3);
Shinya Kitaoka 120a6e
  // find interval with corner like extremes
Shinya Kitaoka 120a6e
  for (i = 0; i < size; ++i) {
Shinya Kitaoka 120a6e
    double tmp   = corners[i];
Shinya Kitaoka 120a6e
    TPointD pnt  = s->getPoint(tmp);
Shinya Kitaoka 120a6e
    double large = 5.0;
Shinya Kitaoka 120a6e
    drawCross(pnt, large * pixelSize);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glColor3d(0.7, 0.7, 0.7);
Shinya Kitaoka 120a6e
    std::ostringstream oss;
Shinya Kitaoka 120a6e
    oss << "[" << tmp << "]";
Shinya Kitaoka 120a6e
    extglDrawText(TPointD(pnt.x, pnt.y) + offset, oss.str());
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  corners.clear();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToonzExt::straightCornersDetector(s, corners);
Shinya Kitaoka 120a6e
  if (corners.empty()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  size = corners.size();
Shinya Kitaoka 120a6e
  glColor3d(0.8, 1.0, 0.3);
Shinya Kitaoka 120a6e
  // find interval with corner like extremes
Shinya Kitaoka 120a6e
  for (i = 0; i < size; ++i) {
Shinya Kitaoka 120a6e
    double tmp   = corners[i];
Shinya Kitaoka 120a6e
    TPointD pnt  = s->getPoint(tmp);
Shinya Kitaoka 120a6e
    double large = 5.0;
Shinya Kitaoka 120a6e
    drawCross(pnt, large * pixelSize);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    glColor3d(0.7, 0.2, 0.2);
Shinya Kitaoka 120a6e
    std::ostringstream oss;
Shinya Kitaoka 120a6e
    oss << "[" << tmp << "]";
Shinya Kitaoka 120a6e
    extglDrawText(TPointD(pnt.x, pnt.y) - offset, oss.str());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToonzExt::OverallDesigner::OverallDesigner(int x, int y) : x_(x), y_(y) {
Shinya Kitaoka 120a6e
  pixelSize_ = sqrt(this->getPixelSize2());
Shinya Kitaoka 120a6e
  scale_     = pixelSize_ != 0.0 ? pixelSize_ : 1.0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToonzExt::OverallDesigner::~OverallDesigner() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::draw(ToonzExt::SmoothDeformation *sd) {
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    this->setPosition();
Shinya Kitaoka 120a6e
    TCubic c;
Shinya Kitaoka 120a6e
    c.setP0(TPointD(0.0, 0.0));
Shinya Kitaoka 120a6e
    c.setP1(TPointD(4.0, 12.0));
Shinya Kitaoka 120a6e
    c.setP2(TPointD(12.0, 12.0));
Shinya Kitaoka 120a6e
    c.setP3(TPointD(16.0, 0.0));
Shinya Kitaoka 120a6e
    glColor3d(1.0, 0.0, 1.0);
Shinya Kitaoka 120a6e
    tglDraw(c, 100, GL_LINE);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::draw(ToonzExt::CornerDeformation *sd) {
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    this->setPosition();
Shinya Kitaoka 120a6e
    TCubic c;
Shinya Kitaoka 120a6e
    c.setP0(TPointD(0.0, 0.0));
Shinya Kitaoka 120a6e
    c.setP1(TPointD(0.0, 12.0));
Shinya Kitaoka 120a6e
    c.setP2(TPointD(6.0, 12.0));
Shinya Kitaoka 120a6e
    c.setP3(TPointD(12.0, 12.0));
Shinya Kitaoka 120a6e
    glColor3d(1.0, 0.0, 1.0);
Shinya Kitaoka 120a6e
    tglDraw(c, 100, GL_LINE);
Shinya Kitaoka 120a6e
    c.setP0(TPointD(12.0, 12.0));
Shinya Kitaoka 120a6e
    c.setP1(TPointD(6.0, 8.0));
Shinya Kitaoka 120a6e
    c.setP2(TPointD(6.0, 4.0));
Shinya Kitaoka 120a6e
    c.setP3(TPointD(12.0, 0.0));
Shinya Kitaoka 120a6e
    tglDraw(c, 100, GL_LINE);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::draw(ToonzExt::StraightCornerDeformation *sd) {
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
  glPushMatrix();
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    this->setPosition();
Shinya Kitaoka 120a6e
    glColor3d(0.0, 1.0, 1.0);
Shinya Kitaoka 120a6e
    glBegin(GL_LINE_STRIP);
Shinya Kitaoka 120a6e
    tglVertex(TPointD(0.0, 0.0));
Shinya Kitaoka 120a6e
    tglVertex(TPointD(8.0, 12.0));
Shinya Kitaoka 120a6e
    tglVertex(TPointD(16.0, 0.0));
Shinya Kitaoka 120a6e
    glEnd();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  glPopMatrix();
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::draw(ToonzExt::StrokeDeformation *sd) {
Shinya Kitaoka 120a6e
  if (sd) {
Shinya Kitaoka 120a6e
    const TStroke *s;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    // glColor3d(1.0,0.0,1.0);
Shinya Kitaoka 120a6e
    s = sd->getCopiedStroke();
Shinya Kitaoka 120a6e
    if (s) {
Shinya Kitaoka 120a6e
      const ContextStatus *status = sd->getStatus();
Shinya Kitaoka 120a6e
      double w = 0.0, pixelSize = 1.0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      if (status) {
Shinya Kitaoka 120a6e
        w         = status->w_;
Shinya Kitaoka 120a6e
        pixelSize = status->pixelSize_ < 0 ? 1.0 : status->pixelSize_;
Shinya Kitaoka 120a6e
      }
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
      drawCross(s->getPoint(0), 2 * pixelSize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
      tglDrawCircle(s->getPoint(w), 8 * pixelSize);
Shinya Kitaoka 120a6e
      drawCross(s->getPoint(w), 8 * pixelSize);
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
      ToonzExt::Interval ex = sd->getExtremes();
Shinya Kitaoka 120a6e
      drawStrokeCenterLine(s, pixelSize_, ex);
Shinya Kitaoka 120a6e
      if (status) {
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
        glColor3d(0, 0, 0);
Shinya Kitaoka 120a6e
        showCorners(s, status->cornerSize_, pixelSize);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        glColor3d(0, 0, 0);
Shinya Kitaoka 120a6e
        TPointD offset = normalize(TPointD(1.0, 1.0)) * 20.0;
Shinya Kitaoka 120a6e
        std::ostringstream oss;
Shinya Kitaoka 120a6e
        oss << "(" << this->x_ << "," << this->y_ << ")\n{" << w << ",{"
Shinya Kitaoka 120a6e
            << sd->getExtremes().first << "," << sd->getExtremes().second
Shinya Kitaoka 120a6e
            << "}}";
Shinya Kitaoka 120a6e
        extglDrawText(TPointD(x_, y_) + offset, oss.str());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        glColor3d(0.5, 1.0, 0.5);
Shinya Kitaoka 120a6e
        showCP(s, pixelSize);
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
glColor3d(1.0,1.0,0.0);
Shinya Kitaoka 120a6e
s = sd->getStroke();
Shinya Kitaoka 120a6e
if(s)
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
drawCross( s->getPoint(0),
Shinya Kitaoka 120a6e
     4);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
drawStrokeCenterLine(s,
Shinya Kitaoka 120a6e
               pixelSize_,
Shinya Kitaoka 120a6e
               ToonzExt::Interval(0,1));
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    s = sd->getTransformedStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    glColor3d(1.0, 0.0, 0.0);
Shinya Kitaoka 120a6e
    if (s) {
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
      isValid(s);
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
      drawStrokeCenterline(*s, pixelSize_);
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef _DEBUG
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
      const TStroke *c = sd->getCopiedStroke(), *s = sd->getStroke();
Shinya Kitaoka 120a6e
      if (c && s) {
Shinya Kitaoka 120a6e
        // glColor3d(1,1,0);
Shinya Kitaoka 120a6e
        // tglDrawDisk(s->getPoint(0.0),
Shinya Kitaoka 120a6e
        //            5*pixelSize_);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        int count =
Shinya Kitaoka 120a6e
            std::min(c->getControlPointCount(), s->getControlPointCount());
Shinya Kitaoka 120a6e
        for (int i = 0; i < count; ++i) {
Shinya Kitaoka 120a6e
          TThickPoint ccp = c->getControlPoint(i);
Shinya Kitaoka 120a6e
          TThickPoint scp = s->getControlPoint(i);
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::setPosition() {
Shinya Kitaoka 120a6e
  TPointD offset(1, -1);
Shinya Kitaoka 120a6e
  offset = normalize(offset) * (20.0 * scale_);
Shinya Kitaoka 120a6e
  glTranslated(x_ + offset.x, y_ + offset.y, 0.0);
Shinya Kitaoka 120a6e
  glScalef(scale_, scale_, scale_);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToonzExt::OverallDesigner::draw(ToonzExt::Selector *selector) {
Shinya Kitaoka 120a6e
  if (!selector) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const TStroke *ref = selector->getStroke();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (!ref) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double length_at_w         = ref->getLength(selector->getW()),
Shinya Kitaoka 120a6e
         emi_selector_length = selector->getLength() * 0.5,
Shinya Kitaoka 120a6e
         stroke_length       = ref->getLength();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToonzExt::Interval interval;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (ref->isSelfLoop()) {
Shinya Kitaoka 120a6e
    interval.first = length_at_w - emi_selector_length;
Shinya Kitaoka 120a6e
    if (interval.first < 0.0) interval.first = stroke_length + interval.first;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    interval.first = ref->getParameterAtLength(interval.first);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    interval.second = length_at_w + emi_selector_length;
Shinya Kitaoka 120a6e
    if (interval.second > stroke_length)
Shinya Kitaoka 120a6e
      interval.second = interval.second - stroke_length;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    interval.second = ref->getParameterAtLength(interval.second);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    interval.first = ref->getParameterAtLength(
Shinya Kitaoka 120a6e
        std::max(0.0, length_at_w - emi_selector_length));
Shinya Kitaoka 120a6e
    interval.second = ref->getParameterAtLength(
Shinya Kitaoka 120a6e
        std::min(stroke_length, length_at_w + emi_selector_length));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  float prev_line_width = 1.0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  glGetFloatv(GL_LINE_WIDTH, &prev_line_width);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  glLineWidth(2.0);
Shinya Kitaoka 120a6e
  drawStrokeCenterLine(ref, pixelSize_, interval);
Shinya Kitaoka 120a6e
  glLineWidth(prev_line_width);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
//  End Of File
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
#ifdef  RESTORE_DEBUG
Toshihiro Shimizu 890ddd
#undef  RESTORE_DEBUG
Toshihiro Shimizu 890ddd
#define _DEBUG  1
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
//*/