Ejemplo n.º 1
0
void PreviewToggleCommand::enable() {
  // Cleanup Preview and Camera Test are exclusive. In case, disable the latter.
  // NOTE: This is done *before* attaching, since attach may invoke a preview
  // rebuild.
  CameraTestCheck *tc = CameraTestCheck::instance();
  tc->setIsEnabled(false);

  // Attach to the model
  CleanupSettingsModel *model = CleanupSettingsModel::instance();

  model->attach(CleanupSettingsModel::LISTENER |
                CleanupSettingsModel::PREVIEWER);

  // Connect signals
  bool ret = true;
  ret      = ret && connect(model, SIGNAL(previewDataChanged()), this,
                       SLOT(onPreviewDataChanged()));
  ret = ret && connect(model, SIGNAL(modelChanged(bool)), this,
                       SLOT(onModelChanged(bool)));
  ret = ret && connect(&m_timer, SIGNAL(timeout()), this, SLOT(postProcess()));

  TPaletteHandle *ph =
      TApp::instance()->getPaletteController()->getCurrentCleanupPalette();
  ret =
      ret && connect(ph, SIGNAL(colorStyleChanged()), &m_timer, SLOT(start()));
  ret = ret && connect(ph, SIGNAL(paletteChanged()), &m_timer, SLOT(start()));
  assert(ret);

  onPreviewDataChanged();

  // in preview cleanup mode, tools are forbidden! Reverting to hand...
  TApp::instance()->getCurrentTool()->setTool(T_Hand);
}
Ejemplo n.º 2
0
void PreviewToggleCommand::disable() {
  CleanupSettingsModel *model = CleanupSettingsModel::instance();

  model->detach(CleanupSettingsModel::LISTENER |
                CleanupSettingsModel::PREVIEWER);

  bool ret = true;
  ret      = ret && disconnect(model, SIGNAL(previewDataChanged()), this,
                          SLOT(onPreviewDataChanged()));
  ret = ret && disconnect(model, SIGNAL(modelChanged(bool)), this,
                          SLOT(onModelChanged(bool)));
  ret =
      ret && disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(postProcess()));

  // Cleanup palette changes all falls under post-processing stuff. And do not
  // involve the model.
  TPaletteHandle *ph =
      TApp::instance()->getPaletteController()->getCurrentCleanupPalette();
  ret = ret &&
        disconnect(ph, SIGNAL(colorStyleChanged()), &m_timer, SLOT(start()));
  ret =
      ret && disconnect(ph, SIGNAL(paletteChanged()), &m_timer, SLOT(start()));
  assert(ret);

  clean();

  TApp::instance()->getCurrentLevel()->notifyLevelChange();
}
Ejemplo n.º 3
0
void CameraTestToggleCommand::enable() {
  /*---既に現在のツールがCameraTestになっている場合はreturn---*/
  m_oldTool = TApp::instance()->getCurrentTool()->getTool();
  if (m_oldTool->getName().compare("T_CameraTest") == 0) {
    CameraTestCheck::instance()->setIsEnabled(true);
    disable();
    return;
  }

  // Cleanup Preview and Camera Test are exclusive. In case, disable the latter.
  // NOTE: This is done *before* attaching, since attach may invoke a preview
  // rebuild.
  CleanupPreviewCheck *pc = CleanupPreviewCheck::instance();
  pc->setIsEnabled(false);

  // Attach to the model
  CleanupSettingsModel *model = CleanupSettingsModel::instance();
  model->attach(
      CleanupSettingsModel::LISTENER | CleanupSettingsModel::CAMERATEST, false);

  // Connect signals
  bool ret = true;
  ret      = ret && connect(model, SIGNAL(previewDataChanged()), this,
                       SLOT(onPreviewDataChanged()));
  assert(ret);

  onPreviewDataChanged();

  TApp::instance()->getCurrentTool()->setTool("T_CameraTest");
}
Ejemplo n.º 4
0
void CameraTestToggleCommand::disable() {
  CleanupSettingsModel *model = CleanupSettingsModel::instance();
  model->detach(CleanupSettingsModel::LISTENER |
                CleanupSettingsModel::CAMERATEST);

  bool ret = true;
  ret      = ret && disconnect(model, SIGNAL(previewDataChanged()), this,
                          SLOT(onPreviewDataChanged()));
  assert(ret);

  clean();

  TApp::instance()->getCurrentLevel()->notifyLevelChange();

  TApp::instance()->getCurrentTool()->setTool(
      QString::fromStdString(m_oldTool->getName()));
  m_oldTool = 0;
}
Ejemplo n.º 5
0
void RGBMatrixEditor::slotPreviewTimeout()
{
    if (m_matrix == NULL || m_group == NULL || m_matrix->duration() <= 0)
        return;

    RGBMap map;

    m_previewIterator += MasterTimer::tick();

    if (m_previewIterator >= m_matrix->duration())
    {
        int stepsCount = m_matrix->stepsCount();
        //qDebug() << "previewTimeout. Step:" << m_previewStep;
        if (m_matrix->runOrder() == RGBMatrix::PingPong)
        {
            if (m_previewDirection == Function::Forward && (m_previewStep + 1) == stepsCount)
                m_previewDirection = Function::Backward;
            else if (m_previewDirection == Function::Backward && (m_previewStep - 1) < 0)
                m_previewDirection = Function::Forward;
        }

        if (m_previewDirection == Function::Forward)
        {
            m_previewStep++;
            if (m_previewStep >= stepsCount)
            {
                m_previewStep = 0;
                m_matrix->setStepColor(m_matrix->startColor());
            }
            else
                m_matrix->updateStepColor(m_previewStep);
        }
        else
        {
            m_previewStep--;
            if (m_previewStep < 0)
            {
                m_previewStep = stepsCount - 1;
                if (m_matrix->endColor().isValid())
                    m_matrix->setStepColor(m_matrix->endColor());
                else
                    m_matrix->setStepColor(m_matrix->startColor());
            }
            else
                m_matrix->updateStepColor(m_previewStep);
        }
        map = m_matrix->previewMap(m_previewStep);
        m_previewIterator = 0;
/*
        for (int y = 0; y < map.size(); y++)
        {
            for (int x = 0; x < map[y].size(); x++)
            {
                QLCPoint pt(x, y);
                if (m_group->head(pt).isValid())
                {
                    if (shape->color() != QColor(map[y][x]).rgb())
                        shape->setColor(map[y][x]);

                    if (shape->color() == QColor(Qt::black).rgb())
                        shape->draw(m_matrix->fadeOutSpeed());
                    else
                        shape->draw(m_matrix->fadeInSpeed());
                }
            }
        }
*/
        if (m_previewData.isEmpty() || map.isEmpty())
            return;

        QHashIterator<QLCPoint, GroupHead> it(m_group->headHash());
        while(it.hasNext())
        {
            it.next();

            QLCPoint pt(it.key());
            //GroupHead head(it.value());
            int ptIdx = pt.x() + (pt.y() * m_group->size().width());
            if (ptIdx < m_previewData.size())
                m_previewData[ptIdx] = QVariant(QColor(map[pt.y()][pt.x()]));
        }

        //qDebug() << "Preview data changed !";
        emit previewDataChanged(m_previewData);
    }
}