Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "casmconfigpanel.h"
Toshihiro Shimizu 890ddd
#include "filebrowserpopup.h"
Toshihiro Shimizu 890ddd
#include "application.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tw/mainshell.h"
Toshihiro Shimizu 890ddd
#include "tw/textfield.h"
Toshihiro Shimizu 890ddd
#include "tw/label.h"
Toshihiro Shimizu 890ddd
#include "tw/optionmenu.h"
Toshihiro Shimizu 890ddd
#include "tw/button.h"
Toshihiro Shimizu 890ddd
#include "tw/checkbox.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tconvert.h"
Toshihiro Shimizu 890ddd
#include "util.h"
Toshihiro Shimizu 890ddd
#include "tsystem.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tw/message.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
CasmTask::CasmTask() { setdefaultValue(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
CasmTask::CasmTask(const string &s, const string &setupFilePath)
Shinya Kitaoka 120a6e
    : m_setupFile(setupFilePath) {
Shinya Kitaoka 120a6e
  setCommandLine(s);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmTask::setdefaultValue() {
Shinya Kitaoka 120a6e
  m_taskChunksize        = 1;
Shinya Kitaoka 120a6e
  m_start                = 0;
Shinya Kitaoka 120a6e
  m_end                  = 9999;
Shinya Kitaoka 120a6e
  m_step                 = 1;
Shinya Kitaoka 120a6e
  m_casmFile             = "";
Shinya Kitaoka 120a6e
  m_outname              = "";
Shinya Kitaoka 120a6e
  m_firstFrame           = 0;
Shinya Kitaoka 120a6e
  m_lastFrame            = 0;
Shinya Kitaoka 120a6e
  m_reduction            = 1;
Shinya Kitaoka 120a6e
  m_moveType             = M_BG_FRACMOVE;
Shinya Kitaoka 120a6e
  m_prec                 = 32;
Shinya Kitaoka 120a6e
  m_renderTile           = 1.;
Shinya Kitaoka 120a6e
  m_memChunk             = 4.;
Shinya Kitaoka 120a6e
  m_multimedia           = false;
Shinya Kitaoka 120a6e
  m_logfile              = false;
Shinya Kitaoka 120a6e
  m_cf                   = false;
Shinya Kitaoka 120a6e
  m_restype              = RES_TYPE_STANDARD;
Shinya Kitaoka 120a6e
  m_noOverwrite          = false;
Shinya Kitaoka 120a6e
  m_clap                 = false;
Shinya Kitaoka 120a6e
  m_mprocess             = false;
Shinya Kitaoka 120a6e
  m_numColumn            = -1;
Shinya Kitaoka 120a6e
  m_lineart              = -1;
Shinya Kitaoka 120a6e
  m_edgeAliasing         = -1;
Shinya Kitaoka 120a6e
  m_gamma                = -1.;
Shinya Kitaoka 120a6e
  m_bcScript             = "";
Shinya Kitaoka 120a6e
  m_acScript             = "";
Shinya Kitaoka 120a6e
  m_outputScript         = "";
Shinya Kitaoka 120a6e
  m_outputScriptArgument = "";
Shinya Kitaoka 120a6e
  m_setupFile            = "";
Shinya Kitaoka 120a6e
  xsize                  = 0;
Shinya Kitaoka 120a6e
  ysize                  = 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
string CasmTask::getCommandLine() const {
Shinya Kitaoka 120a6e
  string qualifiers, prgname, dirname, biname;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_reduction != 1) qualifiers += " -shrink " + toString(m_reduction) + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_moveType != moveType::M_BG_FRACMOVE)
Shinya Kitaoka 120a6e
    qualifiers +=
Shinya Kitaoka 120a6e
        (m_moveType == moveType::M_FRACMOVE) ? " -fracmove " : " -intmove ";
Shinya Kitaoka 120a6e
  if (m_prec == 64)
Shinya Kitaoka 120a6e
    qualifiers += " -64bit";
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    qualifiers += " -32bit";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  qualifiers += " -tile " + toString(m_renderTile) + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  qualifiers += " -mem " + toString(m_memChunk) + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_multimedia) {
Shinya Kitaoka 120a6e
    if (m_numColumn < 0)
Shinya Kitaoka 120a6e
      qualifiers += " -mm ";
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      qualifiers += " -mmsingle " + toString(m_numColumn) + " ";
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_logfile) qualifiers += " -logfile +output/casm_batches.log ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_lineart > -1) qualifiers += " -lineart " + toString(m_lineart) + " ";
Shinya Kitaoka 120a6e
  if (m_edgeAliasing > -1)
Shinya Kitaoka 120a6e
    qualifiers += " -edgealiasing " + toString(m_edgeAliasing) + " ";
Shinya Kitaoka 120a6e
  if (m_gamma > -1.0) qualifiers += " -gamma " + toString(m_gamma) + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  switch (m_restype) {
Shinya Kitaoka 120a6e
    CASE RES_TYPE_STANDARD : qualifiers += " -sq ";
Shinya Kitaoka 120a6e
    CASE RES_TYPE_IMPROVED : qualifiers += " -iq ";
Shinya Kitaoka 120a6e
    CASE RES_TYPE_HIGH : qualifiers += " -hq ";
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_cf) qualifiers += " -cf ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_noOverwrite) qualifiers += " -no_overwrite ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_clap) qualifiers += " -clap ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_bcScript != "") qualifiers += " -bc " + m_bcScript + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_acScript != "" && m_outputScript == "")
Shinya Kitaoka 120a6e
    qualifiers += " -ac " + m_acScript + " ";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_outputScript != "") {
Shinya Kitaoka 120a6e
    bool outputToDdr = (m_outputScript == DDR_OUTPUTSCRIPT_FILENAME);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (!outputToDdr) qualifiers += " -ac " + m_outputScript + " ";
Shinya Kitaoka 120a6e
    if (m_outputScriptArgument != "") {
Shinya Kitaoka 120a6e
      string entry_point = m_outputScriptArgument;
Shinya Kitaoka 120a6e
      string parity      = "odd";
Shinya Kitaoka 120a6e
      int i;
Shinya Kitaoka 120a6e
      i = entry_point.size();
Shinya Kitaoka 120a6e
      if (i > 0 && entry_point[i - 1] == '+') {
Shinya Kitaoka 120a6e
        parity             = "even";
Shinya Kitaoka 120a6e
        entry_point[i - 1] = '\0';
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      // convert_timecode_to_frame (entry_point);//??????
Shinya Kitaoka 120a6e
      if (outputToDdr)
Shinya Kitaoka 120a6e
        qualifiers += " -ddr " + entry_point + " ";
Shinya Kitaoka 120a6e
      else {
Shinya Kitaoka 120a6e
        string app;
Toshihiro Shimizu 890ddd
#ifdef WIN32
Shinya Kitaoka 120a6e
        app = " -ac_args \"$filename $count " + entry_point;
Shinya Kitaoka 120a6e
        app += " " + parity;
Shinya Kitaoka 120a6e
        app += " $total\" ";
Shinya Kitaoka 120a6e
        qualifiers += app;
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
        app = " -ac_args '$filename $count " + entry_point;
Shinya Kitaoka 120a6e
        app += " " + parity;
Shinya Kitaoka 120a6e
        app += " $total' ";
Shinya Kitaoka 120a6e
        qualifiers += " app;
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      if (outputToDdr)
Shinya Kitaoka 120a6e
        qualifiers += " -ddr " + toString(0) + " ";
Shinya Kitaoka 120a6e
      else
Toshihiro Shimizu 890ddd
#ifdef WIN32
Shinya Kitaoka 120a6e
        qualifiers += " -ac_args \"$filename $count $total\" ";
Toshihiro Shimizu 890ddd
#else
Shinya Kitaoka 120a6e
        qualifiers += " -ac_args '$filename $count $total' ";
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  qualifiers += "  -step " + toString(m_step);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_start > m_firstFrame || m_end < m_lastFrame)
Shinya Kitaoka 120a6e
    qualifiers += " -range " + toString(m_start) + " " + toString(m_end) + " ";
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // qualifiers += " -chunk "+toString(m_taskChunksize)+" ";
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return qualifiers;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
static bool is_num(string word) {
Shinya Kitaoka 120a6e
  string::iterator it = word.begin();
Shinya Kitaoka 120a6e
  while (it != word.end()) {
Shinya Kitaoka 120a6e
    if ((*it < '0' || *it > '9') && *it != '.') return false;
Shinya Kitaoka 120a6e
    it++;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return true;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
static string cpy_word(string &word, string s) {
Shinya Kitaoka 120a6e
  /* salto gli spazi bianchi iniziali */
Shinya Kitaoka 120a6e
  string::iterator it  = s.begin();
Shinya Kitaoka 120a6e
  word                 = "";
Shinya Kitaoka 120a6e
  string::iterator it2 = word.begin();
Shinya Kitaoka 120a6e
  while (s[0] == ' ' || s[0] == '\t') it++;
Shinya Kitaoka 120a6e
  if (s[0] == '\'' || s[0] == '\"') {
Shinya Kitaoka 120a6e
    /* argomento fra virgolette */
Shinya Kitaoka 120a6e
    char quote = *it++;
Shinya Kitaoka 120a6e
    while (*it && *it != '\n') {
Shinya Kitaoka 120a6e
      if (*it == '\\') {
Shinya Kitaoka 120a6e
        it++;
Shinya Kitaoka 120a6e
        if (*it == '\0' || *it == '\n') break;
Shinya Kitaoka 120a6e
        switch (*it) {
Shinya Kitaoka 120a6e
          CASE '\\' : *it2++ = '\\';
Shinya Kitaoka 120a6e
        DEFAULT:
Shinya Kitaoka 120a6e
          *it2++ = *it;
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
        it++;
Shinya Kitaoka 120a6e
      } else if (*it == quote) {
Shinya Kitaoka 120a6e
        it++;
Shinya Kitaoka 120a6e
        break;
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        *it2++ = *it++;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    /* argomento senza virgolette */
Shinya Kitaoka 120a6e
    while (*it && *it != ' ' && *it != '\t' && *it != '\n') *it2++ = *it++;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  //*word = '\0';
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* salto gli spazi bianchi finali */
Shinya Kitaoka 120a6e
  while (*it == ' ' || *it == '\t') it++;
Shinya Kitaoka 120a6e
  return s.erase(s.begin(), it);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmTask::setCommandLine(const string &cmdLine) {
Shinya Kitaoka 120a6e
  if (cmdLine.empty()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  setdefaultValue();
Shinya Kitaoka 120a6e
  string s            = cmdLine;
Shinya Kitaoka 120a6e
  string::iterator it = s.begin();
Shinya Kitaoka 120a6e
  string word;
Shinya Kitaoka 120a6e
  while (it != s.end()) {
Shinya Kitaoka 120a6e
    s = cpy_word(word, s);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (word == "-64bit")
Shinya Kitaoka 120a6e
      m_prec = 64;
Shinya Kitaoka 120a6e
    else if (word == "-32bit")
Shinya Kitaoka 120a6e
      m_prec = 32;
Shinya Kitaoka 120a6e
    else if (word == "-sq")
Shinya Kitaoka 120a6e
      m_restype = RES_TYPE_STANDARD;
Shinya Kitaoka 120a6e
    else if (word == "-iq")
Shinya Kitaoka 120a6e
      m_restype = RES_TYPE_IMPROVED;
Shinya Kitaoka 120a6e
    else if (word == "-hq")
Shinya Kitaoka 120a6e
      m_restype = RES_TYPE_HIGH;
Shinya Kitaoka 120a6e
    else if (word == "-step") {
Shinya Kitaoka 120a6e
      s                        = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_step = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-range") {
Shinya Kitaoka 120a6e
      s                         = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_start = atoi(word.c_str());
Shinya Kitaoka 120a6e
      s                         = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_end   = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-shrink") {
Shinya Kitaoka 120a6e
      s                             = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_reduction = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-fracmove") {
Shinya Kitaoka 120a6e
      m_moveType = M_FRACMOVE;
Shinya Kitaoka 120a6e
    } else if (word == "-intmove") {
Shinya Kitaoka 120a6e
      m_moveType = M_INTMOVE;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    /*     else
Shinya Kitaoka 120a6e
if (STR_EQ(word, "-64bit"))
Shinya Kitaoka 120a6e
task->prec = 64;
Shinya Kitaoka 120a6e
else
Shinya Kitaoka 120a6e
if (STR_EQ(word, "-32bit"))
Shinya Kitaoka 120a6e
task->prec = 32;*/
Shinya Kitaoka 120a6e
    else if (word == "-tile") {
Shinya Kitaoka 120a6e
      s                              = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_renderTile = atof(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-mem") {
Shinya Kitaoka 120a6e
      s                                 = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_taskChunksize = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-chunk") {
Shinya Kitaoka 120a6e
      s                            = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_memChunk = atof(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-mm") {
Shinya Kitaoka 120a6e
      m_multimedia = true;
Shinya Kitaoka 120a6e
      m_numColumn  = -1;
Shinya Kitaoka 120a6e
    } else if (word == "-mmsingle") {
Shinya Kitaoka 120a6e
      m_multimedia                  = true;
Shinya Kitaoka 120a6e
      s                             = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_numColumn = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-lineart") {
Shinya Kitaoka 120a6e
      s                           = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_lineart = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-edgealiasing") {
Shinya Kitaoka 120a6e
      s                                = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_edgeAliasing = atoi(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-gamma") {
Shinya Kitaoka 120a6e
      s                         = cpy_word(word, s);
Shinya Kitaoka 120a6e
      if (is_num(word)) m_gamma = atof(word.c_str());
Shinya Kitaoka 120a6e
    } else if (word == "-cf") {
Shinya Kitaoka 120a6e
      m_cf = true;
Shinya Kitaoka 120a6e
    } else if (word == "-no_overwrite") {
Shinya Kitaoka 120a6e
      m_noOverwrite = true;
Shinya Kitaoka 120a6e
    } else if (word == "-clap") {
Shinya Kitaoka 120a6e
      m_clap = true;
Shinya Kitaoka 120a6e
    } else if (word == "-bc") {
Shinya Kitaoka 120a6e
      s          = cpy_word(word, s);
Shinya Kitaoka 120a6e
      m_bcScript = word;
Shinya Kitaoka 120a6e
    } else if (word == "-ac") {
Shinya Kitaoka 120a6e
      s              = cpy_word(word, s);
Shinya Kitaoka 120a6e
      m_outputScript = word;
Shinya Kitaoka 120a6e
    } else if (word == "-ac_args") { /*
Shinya Kitaoka 120a6e
char output_script_argument[1024];
Shinya Kitaoka 120a6e
s = cpy_word(word, s);
Shinya Kitaoka 120a6e
if(parse_ac_args(output_script_argument, word))
Shinya Kitaoka 120a6e
task->output_script_argument = strsave(output_script_argument);*/
Shinya Kitaoka 120a6e
    } else if (word == "-logfile") {
Shinya Kitaoka 120a6e
      s         = cpy_word(word, s);
Shinya Kitaoka 120a6e
      m_logfile = true;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    /*     else
Shinya Kitaoka 120a6e
if (!word.compare("-range"))
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
s = cpy_word(word, s);
Shinya Kitaoka 120a6e
if (is_num(word))
Shinya Kitaoka 120a6e
task->start = atoi(word);
Shinya Kitaoka 120a6e
else
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
delete_job((TASK *)task);
Shinya Kitaoka 120a6e
return NULL;
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
s = cpy_word(word, s);
Shinya Kitaoka 120a6e
if (is_num(word))
Shinya Kitaoka 120a6e
task->end = atoi(word);
Shinya Kitaoka 120a6e
else
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
delete_job((TASK *)task);
Shinya Kitaoka 120a6e
return NULL;
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
}*/
Shinya Kitaoka 120a6e
    /*     else
Shinya Kitaoka 120a6e
if (*word!='\n' && *word!='\0')
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
t = tim_get_type(word);
Shinya Kitaoka 120a6e
if (*t == '.') t++;
Shinya Kitaoka 120a6e
if (FILESTR_NE(t, "casm"))
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
delete_job((TASK *)task);
Toshihiro Shimizu 890ddd
//           return NULL;
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
else
Shinya Kitaoka 120a6e
{
Shinya Kitaoka 120a6e
TCALLOC(task->casm_file, strlen(word)+1);
Shinya Kitaoka 120a6e
strcpy(task->casm_file, word);
Shinya Kitaoka 120a6e
compute_casm_range(task->casm_file, &(task->first_frame), &(task->last_frame),
Shinya Kitaoka 120a6e
&dummy);
Shinya Kitaoka 120a6e
if (task->start<task->first_frame)</task->
Shinya Kitaoka 120a6e
  task->start=task->first_frame;
Shinya Kitaoka 120a6e
if (task->end>task->last_frame)
Shinya Kitaoka 120a6e
  task->end=task->last_frame;
Shinya Kitaoka 120a6e
task->xsize = task->ysize = 0;
Shinya Kitaoka 120a6e
casm_camera_size(task->casm_file, &task->xsize, &task->ysize);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
}*/
Shinya Kitaoka 120a6e
    it = s.begin();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================================
Toshihiro Shimizu 890ddd
enum numFieldType {
Shinya Kitaoka 120a6e
  M_FROM = 0,
Shinya Kitaoka 120a6e
  M_TO,
Shinya Kitaoka 120a6e
  M_STEP,
Shinya Kitaoka 120a6e
  M_SHRINK,
Shinya Kitaoka 120a6e
  M_RTILE,
Shinya Kitaoka 120a6e
  M_MCHUNK,
Shinya Kitaoka 120a6e
  M_COLUMN,
Shinya Kitaoka 120a6e
  M_THICK,
Shinya Kitaoka 120a6e
  M_GAMMA,
Shinya Kitaoka 120a6e
  M_CHUNKSIZE
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class NumFieldChanger : public TNumField::Action {
Shinya Kitaoka 120a6e
  CasmConfigPanel *m_ccp;
Shinya Kitaoka 120a6e
  numFieldType m_typeField;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  NumFieldChanger(CasmConfigPanel *ccp, numFieldType type)
Shinya Kitaoka 120a6e
      : m_ccp(ccp), m_typeField(type) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void sendCommand(const TNumField::Event &ev) {
Shinya Kitaoka 120a6e
    m_ccp->onNumField(ev.m_value, m_typeField);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class ColumnFieldChanger : public TTextField::Action {
Shinya Kitaoka 120a6e
  CasmConfigPanel *m_ccp;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ColumnFieldChanger(CasmConfigPanel *ccp) : m_ccp(ccp) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void sendCommand(std::wstring value) { m_ccp->onColumnField(value); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class NumFieldChanger2 : public TNumField::Action {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  NumFieldChanger2(CasmConfigPanel *ccp, double CasmTask::*) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void sendCommand(double value) {
Shinya Kitaoka 120a6e
    //*m_member = value;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  double CasmTask::*m_member;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//==============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
CasmConfigPanel::CasmConfigPanel(TWidget *parent) : TWidget(parent) {
Shinya Kitaoka 120a6e
  m_task = new CasmTask();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_chunkSizeLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_chunkSizeLabel->setText("Task Chunk Size:");
Shinya Kitaoka 120a6e
  m_chunkSize = new TNumField(this);
Shinya Kitaoka 120a6e
  m_chunkSize->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_chunkSize->setRange(1, std::numeric_limits<int>::max());</int>
Shinya Kitaoka 120a6e
  m_chunkSize->addAction(new NumFieldChanger(this, M_CHUNKSIZE));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_setupLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_setupLabel->setText("Setup Path:");
Shinya Kitaoka 120a6e
  m_setupTextField = new TTextField(this);
Shinya Kitaoka 120a6e
  m_setupBrowseBtn = new TButton(this);
Shinya Kitaoka 120a6e
  m_setupBrowseBtn->setTitle("...");
Shinya Kitaoka 120a6e
  tconnect(*m_setupBrowseBtn, this, &CasmConfigPanel::browseSetupFiles);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_fromLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_fromLabel->setText("From:");
Shinya Kitaoka 120a6e
  m_from = new TNumField(this);
Shinya Kitaoka 120a6e
  m_from->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_from->addAction(new NumFieldChanger(this, M_FROM));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_toLabel->setText("To:");
Shinya Kitaoka 120a6e
  m_to = new TNumField(this);
Shinya Kitaoka 120a6e
  m_to->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_to->addAction(new NumFieldChanger(this, M_TO));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_stepLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_stepLabel->setText("Step:");
Shinya Kitaoka 120a6e
  m_step = new TNumField(this);
Shinya Kitaoka 120a6e
  m_step->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_step->addAction(new NumFieldChanger(this, M_STEP));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_shrinkLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_shrinkLabel->setText("Shrink:");
Shinya Kitaoka 120a6e
  m_shrink = new TNumField(this);
Shinya Kitaoka 120a6e
  m_shrink->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_shrink->addAction(new NumFieldChanger(this, M_SHRINK));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_renderTileLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_renderTileLabel->setText("Render Tile:");
Shinya Kitaoka 120a6e
  m_renderTile = new TNumField(this);
Shinya Kitaoka 120a6e
  m_renderTile->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_renderTile->addAction(new NumFieldChanger(this, M_RTILE));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_memChunkLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_memChunkLabel->setText("Mem Chunk:");
Shinya Kitaoka 120a6e
  m_memChunk = new TNumField(this);
Shinya Kitaoka 120a6e
  m_memChunk->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_memChunk->addAction(new NumFieldChanger(this, M_MCHUNK));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_subPixelMoveLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_subPixelMoveLabel->setText("Subpixel Move:");
Shinya Kitaoka 120a6e
  m_subPixelMove = new TOptionMenu(this);
Shinya Kitaoka 120a6e
  m_subPixelMove->addOption("None");
Shinya Kitaoka 120a6e
  m_subPixelMove->addOption("RGB");
Shinya Kitaoka 120a6e
  m_subPixelMove->addOption("All");
Shinya Kitaoka 120a6e
  m_subPixelMove->setAction(new TOptionMenuAction<casmconfigpanel>(</casmconfigpanel>
Shinya Kitaoka 120a6e
      this, &CasmConfigPanel::onSubPixelMove));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_processingLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_processingLabel->setText("Processing:");
Shinya Kitaoka 120a6e
  m_processing = new TOptionMenu(this);
Shinya Kitaoka 120a6e
  m_processing->addOption("32 Bit");
Shinya Kitaoka 120a6e
  m_processing->addOption("64 Bit");
Shinya Kitaoka 120a6e
  m_processing->setAction(new TOptionMenuAction<casmconfigpanel>(</casmconfigpanel>
Shinya Kitaoka 120a6e
      this, &CasmConfigPanel::onProcessing));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_resampleQualityLabel = new TLabel(this);
Shinya Kitaoka 120a6e
  m_resampleQualityLabel->setText("Resample Quality:");
Shinya Kitaoka 120a6e
  m_resampleQuality = new TOptionMenu(this);
Shinya Kitaoka 120a6e
  m_resampleQuality->addOption("Standard");
Shinya Kitaoka 120a6e
  m_resampleQuality->addOption("Improved");
Shinya Kitaoka 120a6e
  m_resampleQuality->addOption("High");
Shinya Kitaoka 120a6e
  m_resampleQuality->setAction(new TOptionMenuAction<casmconfigpanel>(</casmconfigpanel>
Shinya Kitaoka 120a6e
      this, &CasmConfigPanel::onResampleQuality));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_focus = new TCheckBox(this, "Constant Focus");
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_focus, this, onConstantFocus);</casmconfigpanel>
Shinya Kitaoka 120a6e
  m_noOverwrite = new TCheckBox(this, "No Overwrite");
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_noOverwrite, this, onOverwrite);</casmconfigpanel>
Shinya Kitaoka 120a6e
  m_multimedia = new TCheckBox(this, "Multimedia");
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_multimedia, this, onMultimedia);</casmconfigpanel>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_column = new TTextField(this);
Shinya Kitaoka 120a6e
  m_column->setText("All");
Shinya Kitaoka 120a6e
  m_column->disable();
Shinya Kitaoka 120a6e
  m_column->addAction(new ColumnFieldChanger(this));
Shinya Kitaoka 120a6e
  m_lineart = new TCheckBox(this, "Lineart");
Shinya Kitaoka 120a6e
  m_lineart->disable();
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_lineart, this, onLineart);</casmconfigpanel>
Shinya Kitaoka 120a6e
  m_edgeAliasing = new TCheckBox(this, "Edge Aliasing");
Shinya Kitaoka 120a6e
  m_edgeAliasing->disable();
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_edgeAliasing, this, onEdgeAliasing);</casmconfigpanel>
Shinya Kitaoka 120a6e
  m_thickness = new TNumField(this);
Shinya Kitaoka 120a6e
  m_thickness->setIsInteger(true);
Shinya Kitaoka 120a6e
  m_thickness->setRange(0, 15);
Shinya Kitaoka 120a6e
  m_thickness->setValue(8);
Shinya Kitaoka 120a6e
  m_thickness->disable();
Shinya Kitaoka 120a6e
  m_thickness->addAction(new NumFieldChanger(this, M_THICK));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_gamma = new TCheckBox(this, "Gamma");
Shinya Kitaoka 120a6e
  tconnect<casmconfigpanel>(*m_gamma, this, onGamma);</casmconfigpanel>
Shinya Kitaoka 120a6e
  m_gammaValue = new TNumField(this);
Shinya Kitaoka 120a6e
  m_gammaValue->setValue(0);
Shinya Kitaoka 120a6e
  m_gammaValue->disable();
Shinya Kitaoka 120a6e
  m_gammaValue->addAction(new NumFieldChanger(this, M_GAMMA));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_clap = new TCheckBox(this, "Add Clap");
Shinya Kitaoka 120a6e
  // tconnect<casmconfigpanel>(*m_clap, this, onClap);</casmconfigpanel>
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
m_outputScriptLabel = new TLabel(this);
Shinya Kitaoka 120a6e
m_outputScriptLabel->setText("Output Script:");
Shinya Kitaoka 120a6e
m_outputScript = new TOptionMenu(this);
Shinya Kitaoka 120a6e
m_outputScript->addOption("None");
Shinya Kitaoka 120a6e
//m_subPixelMove->setAction(new TOptionMenuAction<casmconfigpanel>(this,</casmconfigpanel>
Shinya Kitaoka 120a6e
&CasmConfigPanel::onOutputScript));
Shinya Kitaoka 120a6e
m_entryPointLabel = new TLabel(this);
Shinya Kitaoka 120a6e
m_entryPointLabel->setText("Entry Point:");
Shinya Kitaoka 120a6e
m_entryPoint = new TTextField(this);
Shinya Kitaoka 120a6e
m_entryPoint->setText("");
Shinya Kitaoka 120a6e
*/
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::configureNotify(const TDimension &d) {
Shinya Kitaoka 120a6e
  int x0 = 20;
Shinya Kitaoka 120a6e
  int y  = d.ly - 1 - 10;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int x = x0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_setupLabel->setGeometry(x, y - 15, x + 100, y);
Shinya Kitaoka 120a6e
  m_setupTextField->setGeometry(x + 104, y - 15, x + 650, y);
Shinya Kitaoka 120a6e
  m_setupBrowseBtn->setGeometry(x + 660, y - 15, x + 680, y);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  y -= 60;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_chunkSizeLabel->setGeometry(x, y - 15, x + 100, y);
Shinya Kitaoka 120a6e
  m_chunkSize->setGeometry(x + 110, y - 15, x + 156, y);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  y -= 40;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_fromLabel->setGeometry(x, y - 15, x + 50, y);
Shinya Kitaoka 120a6e
  m_from->setGeometry(x + 54, y - 15, x + 100, y);
Shinya Kitaoka 120a6e
  x += 120;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_toLabel->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  m_to->setGeometry(x + 84, y - 15, x + 130, y);
Shinya Kitaoka 120a6e
  x += 150;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_stepLabel->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  m_step->setGeometry(x + 84, y - 15, x + 130, y);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ///
Shinya Kitaoka 120a6e
  x = x0;
Shinya Kitaoka 120a6e
  y -= 40;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_shrinkLabel->setGeometry(x, y - 15, x + 50, y);
Shinya Kitaoka 120a6e
  m_shrink->setGeometry(x + 54, y - 15, x + 100, y);
Shinya Kitaoka 120a6e
  x += 120;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_renderTileLabel->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  m_renderTile->setGeometry(x + 84, y - 15, x + 130, y);
Shinya Kitaoka 120a6e
  x += 150;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_memChunkLabel->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  m_memChunk->setGeometry(x + 84, y - 15, x + 130, y);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  x = x0;
Shinya Kitaoka 120a6e
  y -= 40;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_subPixelMoveLabel->setGeometry(x, y - 15, x + 94, y);
Shinya Kitaoka 120a6e
  m_subPixelMove->setGeometry(x + 98, y - 15, x + 160, y);
Shinya Kitaoka 120a6e
  x += 180;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_processingLabel->setGeometry(x, y - 15, x + 74, y);
Shinya Kitaoka 120a6e
  m_processing->setGeometry(x + 78, y - 15, x + 140, y);
Shinya Kitaoka 120a6e
  x += 160;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_resampleQualityLabel->setGeometry(x, y - 15, x + 114, y);
Shinya Kitaoka 120a6e
  m_resampleQuality->setGeometry(x + 118, y - 15, x + 200, y);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  x = x0;
Shinya Kitaoka 120a6e
  y -= 40;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_focus->setGeometry(x, y - 15, x + 90, y);
Toshihiro Shimizu 890ddd
  x += 120;
Shinya Kitaoka 120a6e
  m_noOverwrite->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  x += 110;
Shinya Kitaoka 120a6e
  m_multimedia->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  x += 90;
Shinya Kitaoka 120a6e
  m_column->setGeometry(x, y - 15, x + 20, y);
Shinya Kitaoka 120a6e
  x += 30;
Shinya Kitaoka 120a6e
  m_lineart->setGeometry(x, y - 15, x + 60, y);
Shinya Kitaoka 120a6e
  x += 65;
Shinya Kitaoka 120a6e
  m_edgeAliasing->setGeometry(x, y - 15, x + 80, y);
Shinya Kitaoka 120a6e
  x += 90;
Shinya Kitaoka 120a6e
  m_thickness->setGeometry(x, y - 15, x + 30, y);
Shinya Kitaoka 120a6e
  x += 50;
Shinya Kitaoka 120a6e
  m_gamma->setGeometry(x, y - 15, x + 60, y);
Shinya Kitaoka 120a6e
  x += 70;
Shinya Kitaoka 120a6e
  m_gammaValue->setGeometry(x, y - 15, x + 30, y);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  x = x0;
Shinya Kitaoka 120a6e
  y -= 40;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_clap->setGeometry(x, y - 15, x + 90, y);
Shinya Kitaoka 120a6e
  /*
Shinya Kitaoka 120a6e
x += 120;
Shinya Kitaoka 120a6e
m_outputScriptLabel->setGeometry(x, y-15, x+94, y);
Shinya Kitaoka 120a6e
m_outputScript->setGeometry(x+98, y-15, x+160, y);
Shinya Kitaoka 120a6e
x +=180;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
m_entryPointLabel->setGeometry(x, y-15, x+94, y);
Shinya Kitaoka 120a6e
m_entryPoint->setGeometry(x+98, y-15, x+160, y);
Shinya Kitaoka 120a6e
*/
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::setTask(CasmTask *task) {
Shinya Kitaoka 120a6e
  m_task = task;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_chunkSize->setValue(m_task->m_taskChunksize);
Shinya Kitaoka 120a6e
  m_from->setValue(m_task->m_start);
Shinya Kitaoka 120a6e
  m_to->setValue(m_task->m_end);
Shinya Kitaoka 120a6e
  m_step->setValue(m_task->m_step);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_shrink->setValue(m_task->m_reduction);
Shinya Kitaoka 120a6e
  m_renderTile->setValue(m_task->m_renderTile);
Shinya Kitaoka 120a6e
  m_memChunk->setValue(m_task->m_memChunk);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  string move;
Shinya Kitaoka 120a6e
  if (m_task->m_moveType == CasmTask::M_INTMOVE)
Shinya Kitaoka 120a6e
    move = "None";
Shinya Kitaoka 120a6e
  else if (m_task->m_moveType == CasmTask::M_BG_FRACMOVE)
Shinya Kitaoka 120a6e
    move = "RGB";
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    move = "All";
Shinya Kitaoka 120a6e
  m_subPixelMove->setText(move);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  string bits;
Shinya Kitaoka 120a6e
  if (m_task->m_prec == 32)
Shinya Kitaoka 120a6e
    bits = "32 Bit";
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    bits = "64 Bit";
Shinya Kitaoka 120a6e
  m_processing->setText(bits);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  string quality = "";
Shinya Kitaoka 120a6e
  if (m_task->m_restype == CasmTask::RES_TYPE_STANDARD)
Shinya Kitaoka 120a6e
    quality = "Standard";
Shinya Kitaoka 120a6e
  else if (m_task->m_restype == CasmTask::RES_TYPE_IMPROVED)
Shinya Kitaoka 120a6e
    quality = "Improved";
Shinya Kitaoka 120a6e
  else if (m_task->m_restype == CasmTask::RES_TYPE_HIGH)
Shinya Kitaoka 120a6e
    quality = "High";
Shinya Kitaoka 120a6e
  m_resampleQuality->setText(quality);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_focus->select(m_task->m_cf);
Shinya Kitaoka 120a6e
  m_noOverwrite->select(m_task->m_noOverwrite);
Shinya Kitaoka 120a6e
  m_multimedia->select(m_task->m_multimedia);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_task->m_numColumn < 0)
Shinya Kitaoka 120a6e
    m_column->setText("All");
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_column->setText(toString(m_task->m_numColumn));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_task->m_lineart < 0) {
Shinya Kitaoka 120a6e
    m_lineart->disable();
Shinya Kitaoka 120a6e
    m_lineart->select(false);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_lineart->enable();
Shinya Kitaoka 120a6e
    m_lineart->select(true);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_task->m_edgeAliasing < 0) {
Shinya Kitaoka 120a6e
    m_edgeAliasing->disable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->select(false);
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_edgeAliasing->enable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->select(true);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_task->m_edgeAliasing >= 0 || m_task->m_lineart >= 0)
Shinya Kitaoka 120a6e
    m_thickness->setValue(tmax(m_task->m_edgeAliasing, m_task->m_lineart));
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_thickness->setValue(8);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_task->m_gamma < 0.) {
Shinya Kitaoka 120a6e
    m_gamma->select(false);
Shinya Kitaoka 120a6e
    m_gammaValue->setValue(0.0);
Shinya Kitaoka 120a6e
    m_gammaValue->disable();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_gamma->select(true);
Shinya Kitaoka 120a6e
    m_gammaValue->setValue(m_task->m_gamma);
Shinya Kitaoka 120a6e
    m_gammaValue->enable();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
CasmTask *CasmConfigPanel::getTask() const { return m_task; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onNumField(double v, int type) {
Shinya Kitaoka 120a6e
  switch (type) {
Shinya Kitaoka 120a6e
  case M_FROM:
Shinya Kitaoka 120a6e
    m_task->m_start = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_TO:
Shinya Kitaoka 120a6e
    m_task->m_end = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_STEP:
Shinya Kitaoka 120a6e
    m_task->m_step = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_SHRINK:
Shinya Kitaoka 120a6e
    m_task->m_reduction = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_RTILE:
Shinya Kitaoka 120a6e
    m_task->m_renderTile = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_MCHUNK:
Shinya Kitaoka 120a6e
    m_task->m_memChunk = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_THICK:
Shinya Kitaoka 120a6e
    if (m_lineart->isSelected()) m_task->m_lineart           = (int)v;
Shinya Kitaoka 120a6e
    if (m_edgeAliasing->isSelected()) m_task->m_edgeAliasing = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_GAMMA:
Shinya Kitaoka 120a6e
    m_task->m_gamma = v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  case M_CHUNKSIZE:
Shinya Kitaoka 120a6e
    m_task->m_taskChunksize = (int)v;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onColumnField(std::wstring value) {
Shinya Kitaoka 120a6e
  if (value == toWideString("") || value == toWideString("ALL") ||
Shinya Kitaoka 120a6e
      value == toWideString("All") || value == toWideString("all") ||
Shinya Kitaoka 120a6e
      value == toWideString("AL") || value == toWideString("Al") ||
Shinya Kitaoka 120a6e
      value == toWideString("a") || value == toWideString("A"))
Shinya Kitaoka 120a6e
    m_task->m_numColumn = -1;
Shinya Kitaoka 120a6e
  else if (is_num(toString(value)))
Shinya Kitaoka 120a6e
    m_task->m_numColumn = atoi(toString(value).c_str());
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    m_task->m_numColumn = -1;
Shinya Kitaoka 120a6e
    m_column->setText("All");
Shinya Kitaoka 120a6e
    TMessage::error("Only \"All\" or a number is a valid argument");
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::browseSetupFiles() {
Shinya Kitaoka 120a6e
  static FileBrowserPopup *popup = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (!popup) {
Shinya Kitaoka 120a6e
    CasmConfigPanel *csp = this;
Shinya Kitaoka 120a6e
    vector<string> fileTypes;</string>
Shinya Kitaoka 120a6e
    fileTypes.push_back("setup");
Shinya Kitaoka 120a6e
    popup = new FileBrowserPopup(csp, fileTypes);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    popup->setOkAction(new TFileBrowserPopupAction<casmconfigpanel>(</casmconfigpanel>
Shinya Kitaoka 120a6e
        csp, &CasmConfigPanel::loadSetup));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (!popup) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFilePath fp = Application::instance()->getCurrentFolder();
Shinya Kitaoka 120a6e
  if (fp != TFilePath()) popup->setCurrentDir(fp);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDimension d = TMainshell::getMainshell()->getSize();
Toshihiro Shimizu 890ddd
#ifdef WIN32
Shinya Kitaoka 120a6e
  HDC hdc = GetDC(0);
Shinya Kitaoka 120a6e
  d.lx    = GetDeviceCaps(hdc, HORZRES);
Shinya Kitaoka 120a6e
  d.ly    = GetDeviceCaps(hdc, VERTRES);
Shinya Kitaoka 120a6e
  ReleaseDC(0, hdc);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  d -= popup->getSize();
Shinya Kitaoka 120a6e
  // TDimension d = TMainshell::getMainshell()->getSize() - popup->getSize();
Shinya Kitaoka 120a6e
  popup->popup(TPoint(d.lx / 2, d.ly / 2));
Shinya Kitaoka 120a6e
  popup->setCaption("Load Setup");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::loadSetup(const TFilePath &fp) {
Shinya Kitaoka 120a6e
  if (!TFileStatus(fp).doesExist()) {
Shinya Kitaoka 120a6e
    string msg = toString(fp.getWideString()) + "\n";
Shinya Kitaoka 120a6e
    msg += "File not found\n";
Shinya Kitaoka 120a6e
    msg += "Please verify that the path and file name are correct";
Shinya Kitaoka 120a6e
    m_setupTextField->setText("");
Shinya Kitaoka 120a6e
    TMessage::error(msg);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  Application::instance()->setCurrentFolder(fp.getParentDir());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  string uncString = convertToUncString(fp);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_setupTextField->setText(uncString);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifdef WIN32
Shinya Kitaoka 120a6e
  int x = uncString.find("\\", 2);
Shinya Kitaoka 120a6e
  while (x != string::npos) {
Shinya Kitaoka 120a6e
    uncString.replace(x, 1, "/", 0, 1);
Shinya Kitaoka 120a6e
    x = uncString.find("\\", x + 1);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_task->m_setupFile = uncString;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onMultimedia(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  if (on) {
Shinya Kitaoka 120a6e
    m_task->m_multimedia = true;
Shinya Kitaoka 120a6e
    m_column->enable();
Shinya Kitaoka 120a6e
    m_lineart->enable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->enable();
Shinya Kitaoka 120a6e
    if (m_lineart->isSelected() || m_edgeAliasing->isSelected())
Shinya Kitaoka 120a6e
      m_thickness->enable();
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      m_thickness->disable();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_task->m_multimedia = false;
Shinya Kitaoka 120a6e
    m_column->disable();
Shinya Kitaoka 120a6e
    m_lineart->disable();
Shinya Kitaoka 120a6e
    m_lineart->select(false);
Shinya Kitaoka 120a6e
    m_edgeAliasing->disable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->select(false);
Shinya Kitaoka 120a6e
    m_thickness->setValue(8);
Shinya Kitaoka 120a6e
    m_thickness->disable();
Shinya Kitaoka 120a6e
    m_task->m_lineart = m_task->m_edgeAliasing = -1;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onLineart(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  if (on) {
Shinya Kitaoka 120a6e
    m_task->m_lineart      = (int)m_thickness->getValue();
Shinya Kitaoka 120a6e
    m_task->m_edgeAliasing = -1;
Shinya Kitaoka 120a6e
    m_lineart->enable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->disable();
Shinya Kitaoka 120a6e
    m_thickness->enable();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_task->m_lineart = -1;
Shinya Kitaoka 120a6e
    m_lineart->enable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->enable();
Shinya Kitaoka 120a6e
    m_thickness->disable();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onEdgeAliasing(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  if (on) {
Shinya Kitaoka 120a6e
    m_task->m_edgeAliasing = (int)m_thickness->getValue();
Shinya Kitaoka 120a6e
    m_task->m_lineart      = -1;
Shinya Kitaoka 120a6e
    m_lineart->disable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->enable();
Shinya Kitaoka 120a6e
    m_thickness->enable();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    m_task->m_edgeAliasing = -1;
Shinya Kitaoka 120a6e
    m_lineart->enable();
Shinya Kitaoka 120a6e
    m_edgeAliasing->enable();
Shinya Kitaoka 120a6e
    m_thickness->disable();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onConstantFocus(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  m_task->m_cf = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onOverwrite(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  m_task->m_noOverwrite = on;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onGamma(TCheckBox *box, bool on) {
Shinya Kitaoka 120a6e
  if (on)
Shinya Kitaoka 120a6e
    m_task->m_gamma = m_gammaValue->getValue();
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_task->m_gamma = -1.;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onSubPixelMove(string move) {
Shinya Kitaoka 120a6e
  if (move == "None")
Shinya Kitaoka 120a6e
    m_task->m_moveType = CasmTask::M_INTMOVE;
Shinya Kitaoka 120a6e
  else if (move == "RGB")
Shinya Kitaoka 120a6e
    m_task->m_moveType = CasmTask::M_BG_FRACMOVE;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_task->m_moveType = CasmTask::M_FRACMOVE;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onProcessing(string bits) {
Shinya Kitaoka 120a6e
  if (bits == "32 Bit")
Shinya Kitaoka 120a6e
    m_task->m_prec = 32;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_task->m_prec = 64;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void CasmConfigPanel::onResampleQuality(string quality) {
Shinya Kitaoka 120a6e
  if (quality == "Standard")
Shinya Kitaoka 120a6e
    m_task->m_restype = CasmTask::RES_TYPE_STANDARD;
Shinya Kitaoka 120a6e
  else if (quality == "Improved")
Shinya Kitaoka 120a6e
    m_task->m_restype = CasmTask::RES_TYPE_IMPROVED;
Shinya Kitaoka 120a6e
  else if (quality == "High")
Shinya Kitaoka 120a6e
    m_task->m_restype = CasmTask::RES_TYPE_HIGH;
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_task->m_restype = CasmTask::RES_TYPE_NONE;
Toshihiro Shimizu 890ddd
}