示例#1
0
SplineEditorWidget::SplineEditorWidget(QWidget *parent) :
  QWidget(parent)
{
  m_parent = parent;

  QPen m_pointPen;
  QBrush m_pointBrush;
  QPen m_connectionPen;
  m_pointPen = QPen(QColor(0, 0, 0, 255), 1);
  m_connectionPen = QPen(QColor(200, 200, 200, 150), 1);
  m_pointBrush = QBrush(QColor(255, 255, 255, 200));

  m_1dHist  = new QRadioButton("1D", this);
  m_2dHist  = new QRadioButton("2D", this);

  m_vol1 = new QRadioButton("V1", this);
  m_vol2 = new QRadioButton("V2", this);
  m_vol3 = new QRadioButton("V3", this);
  m_vol4 = new QRadioButton("V4", this);

  QButtonGroup *butGrp1 = new QButtonGroup(this);
  butGrp1->setExclusive(true);
  butGrp1->addButton(m_1dHist);
  butGrp1->addButton(m_2dHist);
  QButtonGroup *butGrp2 = new QButtonGroup(this);
  butGrp2->setExclusive(true);
  butGrp2->addButton(m_vol1);
  butGrp2->addButton(m_vol2);
  butGrp2->addButton(m_vol3);
  butGrp2->addButton(m_vol4);

  m_2dHist->setChecked(true);
  m_vol1->setChecked(true);

  QHBoxLayout *hbox = new QHBoxLayout();
  hbox->addStretch();
  hbox->addWidget(m_vol4);
  hbox->addWidget(m_vol3);
  hbox->addWidget(m_vol2);
  hbox->addWidget(m_vol1);

  m_gbotValue = new QLineEdit("1.0");
  m_gbotValue->setMaximumSize(30, 25);
  QRegExp rx("(\\-?\\d*\\.?\\d*\\s?)");
  QRegExpValidator *validator = new QRegExpValidator(rx,0);
  m_gbotValue->setValidator(validator);

  m_gtopValue = new QLineEdit("1.0");
  m_gtopValue->setMaximumSize(30, 25);
  m_gtopValue->setValidator(validator);

  QHBoxLayout *hboxt = new QHBoxLayout();
  hboxt->addWidget(m_gbotValue);
  hboxt->addStretch();
  hboxt->addWidget(m_1dHist);
  hboxt->addWidget(m_2dHist);
  hboxt->addStretch();
  hboxt->addWidget(m_gtopValue);

  m_gbotSlider = new QSlider(Qt::Vertical);
  m_gbotSlider->setRange(0, 255);
  m_gbotSlider->setValue(0);

  m_gtopSlider = new QSlider(Qt::Vertical);
  m_gtopSlider->setRange(0, 255);
  m_gtopSlider->setValue(255);

  m_16bitEditor = new RemapHistogramWidget(this);
  m_16bitEditor->setSizePolicy(QSizePolicy::Expanding,
			       QSizePolicy::Expanding);

  m_splineEditor = new SplineEditor(this);
  m_splineEditor->setSizePolicy(QSizePolicy::Expanding,
				QSizePolicy::Expanding);
  QHBoxLayout *hbox1 = new QHBoxLayout;
  hbox1->addWidget(m_gbotSlider);
  hbox1->addWidget(m_splineEditor);
  hbox1->addWidget(m_16bitEditor);
  hbox1->addWidget(m_gtopSlider);

  QVBoxLayout *vbox = new QVBoxLayout();
  vbox->addLayout(hboxt);
  vbox->addLayout(hbox1);
  vbox->addLayout(hbox);

  setLayout(vbox);

  m_vol1->hide();
  m_vol2->hide();
  m_vol3->hide();
  m_vol4->hide();


  m_splineEditor->setShapePen(m_pointPen);
  m_splineEditor->setConnectionPen(m_connectionPen);
  m_splineEditor->setShapeBrush(m_pointBrush);


  connect(m_gtopSlider, SIGNAL(sliderReleased()),
	  this, SLOT(gtopSliderReleased()));
  connect(m_gbotSlider, SIGNAL(sliderReleased()),
	  this, SLOT(gbotSliderReleased()));
  connect(m_gtopValue, SIGNAL(editingFinished()),
	  this, SLOT(gValueChanged()));
  connect(m_gbotValue, SIGNAL(editingFinished()),
	  this, SLOT(gValueChanged()));

  connect(m_1dHist, SIGNAL(toggled(bool)),
	  this, SLOT(hist1DClicked(bool)));

  connect(m_2dHist, SIGNAL(toggled(bool)),
	  this, SLOT(hist2DClicked(bool)));

  connect(m_vol1, SIGNAL(toggled(bool)),
	  this, SLOT(vol1Clicked(bool)));

  connect(m_vol2, SIGNAL(toggled(bool)),
	  this, SLOT(vol2Clicked(bool)));

  connect(m_vol3, SIGNAL(toggled(bool)),
	  this, SLOT(vol3Clicked(bool)));

  connect(m_vol4, SIGNAL(toggled(bool)),
	  this, SLOT(vol4Clicked(bool)));

  connect(m_splineEditor, SIGNAL(refreshDisplay()),
	  this, SLOT(update()));

  connect(m_splineEditor, SIGNAL(splineChanged()),
	  this, SLOT(updateTransferFunction()));

  connect(m_splineEditor, SIGNAL(selectEvent(QGradientStops)),
	  this, SLOT(selectSpineEvent(QGradientStops)));

  connect(m_splineEditor, SIGNAL(deselectEvent()),
	  this, SLOT(deselectSpineEvent()));

  connect(m_splineEditor, SIGNAL(applyUndo(bool)),
	  this, SIGNAL(applyUndo(bool)));

  connect(m_16bitEditor, SIGNAL(newMapping(float, float)),
	  this, SLOT(updateTransferFunction(float, float)));

  setMinimumSize(200, 200);

  m_16bitEditor->hide();
}
示例#2
0
TApp::TApp()
    : m_currentScene(0)
    , m_currentXsheet(0)
    , m_currentFrame(0)
    , m_currentColumn(0)
    , m_currentLevel(0)
    , m_currentTool(0)
    , m_currentObject(0)
    , m_currentSelection(0)
    , m_currentOnionSkinMask(0)
    , m_currentFx(0)
    , m_mainWindow(0)
    , m_autosaveTimer(0)
    , m_autosaveSuspended(false)
    , m_isStarting(false)
    , m_isPenCloseToTablet(false) {
  m_currentScene         = new TSceneHandle();
  m_currentXsheet        = new TXsheetHandle();
  m_currentFrame         = new TFrameHandle();
  m_currentColumn        = new TColumnHandle();
  m_currentLevel         = new TXshLevelHandle();
  m_currentTool          = new ToolHandle();
  m_currentObject        = new TObjectHandle();
  m_currentOnionSkinMask = new TOnionSkinMaskHandle();
  m_currentFx            = new TFxHandle();
  m_currentSelection     = TSelectionHandle::getCurrent();

  m_paletteController = new PaletteController();

  bool ret = true;

  ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetChanged()), this,
                                SLOT(onXsheetChanged()));

  ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSoundChanged()),
                                this, SLOT(onXsheetSoundChanged()));

  ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneSwitched()), this,
                                SLOT(onSceneSwitched()));

  ret = ret && QObject::connect(m_currentScene, SIGNAL(sceneChanged()), this,
                                SLOT(onSceneChanged()));

  ret = ret && QObject::connect(m_currentXsheet, SIGNAL(xsheetSwitched()), this,
                                SLOT(onXsheetSwitched()));

  ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this,
                                SLOT(onFrameSwitched()));

  ret = ret && QObject::connect(m_currentFrame, SIGNAL(frameSwitched()), this,
                                SLOT(onImageChanged()));

  ret = ret && QObject::connect(m_currentFx, SIGNAL(fxSwitched()), this,
                                SLOT(onFxSwitched()));

  ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()),
                                this, SLOT(onColumnIndexSwitched()));

  ret = ret && QObject::connect(m_currentColumn, SIGNAL(columnIndexSwitched()),
                                this, SLOT(onImageChanged()));

  ret = ret &&
        QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)),
                         this, SLOT(onImageChanged()));

  ret = ret &&
        QObject::connect(m_currentLevel, SIGNAL(xshLevelSwitched(TXshLevel *)),
                         this, SLOT(onXshLevelSwitched(TXshLevel *)));

  ret = ret && QObject::connect(m_currentLevel, SIGNAL(xshLevelChanged()), this,
                                SLOT(onXshLevelChanged()));

  ret = ret && QObject::connect(m_currentObject, SIGNAL(objectSwitched()), this,
                                SLOT(onObjectSwitched()));

  ret = ret && QObject::connect(m_currentObject, SIGNAL(splineChanged()), this,
                                SLOT(onSplineChanged()));

  ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),
                                SIGNAL(paletteChanged()), this,
                                SLOT(onPaletteChanged()));

  ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),
                                SIGNAL(colorStyleSwitched()), this,
                                SLOT(onLevelColorStyleSwitched()));

  ret = ret && QObject::connect(m_paletteController->getCurrentLevelPalette(),
                                SIGNAL(colorStyleChangedOnMouseRelease()), this,
                                SLOT(onLevelColorStyleChanged()));

  ret = ret && QObject::connect(m_paletteController->getCurrentCleanupPalette(),
                                SIGNAL(paletteChanged()), m_currentScene,
                                SIGNAL(sceneChanged()));

  TMeasureManager::instance()->addCameraMeasures(getCurrentCameraSize);

  m_autosaveTimer = new QTimer(this);
  ret             = ret &&
        connect(m_autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));

  Preferences *preferences = Preferences::instance();

  if (preferences->isRasterOptimizedMemory()) {
    if (!TBigMemoryManager::instance()->init(
            (int)(/*15*1024*/ TSystem::getFreeMemorySize(true) * .8)))
      DVGui::warning(tr("Error allocating memory: not enough memory."));
  }
  ret = ret &&
        connect(preferences, SIGNAL(stopAutoSave()), SLOT(onStopAutoSave()));
  ret = ret &&
        connect(preferences, SIGNAL(startAutoSave()), SLOT(onStartAutoSave()));
  ret = ret && connect(m_currentTool, SIGNAL(toolEditingFinished()),
                       SLOT(onToolEditingFinished()));

  if (preferences->isAutosaveEnabled())
    m_autosaveTimer->start(preferences->getAutosavePeriod() * 1000 * 60);

  UnitParameters::setCurrentDpiGetter(getCurrentDpi);
  assert(ret);
}