示例#1
1
void SetRange(QCustomPlot& plot, int index, QVariantMap range, QCPAxis::AxisType type)
{
	auto g = plot.graph(index);
	
	auto it = range.find("lo");
	if (it != range.end())
	{
		switch (type)
		{
		case QCPAxis::atLeft:
			g->valueAxis()->setRangeLower(it->toReal());
			break;
		case QCPAxis::atBottom:
			g->keyAxis()->setRangeLower(it->toReal());
			break;
		}
	}
	it = range.find("up");
	if (it != range.end())
	{
		switch (type)
		{
		case QCPAxis::atLeft:
			g->valueAxis()->setRangeUpper(it->toReal());
			break;
		case QCPAxis::atBottom:
			g->keyAxis()->setRangeUpper(it->toReal());
			break;
		}
	}
}
void c_assignvar::generate()
{
	/// Execute the assigning of variables
	string memberOf = (g_objStack.empty()) ? "" : g_objStack.top();
	void *parent = (g_dataStack.empty()) ? NULL : g_dataStack.top();
	string value;
	char varType = m_expression->getType();

	if(varType == STRING)    value = m_expression->getText();
	else if(varType == REAL) value = toText(m_expression->getReal());

	// Set the built-in or custom variable
	if(m_custom == false)
		c_compiler::setVariable(m_varName.c_str(), memberOf.c_str(), parent, value);
	else
	{
		// Set the value of the custom variable
		int scope = g_scope;
		while(scope >= 0)
		{
			if(varType == STRING)
			{
				// Get the string value
				if(g_strings.find(scope) != g_strings.end())
				{
					if(g_strings[scope].find(m_varName) != g_strings[scope].end())
					{
						g_strings[scope][m_varName] = value;
						break;
					}
				}
			}
			else if(varType == REAL)
			{
				// Set either the integer value or the float value in that scope which have the variable
				if( g_integers.find(scope) != g_integers.end() )
				{
					if( g_integers[scope].find(m_varName) != g_integers[scope].end() )
					{
						g_integers[scope][m_varName] = (int)toReal(&value);
						break;
					}
				}
				else if(g_floats.find(scope) != g_floats.end())
				{
					if( g_floats[scope].find(m_varName) != g_floats[scope].end() )
					{
						g_floats[scope][m_varName] = toReal(&value);
						break;
					}
				}
			}
			scope--;
		}
	}
}
示例#3
0
void ValueSlider::
        rangeChanged(int min, int max)
{
    emit rangeChanged(toReal(min), toReal(max));

    lineEdit()->setToolTip(QString("%3 [%1, %2]")
                           .arg(minimum(),0,'f',decimals(minimum()))
                           .arg(maximum(),0,'f',decimals(maximum()))
                           .arg(toolTip()));
    //setValidator(new QDoubleValidator(minimum(), maximum(), 1000));
    setValidator(new QDoubleValidator());// minimum(), maximum(), 1000));
}
void c_decvar::generate()
{
	/// Set the declared variable to the value given to it
	char varType = m_expression->getType();
	string value;
	if(varType == STRING)    value = m_expression->getText();
	else if(varType == REAL) value = toText(m_expression->getReal());

	// Set the value of the custom variable
	if(m_type == E_KW_INT) g_integers[g_scope][m_varName] = (int)toReal(&value);
	else if(m_type == E_KW_FLOAT) g_floats[g_scope][m_varName] = toReal(&value);
	else if(m_type == E_KW_STRING) g_strings[g_scope][m_varName] = value;
}
示例#5
0
文件: Field.c 项目: aivaras16/nitro
NITFAPI(NITF_BOOL) nitf_Field_get(nitf_Field * field,
                                  NITF_DATA * outValue,
                                  nitf_ConvType convType,
                                  size_t length, nitf_Error * error)
{
    NITF_BOOL status = NITF_FAILURE;
    switch (convType)
    {
        case NITF_CONV_UINT:
            status = toUint(field, outValue, length, error);
            break;

        case NITF_CONV_INT:
            status = toInt(field, outValue, length, error);
            break;

        case NITF_CONV_STRING:
            status = toString(field, (char *) outValue, length, error);
            break;

        case NITF_CONV_RAW:
            status = toRaw(field, (char *) outValue, length, error);
            break;

        case NITF_CONV_REAL:
            status = toReal(field, outValue, length, error);
            break;
    }
    return status;
}
示例#6
0
StringList ShareManager::getRealPaths(const string& virtualPath) {
	if(virtualPath.empty())
		throw ShareException("empty virtual path");

	StringList ret;

	Lock l(cs);

	if(*(virtualPath.end() - 1) == '/') {
		// directory
		Directory::Ptr d = splitVirtual(virtualPath).first;

		// imitate Directory::getRealPath
		if(d->getParent()) {
			ret.push_back(d->getParent()->getRealPath(this,d->getName()));
		} else {
			for(auto& i: shares) {
				if(Util::stricmp(i.second, d->getName()) == 0) {
					// remove the trailing path sep
					if(FileFindIter(i.first.substr(0, i.first.size() - 1)) != FileFindIter()) {
						ret.push_back(i.first);
					}
				}
			}
		}

	} else {
		// file
		ret.push_back(toReal(virtualPath,false));
	}

	return ret;
}
double c_exprvar::getReal()
{
	string memberOf = (g_objStack.empty()) ? "" : g_objStack.top();
	void *parent = (g_dataStack.empty()) ? NULL : g_dataStack.top();

	if( c_compiler::getVariable(m_varname.c_str(), memberOf.c_str()) )
	{
		string e = c_compiler::getVariable(m_varname.c_str(), memberOf.c_str(), parent);
		return toReal(&e);
	}
	int scope = g_scope;
	while(scope >= 0)
	{
		if(g_integers.find(scope) != g_integers.end())
		{
			if(g_integers[scope].find(m_varname) != g_integers[scope].end())
				return g_integers[scope][m_varname];
		}
		if(g_floats.find(scope) != g_floats.end())
		{
			if(g_floats[g_scope].find(m_varname) != g_floats[g_scope].end())
				return g_floats[g_scope][m_varname];
		}
		scope--;
	}
	return 0.0;
}
示例#8
0
文件: CJson.cpp 项目: colinw7/CJson
void
CJson::String::
printReal(std::ostream &os) const
{
  double r;

  if (toReal(r))
    os << r;
  else
    print(os);
}
Number JSON::toNumber(const JSON::JSONValue& value)
{
    MMLT_precondition_msg(
        isNumber(value),
        "Coordinate is not a number!"
    );

    if(isInt(value))
    {
        return toInt(value);
    }
    else
    {
        MMLT_precondition(isReal(value));
        return toReal(value);
    }
}
示例#10
0
void LinearSolver :: solve( Factor& A,
                            vector<Quaternion>& x,
                            const vector<Quaternion>& b )
// solves the linear system Ax = b where A is positive-semidefinite
{
    int n = x.size();
    Dense result( cc, n*4, 1 );
    Dense    rhs( cc, n*4, 1 );

    // convert right-hand side to real values
    toReal( b, rhs );

    // solve real linear system
    result = cholmod_l_solve( CHOLMOD_A, *A, *rhs, cc );

    // convert solution back to quaternions
    toQuat( result, x );
}
示例#11
0
    inline ber::Value Value::toBerValue() const
    {
        switch(type().value())
        {
            case ParameterType::Integer:
                return ber::Value(toInteger());

            case ParameterType::Real:
                return ber::Value(toReal());

            case ParameterType::String:
                return ber::Value(toString());

            case ParameterType::Octets:
                return ber::Value(toOctets());

            case ParameterType::Boolean:
                return ber::Value(toBoolean());
        }

        return ber::Value();
    }
示例#12
0
文件: minips.cpp 项目: endriff/sam2p
int MiniPS::Tokenizer::yylex() {
  int c=0; /* dummy initialization */
  bool hi;
  unsigned hv;
  slen_t nest, len;
  signed long l;
  double d;
  Real::metric_t metric;
  char saved;
  
  if (ungot==EOFF) return EOFF;
  if (ungot!=NO_UNGOT) { c=ungot; ungot=NO_UNGOT; goto again; }
 again_getcc:
  c=in.vi_getcc();
 again:
  switch (c) {
   case -1: eof:
    return ungot=EOFF;
   case '\n': case '\r': case '\t': case ' ': case '\f': case '\0':
    goto again_getcc;
   case '%': /* one-line comment */
    while ((c=in.vi_getcc())!='\n' && c!='\r' && c!=-1) ;
    if (c==-1) goto eof;
    goto again_getcc;
   case '{': case '[':
    return '[';
   case '}': case ']':
    return ']';
   case ')': goto err;
   case '>':
    if (in.vi_getcc()!='>') goto err;
    return '>';
   case '<':
    if ((c=in.vi_getcc())==-1) { uf_hex: Error::sev(Error::EERROR) << "miniPS: unfinished hexstr" << (Error*)0; }
    if (c=='<') return '<';
    if (c=='~') Error::sev(Error::EERROR) << "miniPS: a85str unsupported" << (Error*)0;
    tv.bb=&b; b.clear();
    hi=true;
    while (c!='>') {
      if ((hv=b.hexc2n(c))!=16) {
        if (hi) { b << (char)(hv<<4); hi=false; }
           else { b.end_()[-1]|=hv; hi=true; }
      } else if (!is_ps_white(c)) Error::sev(Error::EERROR) << "miniPS: syntax error in hexstr" << (Error*)0;
      if ((c=in.vi_getcc())==-1) goto uf_hex;
    }
    /* This is correct even if an odd number of hex digits have arrived */
    return '(';
   case '(':
    tv.bb=&b; b.clear();
    nest=1;
    while ((c=in.vi_getcc())!=-1) { redo:
      if (c==')' && --nest==0) return '(';
      if (c!='\\') { if (c=='(') nest++; b << (char)c; continue; }
      /* read a backslash */
      switch (c=in.vi_getcc()) {
       case -1: goto uf_str;
       case 'n': b << '\n'; break;
       case 'r': b << '\r'; break;
       case 't': b << '\t'; break;
       case 'b': b << '\010'; break; /* \b and \a conflict between -ansi and -traditional */
       case 'f': b << '\f'; break;
       default:
        if (c<'0' || c>'7') { b << (char)c; break; }
        hv=c-'0'; /* read at most 3 octal chars */
        if ((c=in.vi_getcc())==-1) goto uf_str;
        if (c<'0' || c>'7') { b << (char)hv; goto redo; }
        hv=8*hv+(c-'0');
        if ((c=in.vi_getcc())==-1) goto uf_str;
        if (c<'0' || c>'7') { b << (char)hv; goto redo; }
        b << (char)(8*hv+(c-'0'));
      } /* SWITCH */
    } /* WHILE */    
    uf_str: Error::sev(Error::EERROR) << "miniPS: unfinished str" << (Error*)0;
   case '/':
    /* fall-through, b will begin with '/' */
   default: /* /nametype, /integertype or /realtype */
    tv.bb=&b; b.clear();
    b.clear(); b << (char)c;
    while ((c=in.vi_getcc())!=-1 && is_ps_name(c)) b << (char)c;
    ungot=c==-1?EOFF:c;
    if (b[0]=='/') return '/';
    b.term0();
    /* Dat: we don't support base-n number such as `16#100' == 256 in PostScript */
    if (!toInteger(b, l)) { tv.i=l; return '1'; }
    /* Dat: call toInteger _before_ toReal */
    // if (!toReal(b, tv.d)) { fprintf(stderr,"%f;\n", tv.d); }
    /* assert(tv.bb!=NULLP); */
    len=b.getLength();
    if (!toReal(b, d)) { /* tv.bb is also valid */
      tv.r=new Real(d, b(), len);
      return '.';
    } 
    if (len>2 && (metric=Real::str2metric(b()+len-2))!=Real::ME_COUNT) {
      saved=b[len-2];
      b[len-2]='\0';
      if (!toReal(b, d)) {
        tv.r=new Real(d, b(), len-2);
        tv.r->setMetric(metric);
        return ':'; /* Real with metric */
      }
      b[len-2]=saved;
    }
    return 'E'; /* /nametype */
  }
 err:
  Error::sev(Error::EERROR) << "miniPS: syntax error" << (Error*)0;
  goto again_getcc; /* notreached */
}
示例#13
0
文件: minips.cpp 项目: endriff/sam2p
bool MiniPS::Real::isDimen(char const *str) {
  double d;
  slen_t len=strlen(str);
  if (!toReal(str, len, d)) return true;
  return len>2 && str2metric(str+len-2)!=ME_COUNT && !toReal(str, len-2, d);
}
示例#14
0
void ValueSlider::
        sliderMoved(int v)
{
    value_ = toReal(v);
    emit valueChanged(value_);
}
示例#15
0
文件: vifann.cpp 项目: EQ4/Visore
void ViFann::run(const qreal *input, qreal *output, const int &iterations)
{
	toFloat(input, mInput, mInputCount);
	run(mInput, mOutput, iterations);
	toReal(mOutput, output, mOutputCount);
}
示例#16
0
qreal ValueSlider::
        maximum() const
{
    return toReal(slider_->maximum());
}
示例#17
0
文件: debug.c 项目: jamesbmoen/orson
void writingObject(refBuffer buffer, refObject object)
{ if (object == nil)
  { writeFormat(buffer, "[Nil]"); }
  else
  { switch (tag(object))
    { case cellTag:
      { writeFormat(buffer, "[Cell %X]", object);
        return; }
      case characterTag:
      { writeCharacter(buffer, toCharacter(object));
        return; }
      case evenBinderTag:
      { writeFormat(buffer, "[EvenBinder %X]", object);
        return; }
      case hookTag:
      { writeFormat(buffer, "?%s", hookTo(object));
        return; }
      case hunkTag:
      { writeFormat(buffer, "[Hunk %X]", object);
        return; }
      case integerTag:
      { writeFormat(buffer, "%i", toInteger(object));
        return; }
      case jokerTag:
      { writeFormat(buffer, "[%s]", jokerTo(object));
        return; }
      case leftBinderTag:
      { writeFormat(buffer, "[LeftBinder %X]", object);
        return; }
      case markedTag:
      { writeFormat(buffer, "[...]");
        return; }
      case matchTag:
      { writeFormat(buffer, "[Match %X]", object);
        return; }
      case nameTag:
      { writeVisibleName(buffer, object);
        return; }
      case pairTag:
      { refObject pairs = object;
        tag(object) = markedTag;
        writeChar(buffer, '(');
        writingObject(buffer, car(pairs));
        pairs = cdr(pairs);
        while (pairs != nil)
        { writeBlank(buffer);
          writingObject(buffer, car(pairs));
          pairs = cdr(pairs); }
        writeChar(buffer, ')');
        tag(object) = pairTag;
        return; }
      case realTag:
      { writeFormat(buffer, "%.17E", toReal(object));
        return; }
      case rightBinderTag:
      { writeFormat(buffer, "[RightBinder %X]", object);
        return; }
      case stringTag:
      { writeQuotedString(buffer, toRefString(object));
        return; }
      default:
      { writeFormat(buffer, "[Tag%i %X]", tag(object), object);
        return; }}}}
示例#18
0
文件: vifann.cpp 项目: EQ4/Visore
void ViFann::run(const qreal *input, qreal *output)
{
	toFloat(input, mInput, mInputCount);
	run(mInput, mOutput);
	toReal(mOutput, output, mOutputCount);
}
示例#19
0
/// Accessor functions
double c_exprconst::getReal()
{
	if(m_negative == true)
		return -toReal(&m_value);
	return toReal(&m_value);
}