Beispiel #1
0
void CLyapWolfMethod::initializeParameter()
{
  assertParameter("Orthonormalization Interval", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0);
  assertParameter("Overall time", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1000.0);
  assertParameter("Relative Tolerance", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-6);
  assertParameter("Absolute Tolerance", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-12);
  assertParameter("Max Internal Steps", CCopasiParameter::UINT, (unsigned C_INT32) 10000);

  // Check whether we have an (obsolete) parameter "Use Default Absolute Tolerance"
  CCopasiParameter *pParm;

  if ((pParm = getParameter("Use Default Absolute Tolerance")) != NULL)
    {
      C_FLOAT64 NewValue;

      if (pParm->getValue< bool >())
        {
          // The default
          NewValue = 1.e-12;
        }
      else
        {
          NewValue = getValue< C_FLOAT64 >("Absolute Tolerance");
        }

      setValue("Absolute Tolerance", NewValue);
      removeParameter("Use Default Absolute Tolerance");
    }

  // These parameters are no longer supported.
  removeParameter("Adams Max Order");
  removeParameter("BDF Max Order");
}
Beispiel #2
0
void CTauLeapMethod::initializeParameter()
{
  CCopasiParameter *pParm;

  assertParameter("Epsilon", CCopasiParameter::DOUBLE, (C_FLOAT64) 0.001);
  assertParameter("Max Internal Steps", CCopasiParameter::UINT, (unsigned C_INT32) 10000);
  assertParameter("Use Random Seed", CCopasiParameter::BOOL, false);
  assertParameter("Random Seed", CCopasiParameter::UINT, (unsigned C_INT32) 1);

  // Check whether we have a method with the old parameter names
  if ((pParm = getParameter("TAULEAP.Tau")) != NULL)
    {
      removeParameter("TAULEAP.Tau");

      if ((pParm = getParameter("TAULEAP.UseRandomSeed")) != NULL)
        {
          setValue("Use Random Seed", pParm->getValue< bool >());
          removeParameter("TAULEAP.UseRandomSeed");
        }

      if ((pParm = getParameter("TAULEAP.RandomSeed")) != NULL)
        {
          setValue("Random Seed", pParm->getValue< unsigned C_INT32 >());
          removeParameter("TAULEAP.RandomSeed");
        }
    }
}
bool CExperimentObjectMap::CDataColumn::setScale(const C_FLOAT64 & weight)
{
  if (isnan(weight))
    {
      if (mpScale != NULL)
        {
          removeParameter("Weight");
          mpScale = NULL;
        }

      return true;
    }

  C_FLOAT64 DefaultWeight = getDefaultScale();

  if (weight != DefaultWeight || isnan(DefaultWeight))
    {
      if (mpScale != NULL)
        *mpScale = weight;
      else
        mpScale = assertParameter("Weight", CCopasiParameter::UDOUBLE, weight);

      return true;
    }

  if (mpScale != NULL)
    {
      removeParameter("Weight");
      mpScale = NULL;
    }

  return true;
}
Beispiel #4
0
void AdditiveSynthVoice::setNumHarmonics(float num) {
    
    for (int i = 0; i < _numHarmonics; i++) {
        
        char name[12];
        sprintf(name, "Harmonic %d", i+1);
        removeParameter(name);
    }
    
    _numHarmonics = num;
    
    /* Clear the harmonic amplitudes vector, and clear any harmonic amplitude params from the parameter list and sample update and sample rate listeners */
    _harmonicAmps.clear();
    for (int i = 0; i < _sampleRateListeners.size(); i++) {
        
    }
    
    SynthParameter* p;
    for (int i = 0; i < _numHarmonics; i++) {
        
        char name[12];
        sprintf(name, "Harmonic %d", i+1);
        p = new SynthParameter(name, _fs, i == 0 ? 1.0f : 0.0f, 0.1f);
        p->setRange(0.0f, 1.0f);
        
        _harmonicAmps.push_back(p);            // Store harmonic amplitudes in a vector
        removeParameter(name);
        addParameter(p);
    }
}
Beispiel #5
0
bool CFitItem::elevateChildren()
{
  // The functionality of SavedValue is no handled more transparently
  // through the StartValue. Therefore, in case we encounter an old file
  // we need to copy its value.
  CCopasiParameter *pSavedValue = getParameter("SavedValue");

  if (pSavedValue)
    {
      setStartValue(*pSavedValue->getValue().pDOUBLE);
      removeParameter("SavedValue");
    }

  mpGrpAffectedExperiments =
    elevate<CCopasiParameterGroup, CCopasiParameterGroup>(mpGrpAffectedExperiments);

  if (!mpGrpAffectedExperiments) return false;

  mpGrpAffectedCrossValidations =
    elevate<CCopasiParameterGroup, CCopasiParameterGroup>(mpGrpAffectedCrossValidations);

  if (!mpGrpAffectedCrossValidations) return false;

  return true;
}
//!
//! Constructor of the PinGraphicsItem class.
//! Creates a pin graphics item representing the given parameter.
//!
//! \param parent The graphics item this item will be a child of.
//! \param index The index of the pin in a list of pins.
//! \param parameter The parameter this pin item represents.
//!
PinGraphicsItem::PinGraphicsItem ( QGraphicsItem *parent, int index, Parameter *parameter )
    : BaseRectItem(Parameter::getTypeColor(parameter->getType()), true, parent)
{
	m_abstractParameter = parameter;
    m_isGroup = m_abstractParameter->isGroup();
    m_isRootGroup = m_abstractParameter->getName().isEmpty();
    connect(parameter, SIGNAL(destroyed()), SLOT(removeParameter()));
    m_pinType = parameter->getPinType();
    m_parameterTypeFilter = Parameter::T_Unknown;

    // set the item's position and size
    setRect(QRectF(0, 0, PIN_WIDTH, PIN_HEIGHT));
    if (m_pinType == Parameter::PT_Input)
        setPos(PIN_OFFSET_LEFT, PIN_OFFSET_TOP + index * PIN_VERTICAL_SPACING);
    else
        setPos(parent->boundingRect().width() - PIN_OFFSET_RIGHT - rect().width(), PIN_OFFSET_TOP + index * PIN_VERTICAL_SPACING);

    // set the item's tool tip
    QString pinInfo = parameter->getName();
    pinInfo += "\nType: " + Parameter::getTypeName(parameter->getType());
    if (parameter->getMultiplicity() == Parameter::M_OneOrMore)
        pinInfo += " List";
    QString parameterDescription = parameter->getDescription();
    if (!parameterDescription.isEmpty())
        pinInfo += "\nDescription: " + parameterDescription;
    setToolTip(pinInfo);

	//setCacheMode(DeviceCoordinateCache);

    INC_INSTANCE_COUNTER
}
void ScriptParametersDialog::addParameter(const QString &name, const QString &value, bool code, ActionTools::ScriptParameter::ParameterType parameterType)
{
	int rowCount = ui->parameterTable->rowCount();

	ui->parameterTable->insertRow(rowCount);

	QLineEdit *nameLineEdit = new QLineEdit(this);
	nameLineEdit->setText(name);

	ui->parameterTable->setCellWidget(rowCount, 0, nameLineEdit);

	mParameterTypes.append(parameterType);
	setupValueParameter(rowCount, parameterType, value, code);

	QComboBox *typeComboBox = new QComboBox(this);
	typeComboBox->addItems(QStringList() << tr("Text") << tr("Number") << tr("Window title") << tr("File") << tr("Line"));
	typeComboBox->setCurrentIndex(parameterType);
	typeComboBox->installEventFilter(this);
	connect(typeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(parameterTypeChanged(int)));
	ui->parameterTable->setCellWidget(rowCount, 2, typeComboBox);

	QPushButton *removeParameterPushButton = new QPushButton(tr("Remove"), this);
	connect(removeParameterPushButton, SIGNAL(clicked()), this, SLOT(removeParameter()));

	ui->parameterTable->setCellWidget(rowCount, 3, removeParameterPushButton);
}
Beispiel #8
0
void Z3DPunctaFilter::deinitialize()
{
  std::vector<ZParameter*> paras = m_rendererBase->getParameters();
  for (size_t i=0; i<paras.size(); i++) {
    //paras[i]->disconnect(this);
    removeParameter(paras[i]);
  }
  Z3DGeometryFilter::deinitialize();
}
Beispiel #9
0
void CFitProblem::initializeParameter()
{
  removeParameter("Subtask");
  mpParmSubtaskCN = NULL;
  removeParameter("ObjectiveExpression");
  mpParmObjectiveExpression = NULL;
  *mpParmMaximize = false;

  mpParmSteadyStateCN =
    assertParameter("Steady-State", CCopasiParameter::CN, CCopasiObjectName(""))->getValue().pCN;
  mpParmTimeCourseCN =
    assertParameter("Time-Course", CCopasiParameter::CN, CCopasiObjectName(""))->getValue().pCN;

  assertGroup("Experiment Set");


  elevateChildren();
}
Beispiel #10
0
void ParameterManager::prepareQuit() {

    std::vector<vistle::Parameter *> toRemove;
    for (auto &param: parameters) {
        toRemove.push_back(param.second.get());
    }
    for (auto &param: toRemove) {
        removeParameter(param);
    }
}
Beispiel #11
0
	//! Constructor
    HFPlanner::HFPlanner(SPACETYPE stype, Sample *init, Sample *goal, SampleSet *samples, Sampler *sampler, WorkSpace *ws, LocalPlanner *lcPlan, KthReal ssize):
              gridPlanner(stype, init, goal, samples, sampler, ws, lcPlan, ssize)
	{
		//set intial values
	  
		_guiName = _idName =  "HF Planner";
		removeParameter("Max. Samples");
		removeParameter("Step Size");
      
		_hfiter=10;
		_mainiter=10;
		addParameter("HF relax iter", _hfiter);
		addParameter("main iter", _mainiter);
		_dirichlet=0;
		addParameter("(1)dirichlet (0)neumann", _dirichlet);
		_goalPotential=-1000;
        addParameter("Goal potential", _goalPotential);
		_stepSize=1.0;

    }
Beispiel #12
0
bool CTSSAProblem::elevateChildren()
{
  // If we have an old COPASI file "Duration" is not set
  // but we can fix that.
  if (*mpDuration == 1.0) // the default
    setDuration(*mpStepSize *(C_FLOAT64) *mpStepNumber);

  removeParameter("Deuflhard Tolerance");

  return true;
}
Beispiel #13
0
void CSteadyStateMethod::initializeParameter()
{
  CCopasiParameter *pParm;

  mpSSResolution = assertParameter("Resolution", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-009);
  mpDerivationResolution = mpSSResolution;

  mpDerivationFactor = assertParameter("Derivation Factor", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-003);

  // Check whether we have a method with the old parameter names
  if ((pParm = getParameter("Newton.DerivationFactor")) != NULL)
    {
      setValue("Derivation Factor", pParm->getValue< C_FLOAT64 >());
      removeParameter("Newton.DerivationFactor");
    }

  if ((pParm = getParameter("Newton.Resolution")) != NULL)
    {
      setValue("Resolution", pParm->getValue< C_FLOAT64 >());
      removeParameter("Newton.Resolution");
    }
}
Beispiel #14
0
    /**
     * @brief ClassMethod::addParameter
     * @param name
     * @param typeId
     * @return
     */
    SharedField ClassMethod::addParameter(const QString &name, const common::ID &typeId)
    {
        if (!name.isEmpty()) {
            auto existField = getParameter(name);
            if (existField)
                removeParameter(name);
        }

        auto f = std::make_shared<Field>(name, typeId);
        m_Parameters << f;

        return f;
    }
void UnusedParametersCheck::warnOnUnusedParameter(
    const MatchFinder::MatchResult &Result, const FunctionDecl *Function,
    unsigned ParamIndex) {
  const auto *Param = Function->getParamDecl(ParamIndex);
  auto MyDiag = diag(Param->getLocation(), "parameter '%0' is unused")
                << Param->getName();

  auto UsedByRef = [&] {
    return !ast_matchers::match(
                decl(hasDescendant(
                    declRefExpr(to(equalsNode(Function)),
                                unless(hasAncestor(
                                    callExpr(callee(equalsNode(Function)))))))),
                *Result.Context->getTranslationUnitDecl(), *Result.Context)
                .empty();
  };

  // Comment out parameter name for non-local functions.
  if (Function->isExternallyVisible() ||
      !Result.SourceManager->isInMainFile(Function->getLocation()) ||
      UsedByRef()) {
    SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd());
    // Note: We always add a space before the '/*' to not accidentally create a
    // '*/*' for pointer types, which doesn't start a comment. clang-format will
    // clean this up afterwards.
    MyDiag << FixItHint::CreateReplacement(
        RemovalRange, (Twine(" /*") + Param->getName() + "*/").str());
    return;
  }

  // Fix all redeclarations.
  for (const FunctionDecl *FD : Function->redecls())
    if (FD->param_size())
      MyDiag << removeParameter(FD, ParamIndex);

  // Fix all call sites.
  auto CallMatches = ast_matchers::match(
      decl(forEachDescendant(
          callExpr(callee(functionDecl(equalsNode(Function)))).bind("x"))),
      *Result.Context->getTranslationUnitDecl(), *Result.Context);
  for (const auto &Match : CallMatches)
    MyDiag << removeArgument(Match.getNodeAs<CallExpr>("x"), ParamIndex);
}
bool CExperimentObjectMap::CDataColumn::setObjectCN(const std::string & objectCN)
{
  if (objectCN == "")
    {
      if (mpObjectCN != NULL)
        {
          removeParameter("Object CN");
          mpObjectCN = NULL;
        }
    }
  else
    {
      if (mpObjectCN != NULL)
        *mpObjectCN = objectCN;
      else
        mpObjectCN =
          assertParameter("Object CN", CCopasiParameter::CN, (CCopasiObjectName) objectCN);
    }

  return true;
}
Beispiel #17
0
void CHybridMethod::initializeParameter()
{
  CCopasiParameter *pParm;

  assertParameter("Max Internal Steps", CCopasiParameter::INT, (C_INT32) MAX_STEPS);
  assertParameter("Lower Limit", CCopasiParameter::DOUBLE, (C_FLOAT64) LOWER_STOCH_LIMIT);
  assertParameter("Upper Limit", CCopasiParameter::DOUBLE, (C_FLOAT64) UPPER_STOCH_LIMIT);
  assertParameter("Partitioning Interval", CCopasiParameter::UINT, (unsigned C_INT32) PARTITIONING_INTERVAL);
  assertParameter("Use Random Seed", CCopasiParameter::BOOL, (bool) USE_RANDOM_SEED);
  assertParameter("Random Seed", CCopasiParameter::UINT, (unsigned C_INT32) RANDOM_SEED);

  // Check whether we have a method with the old parameter names
  if ((pParm = getParameter("HYBRID.MaxSteps")) != NULL)
    {
      setValue("Max Internal Steps", pParm->getValue< C_INT32 >());
      removeParameter("HYBRID.MaxSteps");

      if ((pParm = getParameter("HYBRID.LowerStochLimit")) != NULL)
        {
          setValue("Lower Limit", pParm->getValue< C_FLOAT64 >());
          removeParameter("HYBRID.LowerStochLimit");
        }

      if ((pParm = getParameter("HYBRID.UpperStochLimit")) != NULL)
        {
          setValue("Upper Limit", pParm->getValue< C_FLOAT64 >());
          removeParameter("HYBRID.UpperStochLimit");
        }

      if ((pParm = getParameter("HYBRID.PartitioningInterval")) != NULL)
        {
          setValue("Partitioning Interval", pParm->getValue< unsigned C_INT32 >());
          removeParameter("HYBRID.PartitioningInterval");
        }

      if ((pParm = getParameter("UseRandomSeed")) != NULL)
        {
          setValue("Use Random Seed", pParm->getValue< bool >());
          removeParameter("UseRandomSeed");
        }

      if ((pParm = getParameter("")) != NULL)
        {
          setValue("Random Seed", pParm->getValue< unsigned C_INT32 >());
          removeParameter("");
        }
    }
}
void UnusedParametersCheck::warnOnUnusedParameter(
    const MatchFinder::MatchResult &Result, const FunctionDecl *Function,
    unsigned ParamIndex) {
  const auto *Param = Function->getParamDecl(ParamIndex);
  auto MyDiag = diag(Param->getLocation(), "parameter '%0' is unused")
                << Param->getName();

  auto UsedByRef = [&] {
    return !ast_matchers::match(
                decl(hasDescendant(
                    declRefExpr(to(equalsNode(Function)),
                                unless(hasAncestor(
                                    callExpr(callee(equalsNode(Function)))))))),
                *Result.Context->getTranslationUnitDecl(), *Result.Context)
                .empty();
  };

  // Comment out parameter name for non-local functions.
  if ((Function->isExternallyVisible() &&
       Function->getStorageClass() != StorageClass::SC_Static) ||
      UsedByRef()) {
    SourceRange RemovalRange(Param->getLocation(), Param->getLocEnd());
    MyDiag << FixItHint::CreateReplacement(
        RemovalRange, (Twine(" /*") + Param->getName() + "*/").str());
    return;
  }

  // Fix all redeclarations.
  for (const FunctionDecl *FD : Function->redecls())
    MyDiag << removeParameter(FD, ParamIndex);

  // Fix all call sites.
  auto CallMatches = ast_matchers::match(
      decl(forEachDescendant(
          callExpr(callee(functionDecl(equalsNode(Function)))).bind("x"))),
      *Result.Context->getTranslationUnitDecl(), *Result.Context);
  for (const auto &Match : CallMatches)
    MyDiag << removeArgument(Match.getNodeAs<CallExpr>("x"), ParamIndex);
}
Beispiel #19
0
void ContentType::parse( const EString &s )
{
    EmailParser p( s );
    p.whitespace();
    while ( p.present( ":" ) )
        p.whitespace();

    bool mustGuess = false;

    if ( p.atEnd() ) {
        t = "text";
        st = "plain";
    }
    else {
        uint x = p.mark();
        if ( p.nextChar() == '/' )
            mustGuess = true;
        else
            t = p.mimeToken().lower();
        if ( p.atEnd() ) {
            if ( s == "text" ) {
                t = "text"; // elm? mailtool? someone does this, anyway.
                st = "plain";
            }
            // the remainder is from RFC 1049
            else if ( s == "postscript" ) {
                t = "application";
                st = "postscript";
            }
            else if ( s == "postscript" ) {
                t = "application";
                st = "postscript";
            }
            else if ( s == "sgml" ) {
                t = "text";
                st = "sgml";
            }
            else if ( s == "tex" ) {
                t = "application";
                st = "x-tex";
            }
            else if ( s == "troff" ) {
                t = "application";
                st = "x-troff";
            }
            else if ( s == "dvi" ) {
                t = "application";
                st = "x-dvi";
            }
            else if ( s.startsWith( "x-" ) ) {
                st = "x-rfc1049-" + s;
                t = "application";
            }
            else {
                // scribe and undefined types
                setError( "Invalid Content-Type: " + s.quoted() );
            }
        }
        else {
            if ( p.nextChar() == '/' ) {
                p.step();
                if ( !p.atEnd() || p.nextChar() != ';' )
                    st = p.mimeToken().lower();
                if ( st.isEmpty() )
                    mustGuess = true;
            }
            else if ( p.nextChar() == '=' ) {
                // oh no. someone skipped the content-type and
                // supplied only some parameters. we'll assume it's
                // text/plain and parse the parameters.
                t = "text";
                st = "plain";
                p.restore( x );
                mustGuess = true;
            }
            else {
                addParameter( "original-type", t + "/" + st );
                t = "application";
                st = "octet-stream";
                mustGuess = true;
            }
            parseParameters( &p );
        }
    }

    if ( mustGuess ) {
        EString fn = parameter( "name" );
        if ( fn.isEmpty() )
            fn = parameter( "filename" );
        while ( fn.endsWith( "." ) )
            fn.truncate( fn.length() - 1 );
        fn = fn.lower();
        if ( fn.endsWith( "jpg" ) || fn.endsWith( "jpeg" ) ) {
            t = "image";
            st = "jpeg";
        }
        else if ( fn.endsWith( "htm" ) || fn.endsWith( "html" ) ) {
            t = "text";
            st = "html";
        }
        else if ( fn.isEmpty() && st.isEmpty() && t == "text" ) {
            st = "plain";
        }
        else if ( t == "text" ) {
            addParameter( "original-type", t + "/" + st );
            st = "plain";
        }
        else {
            addParameter( "original-type", t + "/" + st );
            t = "application";
            st = "octet-stream";
        }
    }

    if ( t.isEmpty() || st.isEmpty() )
        setError( "Both type and subtype must be nonempty: " + s.quoted() );

    if ( valid() && t == "multipart" && st == "appledouble" &&
         parameter( "boundary" ).isEmpty() ) {
        // some people send appledouble without the header. what can
        // we do? let's just call it application/octet-stream. whoever
        // wants to decode can try, or reply.
        t = "application";
        st = "octet-steam";
    }

    if ( valid() && !p.atEnd() &&
         t == "multipart" && parameter( "boundary" ).isEmpty() &&
         s.lower().containsWord( "boundary" ) ) {
        EmailParser csp( s.mid( s.lower().find( "boundary" ) ) );
        csp.require( "boundary" );
        csp.whitespace();
        if ( csp.present( "=" ) )
            csp.whitespace();
        uint m = csp.mark();
        EString b = csp.string();
        if ( b.isEmpty() || !csp.ok() ) {
            csp.restore( m );
            b = csp.input().mid( csp.pos() ).section( ";", 1 ).simplified();
            if ( !b.isQuoted() )
                b.replace( "\\", "" );
            if ( b.isQuoted() )
                b = b.unquoted();
            else if ( b.isQuoted( '\'' ) )
                b = b.unquoted( '\'' );
        }
        if ( !b.isEmpty() )
            addParameter( "boundary", b );
    }

    if ( valid() && t == "multipart" && parameter( "boundary" ).isEmpty() )
        setError( "Multipart entities must have a boundary parameter." );

    if ( !parameter( "charset" ).isEmpty() ) {
        Codec * c = Codec::byName( parameter( "charset" ) );
        if ( c ) {
            EString cs = c->name().lower();
            if ( t == "text" && cs == "us-ascii" )
                removeParameter( "charset" );
            else if ( cs != parameter( "charset" ).lower() )
                addParameter( "charset", cs );
        }
    }

    if ( valid() && !p.atEnd() &&
         t == "text" && parameter( "charset" ).isEmpty() &&
         s.mid( p.pos() ).lower().containsWord( "charset" ) ) {
        EmailParser csp( s.mid( s.lower().find( "charset" ) ) );
        csp.require( "charset" );
        csp.whitespace();
        if ( csp.present( "=" ) )
            csp.whitespace();
        Codec * c = Codec::byName( csp.dotAtom() );
        if ( c )
            addParameter( "charset", c->name().lower() );
    }

    if ( !valid() )
        setUnparsedValue( s );
}
Beispiel #20
0
void CExperimentSet::removeExperiment(const size_t & index)
{
  removeParameter(index + mNonExperiments);
}
Beispiel #21
0
void Z3DPunctaFilter::prepareData()
{
  if (!m_dataIsInvalid)
    return;

  deregisterPickingObjects(getPickingManager());

  // convert puncta to format that glsl can use
  m_specularAndShininess.clear();
  m_pointAndRadius.clear();
  //m_sourceColorMapper.clear();
  int xMin = std::numeric_limits<int>::max();
  int xMax = std::numeric_limits<int>::min();
  int yMin = std::numeric_limits<int>::max();
  int yMax = std::numeric_limits<int>::min();
  int zMin = std::numeric_limits<int>::max();
  int zMax = std::numeric_limits<int>::min();
  for (size_t i=0; i<m_punctaList.size(); i++) {
    if (m_useSameSizeForAllPuncta.get())
      m_pointAndRadius.push_back(glm::vec4(m_punctaList[i]->x(), m_punctaList[i]->y(), m_punctaList[i]->z(), 2.f));
    else
      m_pointAndRadius.push_back(glm::vec4(m_punctaList[i]->x(), m_punctaList[i]->y(), m_punctaList[i]->z(), m_punctaList[i]->radius()));
    if (m_punctaList[i]->x() > xMax)
      xMax = static_cast<int>(std::ceil(m_punctaList[i]->x()));
    if (m_punctaList[i]->x() < xMin)
      xMin = static_cast<int>(std::floor(m_punctaList[i]->x()));
    if (m_punctaList[i]->y() > yMax)
      yMax = static_cast<int>(std::ceil(m_punctaList[i]->y()));
    if (m_punctaList[i]->y() < yMin)
      yMin = static_cast<int>(std::floor(m_punctaList[i]->y()));
    if (m_punctaList[i]->z() > zMax)
      zMax = static_cast<int>(std::ceil(m_punctaList[i]->z()));
    if (m_punctaList[i]->z() < zMin)
      zMin = static_cast<int>(std::floor(m_punctaList[i]->z()));
    m_specularAndShininess.push_back(glm::vec4(m_punctaList[i]->maxIntensity()/255.f,
                                               m_punctaList[i]->maxIntensity()/255.f,
                                               m_punctaList[i]->maxIntensity()/255.f,
                                               m_punctaList[i]->maxIntensity()/2.f));
  }
  //for (size_t i=0; i<m_origPunctaList.size(); ++i)
    //m_sourceColorMapper.insert(std::pair<QString, size_t>(m_origPunctaList[i]->source(), 0));

  m_xCut.setRange(xMin, xMax);
  m_xCut.set(glm::ivec2(xMin, xMax));
  m_yCut.setRange(yMin, yMax);
  m_yCut.set(glm::ivec2(yMin, yMax));
  m_zCut.setRange(zMin, zMax);
  m_zCut.set(glm::ivec2(zMin, zMax));

  //  std::map<QString,size_t>::iterator it;
  //  size_t index = 0;
  //  size_t numOfPrevColor = m_colorsForDifferentSource.size();
  //  for (it = m_sourceColorMapper.begin(); it != m_sourceColorMapper.end(); it++) {
  //    m_sourceColorMapper[it->first] = index++;
  //    if (index > numOfPrevColor) {
  //      QString guiname = QString("Source %1 Color").arg(index);
  //      m_colorsForDifferentSource.push_back(new ZVec4Parameter(guiname, glm::vec4(
  //                                                                ZRandomInstance.randReal<float>(),
  //                                                                ZRandomInstance.randReal<float>(),
  //                                                                ZRandomInstance.randReal<float>(),
  //                                                                1.f)));
  //      m_colorsForDifferentSource[index-1]->setStyle("COLOR");
  //      connect(m_colorsForDifferentSource[index-1], SIGNAL(valueChanged()), this, SLOT(prepareColor()));
  //    }
  //  }
  //  if (m_widgetsGroup) {
  //    for (size_t i=0; i<m_colorsForDifferentSourceWidgetsGroup.size(); i++) {
  //      delete m_colorsForDifferentSourceWidgetsGroup[i];
  //    }
  //    m_colorsForDifferentSourceWidgetsGroup.clear();
  //  }
  //  if (numOfPrevColor < index) {
  //    for (size_t i=numOfPrevColor; i<m_colorsForDifferentSource.size(); i++) {
  //      addParameter(m_colorsForDifferentSource[i]);
  //    }
  //  } else if (numOfPrevColor > index) {
  //    for (size_t i=index; i<m_colorsForDifferentSource.size(); i++) {
  //      removeParameter(m_colorsForDifferentSource[i]);
  //      delete m_colorsForDifferentSource[i];
  //    }
  //    m_colorsForDifferentSource.resize(index);
  //  }

  bool needUpdateWidget = false;
  QList<QString> allSources;
  for (size_t i=0; i<m_origPunctaList.size(); ++i) {
    int idx = allSources.indexOf(m_origPunctaList[i]->source());
    if (idx == -1) {
      allSources.push_back(m_origPunctaList[i]->source());
      idx = allSources.size() - 1;
    }
    QString guiname = QString("Source %1 Color").arg(idx + 1);
    if (m_sourceColorMapper.find(m_origPunctaList[i]->source()) == m_sourceColorMapper.end()) {
      m_sourceColorMapper[m_origPunctaList[i]->source()] =
          new ZVec4Parameter(guiname, glm::vec4(ZRandomInstance.randReal<float>(),
                                                ZRandomInstance.randReal<float>(),
                                                ZRandomInstance.randReal<float>(),
                                                1.f));
      m_sourceColorMapper[m_origPunctaList[i]->source()]->setStyle("COLOR");
      connect(m_sourceColorMapper[m_origPunctaList[i]->source()], SIGNAL(valueChanged()),
          this, SLOT(prepareColor()));
      addParameter(m_sourceColorMapper[m_origPunctaList[i]->source()]);
      needUpdateWidget = true;
    } else {
      m_sourceColorMapper[m_origPunctaList[i]->source()]->setName(guiname);
    }
  }
  // remove colors for not exist puncta source
  std::map<QString, ZVec4Parameter*>::iterator it = m_sourceColorMapper.begin();
  while (it != m_sourceColorMapper.end()) {
    if (!allSources.contains(it->first)) {
      std::map<QString, ZVec4Parameter*>::iterator itCopy = it;
      ++it;
      removeParameter(itCopy->second);
      delete itCopy->second;
      m_sourceColorMapper.erase(itCopy);
      needUpdateWidget = true;
    } else
      ++it;
  }
  if (needUpdateWidget)
    updateWidgetsGroup();

  m_sphereRenderer->setData(&m_pointAndRadius, &m_specularAndShininess);
  prepareColor();
  adjustWidgets();
  //if (numOfPrevColor != index)   // number of puncta source changed
    //updateWidgetsGroup();
  m_dataIsInvalid = false;
}
Beispiel #22
0
void CLsodaMethod::initializeParameter()
{
  CCopasiParameter *pParm;

  mpReducedModel =
    assertParameter("Integrate Reduced Model", CCopasiParameter::BOOL, (bool) false)->getValue().pBOOL;
  mpRelativeTolerance =
    assertParameter("Relative Tolerance", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-6)->getValue().pUDOUBLE;
  mpAbsoluteTolerance =
    assertParameter("Absolute Tolerance", CCopasiParameter::UDOUBLE, (C_FLOAT64) 1.0e-12)->getValue().pUDOUBLE;
  mpMaxInternalSteps =
    assertParameter("Max Internal Steps", CCopasiParameter::UINT, (unsigned C_INT32) 10000)->getValue().pUINT;

  // Check whether we have a method with the old parameter names
  if ((pParm = getParameter("LSODA.RelativeTolerance")) != NULL)
    {
      *mpRelativeTolerance = *pParm->getValue().pUDOUBLE;
      removeParameter("LSODA.RelativeTolerance");

      if ((pParm = getParameter("LSODA.AbsoluteTolerance")) != NULL)
        {
          *mpAbsoluteTolerance = *pParm->getValue().pUDOUBLE;
          removeParameter("LSODA.AbsoluteTolerance");
        }

      if ((pParm = getParameter("LSODA.AdamsMaxOrder")) != NULL)
        {
          removeParameter("LSODA.AdamsMaxOrder");
        }

      if ((pParm = getParameter("LSODA.BDFMaxOrder")) != NULL)
        {
          removeParameter("LSODA.BDFMaxOrder");
        }

      if ((pParm = getParameter("LSODA.MaxStepsInternal")) != NULL)
        {
          *mpMaxInternalSteps = *pParm->getValue().pUINT;
          removeParameter("LSODA.MaxStepsInternal");
        }
    }

  // Check whether we have a method with "Use Default Absolute Tolerance"
  if ((pParm = getParameter("Use Default Absolute Tolerance")) != NULL)
    {
      C_FLOAT64 NewValue;

      if (*pParm->getValue().pBOOL)
        {
          // The default
          NewValue = 1.e-12;
        }
      else
        {
          C_FLOAT64 OldValue = *mpAbsoluteTolerance;
          CCopasiDataModel* pDataModel = getObjectDataModel();
          assert(pDataModel != NULL);
          CModel * pModel = pDataModel->getModel();

          if (pModel == NULL)
            // The default
            NewValue = 1.e-12;
          else
            {
              const CCopasiVectorNS< CCompartment > & Compartment = pModel->getCompartments();
              unsigned C_INT32 i, imax;
              C_FLOAT64 Volume = DBL_MAX;

              for (i = 0, imax = Compartment.size(); i < imax; i++)
                if (Compartment[i]->getValue() < Volume)
                  Volume = Compartment[i]->getValue();

              if (Volume == DBL_MAX)
                // The default
                NewValue = 1.e-12;
              else
                // Invert the scaling as best as we can
                NewValue = OldValue / (Volume * pModel->getQuantity2NumberFactor());
            }
        }

      *mpAbsoluteTolerance = NewValue;
      removeParameter("Use Default Absolute Tolerance");
    }

  // These parameters are no longer supported.
  removeParameter("Adams Max Order");
  removeParameter("BDF Max Order");
}