Exemplo n.º 1
0
int FractureBox::LoadFractureMapDialog()
{
        Fl_Native_File_Chooser fileBrowser = Fl_Native_File_Chooser(Fl_Native_File_Chooser::BROWSE_FILE);
        fileBrowser.title("Select a fracture map");
        fileBrowser.filter("Image\t*.{fracmap}\n");
        fileBrowser.directory(Global::gMainWindow->GetTextureDirectory());
        if(fileBrowser.show() == 0)
        {
            // LoadFractureMap(fileBrowser.filename(), true);
            Global::gScene->LoadFractureMap(fileBrowser.filename());
            return 1;
        }
        return 0;
}
Exemplo n.º 2
0
void DialogMain::loadImage()
{
    if ( cbUseThreshold != NULL )
    {
        if ( cbUseThreshold->value() > 0 )
        {
            cbUseThreshold->value( 0 );
            thresholdControl();
        }
    }

    Fl_Native_File_Chooser nFC;

    nFC.title( "Choose a RAW image file to open" );
    nFC.type( Fl_Native_File_Chooser::BROWSE_FILE );
    nFC.filter( " RAW Image\t*.raw\n" );
    nFC.directory( currentPath );
    nFC.preset_file(NULL);

    int retVal = nFC.show();
    if ( retVal == 0 )
    {
        if ( strlen(nFC.filename()) == 0 )
        {
            boxImageFileName->label(" ");
            fl_alert("No image selected.");
            return;
        }

        if ( dentalRAW == NULL )
        {
            dentalRAW = new DentalRAWReader();
        }

        if ( dentalRAW != NULL )
        {
            fl_cursor( FL_CURSOR_WAIT, 0, 0 );

#if( UNICODE && DEBUG )
            if ( sizeof(TCHAR) != 2 )
            {
                fl_alert("What's wrong? why it is not unicode ?");
                return;
            }
#endif

            _TSTRING refPath =  _TCM2W( nFC.filename() );

            if ( dentalRAW->Load( refPath.c_str() ) == true )
            {
                rawimagefilename = nFC.filename();

                boxImageFileName->label( rawimagefilename.c_str() );
                boxImageFileName->redraw();
            }
            else
            {
                fl_alert("Failed to load RAW image:\n%s", nFC.filename() );
            }

            if ( dentalRAW->GetAnalisysReport( weight_report ) == false )
            {
                memset( &weight_report, 0, sizeof (weight_report) );
            }

            if( vsThresholdMin != NULL )
            {
                vsThresholdMin->range( 0.0f, float( dentalRAW->getMaximumLevel() ) - 1.0f );
                vsThresholdMin->value( 0 );
            }

            if( vsThresholdMax != NULL )
            {
                vsThresholdMax->range( 1.0f, float( dentalRAW->getMaximumLevel() ) );
                vsThresholdMax->value( dentalRAW->getMaximumLevel() );
            }

            updateImageInfo();
            drawHistogram();
            importRAWimage();

            fl_cursor( FL_CURSOR_DEFAULT, 0, 0 );
        }
    }
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
  Fl::lock();
#ifndef WIN32
  Plus4Emu::setGUIColorScheme(0);
#else
  Plus4Emu::setGUIColorScheme(1);
#endif
  bool    forceInstallFlag = false;
  std::string installDirectory = "";
  {
    int     i = 0;
    while (++i < argc) {
      if (argv[i][0] == '-') {
        if (argv[i][1] == '-' && argv[i][2] == '\0')
          break;
        if (argv[i][1] == 'f' && argv[i][2] == '\0') {
          forceInstallFlag = true;
          continue;
        }
      }
      installDirectory = argv[i];
    }
    if (i < (argc - 1))
      installDirectory = argv[argc - 1];
  }
#ifndef WIN32
  if (installDirectory.length() == 0 && forceInstallFlag)
    installDirectory = Plus4Emu::getPlus4EmuHomeDirectory();
#endif
  if (installDirectory.length() == 0) {
    std::string tmp = "";
#ifndef WIN32
    tmp = Plus4Emu::getPlus4EmuHomeDirectory();
#endif
    Fl_Native_File_Chooser  *w = new Fl_Native_File_Chooser();
    w->type(Fl_Native_File_Chooser::BROWSE_SAVE_DIRECTORY);
    w->title("Select installation directory for plus4emu data files");
    w->filter("*");
    w->directory(tmp.c_str());
    if (w->show() == 0) {
      if (w->filename() != (char *) 0)
        installDirectory = w->filename();
    }
    delete w;
  }
  Plus4Emu::stripString(installDirectory);
  if (installDirectory.length() == 0)
    return -1;
#ifndef WIN32
  while (installDirectory[installDirectory.length() - 1] == '/' &&
         installDirectory.length() > 1) {
    installDirectory.resize(installDirectory.length() - 1);
  }
  {
    mkdir(installDirectory.c_str(), 0755);
    std::string tmp = installDirectory;
    if (tmp[tmp.length() - 1] != '/')
      tmp += '/';
    std::string tmp2 = tmp + "config";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "demo";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "disk";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "progs";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "roms";
    mkdir(tmp2.c_str(), 0755);
    tmp2 = tmp + "tape";
    mkdir(tmp2.c_str(), 0755);
  }
#else
  while ((installDirectory[installDirectory.length() - 1] == '/' ||
          installDirectory[installDirectory.length() - 1] == '\\') &&
         !(installDirectory.length() <= 1 ||
           (installDirectory.length() == 3 && installDirectory[1] == ':'))) {
    installDirectory.resize(installDirectory.length() - 1);
  }
  {
    _mkdir(installDirectory.c_str());
    std::string tmp = installDirectory;
    if (tmp[tmp.length() - 1] != '/' && tmp[tmp.length() - 1] != '\\')
      tmp += '\\';
    std::string tmp2 = tmp + "config";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "demo";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "disk";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "progs";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "roms";
    _mkdir(tmp2.c_str());
    tmp2 = tmp + "tape";
    _mkdir(tmp2.c_str());
  }
#endif
#ifdef WIN32
  uint8_t c = '\\';
#else
  uint8_t c = '/';
#endif
  if (installDirectory[installDirectory.length() - 1] != c)
    installDirectory += c;
  std::string configDirectory = installDirectory + "config";
  configDirectory += c;
  std::string romDirectory = installDirectory + "roms";
  romDirectory += c;
  Plus4EmuConfigInstallerGUI  *gui = new Plus4EmuConfigInstallerGUI();
  if (!forceInstallFlag) {
    gui->mainWindow->show();
    do {
      Fl::wait(0.05);
    } while (gui->mainWindow->shown());
  }
  else
    gui->enableCfgInstall = true;
  try {
    Plus4Emu::ConfigurationDB     *config = (Plus4Emu::ConfigurationDB *) 0;
    Plus4EmuMachineConfiguration  *mCfg = (Plus4EmuMachineConfiguration *) 0;
    if (gui->enableCfgInstall) {
      Plus4EmuDisplaySndConfiguration   *dsCfg =
          (Plus4EmuDisplaySndConfiguration *) 0;
      config = new Plus4Emu::ConfigurationDB();
      {
        Plus4EmuGUIConfiguration  *gCfg =
            new Plus4EmuGUIConfiguration(*config, installDirectory);
        try {
          Plus4Emu::File  f;
          config->saveState(f);
          f.writeFile("gui_cfg.dat", true);
        }
        catch (std::exception& e) {
          gui->errorMessage(e.what());
        }
        delete gCfg;
      }
      delete config;
      config = new Plus4Emu::ConfigurationDB();
      mCfg = new Plus4EmuMachineConfiguration(*config, 6, romDirectory);
      dsCfg = new Plus4EmuDisplaySndConfiguration(*config);
      setKeyboardConfiguration(*config, (gui->keyboardMapHU ? 5 : 4));
      try {
        Plus4Emu::File  f;
        config->saveState(f);
        f.writeFile("plus4cfg.dat", true);
      }
      catch (std::exception& e) {
        gui->errorMessage(e.what());
      }
      delete config;
      delete mCfg;
      delete dsCfg;
      config = (Plus4Emu::ConfigurationDB *) 0;
      mCfg = (Plus4EmuMachineConfiguration *) 0;
    }
    for (int i = 0; i < 16; i++) {
      config = new Plus4Emu::ConfigurationDB();
      mCfg = new Plus4EmuMachineConfiguration(*config, i, romDirectory);
      try {
        std::string fileName = configDirectory;
        fileName += machineConfigFileNames[i];
        config->saveState(fileName.c_str(), false);
      }
      catch (std::exception& e) {
        gui->errorMessage(e.what());
      }
      delete config;
      delete mCfg;
      config = (Plus4Emu::ConfigurationDB *) 0;
      mCfg = (Plus4EmuMachineConfiguration *) 0;
    }
    for (int i = 0; i < 8; i++) {
      if (keyboardConfigFileNames[i] != (char *) 0) {
        config = new Plus4Emu::ConfigurationDB();
        try {
          setKeyboardConfiguration(*config, i);
          std::string fileName = configDirectory;
          fileName += keyboardConfigFileNames[i];
          config->saveState(fileName.c_str(), false);
        }
        catch (std::exception& e) {
          gui->errorMessage(e.what());
        }
        delete config;
        config = (Plus4Emu::ConfigurationDB *) 0;
      }
    }
  }
  catch (std::exception& e) {
    gui->errorMessage(e.what());
    delete gui;
    return -1;
  }
  delete gui;
  return 0;
}