Exemple #1
0
void SyImageBase::loadQImage(const QImage &imageIn)
  {
  SProfileFunction
  int width = imageIn.width();
  int height = imageIn.height();

  XVector<float> data;
  data.resize(width * height);

  xsize bytesPerPixel = imageIn.depth()/8;
  const quint8 *pixel = imageIn.bits();
  for(int i = 0; i < height; ++i )
    {
    xsize rowPos = i * width;
    for(int j = 0; j < width; ++j)
      {
      data[rowPos+j] = (float)*pixel/255.0f;
      pixel += bytesPerPixel;
      }
    }

  image.set(width, height, data);

  postSet();
  }
enum SetResponse XMainWindow::set(const ParameterList &pParams)
{
  _lastSetParams = pParams;

  _private->loadScriptEngine();
  QTimer::singleShot(0, this, SLOT(postSet()));

  return NoError;
}
Exemple #3
0
enum SetResponse XWidget::set( const ParameterList & pParams )
{
  _lastSetParams = pParams;

  loadScriptEngine();

  QTimer::singleShot(0, this, SLOT(postSet()));

  return NoError;
}
Exemple #4
0
void Parameter::set(void* data, Channel channel)
{  
    if (channel < 0 || channel >= m_channelCount) {
        throw ValueError("Invalid channel " + channel);
    }
    // TODO: lazy setting
    preSet();
    m_channels[channel].d = data;
    postSet();
}
Exemple #5
0
void Parameter::set(float f, Channel channel)
{
    if (channel < 0 || channel >= m_channelCount) {
        throw ValueError("Invalid channel " + channel);
    }
    if (m_type == kFloat) {
        // TODO: lazy setting
        preSet();
        m_channels[channel].f = f;
        postSet();
    } else {
        throw ValueError("Tried setting float value on parameter with type " + m_type);
    }
}
Exemple #6
0
void Parameter::set(const std::string& s, Channel channel)
{
    if (channel < 0 || channel >= m_channelCount) {
        throw ValueError("Invalid channel " + channel);
    }
    if (m_type == kString) {
        // TODO: lazy setting
        preSet();
        delete m_channels[channel].s;
        m_channels[channel].s = new std::string(s);
        postSet();
    } else {
        throw ValueError("Tried setting string value on parameter with type " + m_type);
    }
}
Exemple #7
0
  void reweight(Weight& wt, Util::Random01& rng) const {
    double cost = wt.getValue();
    double newcost = cost;
    maybeSet(newcost);
    if (!weights.empty()) {
      if (!IsFeatureWeight<Weight>::value)
        SDL_THROW_LOG(Hypergraph.Reweight, ConfigException,
                      "supplied (unusable) feature weights for non-feature hypergraph");
      double weighted = FeatureDotProduct<Weight, double>::dotProduct(wt, weights);
      if (weightsAdd)
        newcost += weighted;
      else
        newcost = weighted;
    }
    postSet(newcost, rng);

    if (clearFeatures)
      wt = Weight((typename Weight::FloatT)newcost);
    else
      wt.value_ = newcost;
  }