/* compare Strings that contains floats */
static int CompareFloatString(const wxString& first,const wxString& second) {
	double dFirst;
	double dSecond;
	first.ToDouble(&dFirst);
	second.ToDouble(&dSecond);
	if(dFirst < dSecond) {
		return reverseCompareOrder ? 1 : -1 ;
	}
	if(dSecond < dFirst) {
		return reverseCompareOrder ? -1 : 1 ;
	}
	return 0;
}
/////////////////////////////////////////////////////////
// Resets a value with a string, preserving current type
void VariableData::ResetWith(wxString value) {
	switch (type) {
		case VARDATA_INT: {
			long temp = 0;
			value.ToLong(&temp);
			SetInt(temp);
			break;
		}
		case VARDATA_FLOAT: {
			double temp = 0;
			value.ToDouble(&temp);
			SetFloat(temp);
			break;
		}
		case VARDATA_BOOL:
			if (value == _T("1")) SetBool(true);
			else SetBool(false);
			break;
		case VARDATA_COLOUR: {
			long r=0,g=0,b=0;
			value.Mid(1,2).ToLong(&r,16);
			value.Mid(3,2).ToLong(&g,16);
			value.Mid(5,2).ToLong(&b,16);
			SetColour(wxColour(r,g,b));
			break;
		}
		default:
			SetText(value);
			break;
	}
}
예제 #3
0
void PluginPreference::SetValue(const wxString& value) {
  hasBeenSet_ = true;

  if (value_ == value) return;

  if (GetType() == PluginPreferenceType::Spinner) {

    double dValue;
    bool converted = value.ToDouble(&dValue);
    if (!converted) {
      ELOG(_T("PluginPreference: value is not a number"));
      return;
    }

    double fValue = (double)dValue;

    if (minValue_ != maxValue_) {
      if (fValue < minValue_ || fValue > maxValue_) {
        ELOG(wxString::Format(_T("PluginPreference: value of '%s' is not within correct range (%d, %d)."), GetName(), GetMinValue(), GetMaxValue()));
        return;
      }
    }

  }
    
  value_ = value;
  
  Invalidate();
}
예제 #4
0
////////////////////////////////////////////////////////////
// Class name:  MainFrame
// Method name: getDoubleValue
//
// Description: asdfadf
////////////////////////////////////////////////////////////
double MainFrame::getDoubleValue(wxString p_str)
{
	double value;
	
	if (!p_str.IsEmpty())
	{
		// if cannot convert
		if (!p_str.ToDouble(&value))
		{
			// if not a valid number, show error.
        	wxMessageBox(
            	wxT("Not a valid double value."),
           		wxT("Value error."),
            	wxOK|wxICON_EXCLAMATION,
            	this
        	);
		}
	}
	else
	{
		value = -1;
	}
	
	// return double value
	return value;
}
예제 #5
0
void wxGridCellFloatEditor::BeginEdit(int row, int col, wxGrid* grid)
{
    // first get the value
    wxGridTableBase * const table = grid->GetTable();
    if ( table->CanGetValueAs(row, col, wxGRID_VALUE_FLOAT) )
    {
        m_value = table->GetValueAsDouble(row, col);
    }
    else
    {
        m_value = 0.0;

        const wxString value = table->GetValue(row, col);
        if ( !value.empty() )
        {
            if ( !value.ToDouble(&m_value) )
            {
                wxFAIL_MSG( wxT("this cell doesn't have float value") );
                return;
            }
        }
    }

    DoBeginEdit(GetString());
}
예제 #6
0
 static int Time2Frame(const wxString& timestr, int round)
 {
     double timeval;
     int msec;
     
     msec = timestr.ToDouble(&timeval)? (int)(timeval * 1000): 0;
     return (round > 0)? (msec + 49)/ 50: (round < 0)? msec / 50: (msec + 25)/ 50; //round up/down/closest
 }
int StrToInt1Units( wxString aStr )
{
    double num, precision = 10;

    // TODO: Is the following commented string necessary?
    // if (pos(',',s)>0) then DecimalSeparator:=',' else DecimalSeparator:='.';
    aStr.ToDouble( &num );
    return KiROUND( num * precision );
}
예제 #8
0
double xsDoublePropIO::FromString(const wxString& value)
{
	double num = 0;
	if(!value.IsEmpty())
	{
		value.ToDouble(&num);
	}
	return num;
}
예제 #9
0
float xsFloatPropIO::FromString(const wxString& value)
{
	double num = 0;
	if(!value.IsEmpty())
	{
		value.ToDouble(&num);
	}
	return (float)num;
}
예제 #10
0
bool wxSVGFEGaussianBlurElement::SetCustomAttribute(const wxString& name, const wxString& value) {
	double dvalue;
	if (name == wxT("stdDeviation") && value.ToDouble(&dvalue)) {
		m_stdDeviationX.SetBaseVal(dvalue);
		m_stdDeviationY.SetBaseVal(dvalue);
		return true;
	}
	return false;
}
void SpinControl::SetValue(const wxString& textValue) {
    double doubleValue;
    if (textValue.ToDouble(&doubleValue) && InRange(doubleValue)) {
        DoSetValue(doubleValue);
    } else {
        m_text->SetValue(textValue);
        m_text->SetSelection(0, -1);
        m_text->SetInsertionPointEnd();
    }
}
void INCREMENTAL_TEXT_CTRL::incrementCtrlBy( double aInc )
{
    const wxString txt = getCtrlText();
    if( !validateFloatField( txt ) )
        return;

    txt.ToDouble( &m_currentValue );
    m_currentValue += aInc;

    updateTextValue();
}
static double ParseLatLon(wxString s)
{
    if(s.empty())
        return NAN;

    wxChar ns = s.Last();
    int sign = (ns == 'S' || ns == 'W') ? -1 : 1;
    double d;
    s.ToDouble(&d);
    return sign * d;
}
예제 #14
0
/* checks if the value contains a valid float */
bool CDlgAdvPreferences::IsValidFloatValue(const wxString& value) {
    for(unsigned int i=0; i < value.Length();i++) {
        if(!IsValidFloatChar(value[i])) {
            return false;
        }
    }
    //all chars are valid, now what is with the value as a whole ?
    double td;
    if(!value.ToDouble(&td)) {
        return false;
    }
    return true;
}
예제 #15
0
bool CDlgAdvPreferences::IsValidFloatValueBetween(const wxString& value, double minVal, double maxVal){
    for(unsigned int i=0; i < value.Length();i++) {
        if(!IsValidFloatChar(value[i])) {
            return false;
        }
    }
    //all chars are valid, now what is with the value as a whole ?
    double td;
    if(!value.ToDouble(&td)) {
        return false;
    }
    if ((td < minVal) || (td > maxVal)) return false;
    return true;
}
예제 #16
0
void PropGrid::setCellValueWithEvt(int row,int col,const wxString& val)
{
	wxDouble dummy;
	long dummyL;
	wxString cellDataType=this->GetTable()->GetTypeName(row,col);
	if(cellDataType==wxGRID_VALUE_STRING
		|| (val.ToLong(&dummyL) && cellDataType==wxGRID_VALUE_NUMBER)
		|| (val.ToDouble(&dummy) && cellDataType==wxGRID_VALUE_FLOAT)
		)
	{
		this->SetCellValue(row,col,val);
		wxGridEvent customGreedEvent(1,wxEVT_GRID_CELL_CHANGE,this,row,col);
		GetEventHandler()->ProcessEvent( customGreedEvent );
	}
}
예제 #17
0
bool Styles::IsSkinVersionCompatible(const wxString& skinVersion) {
  double dSkinVersion;
  skinVersion.ToDouble(&dSkinVersion);
  
  double dThisVersion;
  wxString fullVersion = VersionInfo::GetVersionString();
  wxArrayString splitted;
  StringUtil::Split(fullVersion, splitted, _T("."));
  wxString tdVersion = splitted[0] + _T(".") + splitted[1];
  tdVersion.ToDouble(&dThisVersion);

  if (dSkinVersion < 1.3 && dThisVersion >= 1.3) return false;

  return true;
}
예제 #18
0
void tcNumberEditControl::SetValue(const wxString& s)
{
    double x = 0; 
    wxString convertedValue = "";
    if (s.ToDouble(&x))
    {
        x *= databaseToDisplay;
        convertedValue.Printf(formatString.c_str(), x);
    }

    tcEditControl::SetValue(convertedValue);

    textCtrl->SetLabel(editValue);

    IndicateChanges();

    CheckReferences();
}
예제 #19
0
bool wxNumberFormatter::FromString(wxString s, double *val)
{
    RemoveThousandsSeparators(s);
    return s.ToDouble(val);
}
void DoubleParameter::SetMin(const wxString &min)
{
    min.ToDouble(&m_Min);
}
void DoubleParameter::SetMax(const wxString &max)
{
    max.ToDouble(&m_Max);
}
예제 #22
0
파일: Util.cpp 프로젝트: p1r4nh4/CellTrack
double wxStringToDouble( const wxString& s )
{
	double val;
	s.ToDouble(&val);
	return val;
}
예제 #23
0
NumeroComp interprete::StringAComp(wxString poli)//Pasar a hugomat?
{
    usi primera=0,segunda=0,tercera=0;
    double resulVariable1=1,resulVariable2=1,resulVariable3=1,resulNum=1;
    double *resulNumero=&resulNum,*exponente1=&resulVariable1,*exponente2=&resulVariable2;
    double *exponente3=&resulVariable3;
    char variables[3]={'a','a','a'};
    NumeroReal resulPar,tempo,tempo1,tempo2,tempo3;
    NumeroComp resulPar2,numeroExpoVarC;
    NumeroComp resultado;
    wxString Numero,ex1,ex2,ex3;
    if(poli.Find('x')!=-1||poli.Find('X')!=-1)
    {
        variables[0]='x';
        //		variablesP++;
    }
    if(poli.Find('y')!=-1||poli.Find('Y')!=-1)
    {
        variables[1]='y';
        //variablesP++;
    }
    if(poli.Find('z')!=-1||poli.Find('Z')!=-1)
    {
        variables[2]='z';
        //variablesP++;
    }
    if(variables[0]=='a'&&variables[1]=='a'&&variables[2]=='a')
    {
        poli.ToDouble(resulNumero);
    }
    else
    {
        if(variables[0]!='a')
        {
            primera=poli.Find('x');
            Numero=poli.Mid(0,primera);
            if(Numero.IsNumber())
            {
                Numero.ToDouble(resulNumero);
            }
        }
        primera=primera+1;
        if(variables[1]=='a'||variables[2]=='a')
        {
            ex1=poli.Mid(primera,poli.length());
	    if(ex1.Find(')')!=-1)
	    {
		ex1=ex1.BeforeFirst(')');
	    }
	    else if(ex1.Find('}')!=-1)
	    {
		ex1=ex1.BeforeFirst('}');
	    }
            if(ex1.IsNumber())
            {
                ex1.ToDouble(exponente1);
            }
        }
        if(variables[1]!='a')
        {
            segunda=poli.Find('y');
            ex1=poli.Mid(primera,segunda);
            ex1=ex1.BeforeFirst('y');
            if(ex1.IsNumber())
            {
                ex1.ToDouble(exponente1);
            }
        }
        segunda++;
        if(variables[2]!='a')
        {
            tercera=poli.Find('z');
            ex2=poli.Mid(segunda,tercera);
            ex2=ex2.BeforeFirst('z');
            //ex2=poli.Mid(segunda,tercera-6);
            if(ex2.IsNumber())
            {
                ex2.ToDouble(exponente2);
            }
            ex3=poli.AfterLast('z');
        }
        if(ex3.IsNumber())
        {
            ex3.ToDouble(exponente3);
        }
        if(resulVariable1!=0)
        {
            tempo1.CambiarNumerador((int)resulVariable1);
        }
        if(resulVariable2!=0)
        {
            tempo2.CambiarNumerador((int)resulVariable2);
        }
        if(resulVariable3!=0)
        {
            tempo3.CambiarNumerador((int)resulVariable3);
        }
    }
    /////////////////////
    resulPar.CambiarNumerador((int)resulNum);
    resulPar2.CambiarNumero(resulPar);
    resulPar2.CambiarVariable1(variables[0]);
    resulPar2.CambiarVariable2(variables[1]);
    resulPar2.CambiarVariable3(variables[2]);
    resulPar2.CambiarExponenteVariable1(tempo1);
    resulPar2.CambiarExponenteVariable2(tempo2);
    resulPar2.CambiarExponenteVariable3(tempo3);
    resultado=resulPar2;
    return resultado;
}
예제 #24
0
bool CVSCPVariable::setValueFromString( int type, const wxString& strValue )
{	
    // Convert to uppercase
    wxString strUpper;

    switch ( type ) { 

        case VSCP_DAEMON_VARIABLE_CODE_STRING:
            m_strValue = strValue;
            break;

        case VSCP_DAEMON_VARIABLE_CODE_BOOLEAN:
            {
                strUpper = strValue.Upper();
                if ( wxNOT_FOUND != strUpper.Find( _("TRUE") ) ) {
                    m_boolValue = true;
                }
                else {
                    m_boolValue = false;
                }
            }
            break;

        case VSCP_DAEMON_VARIABLE_CODE_INTEGER:
            m_longValue = readStringValue( strValue );
            break;
            
        case VSCP_DAEMON_VARIABLE_CODE_LONG:
            m_longValue = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_DOUBLE:
            strValue.ToDouble( &m_floatValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_MEASUREMENT:
            {
                uint8_t data[ VSCP_MAX_DATA ];
                uint16_t sizeData = 0;
                getVscpDataArrayFromString( data, &sizeData, strValue );
                if ( sizeData > 8 ) sizeData = 8;
                if (sizeData) memcpy( m_normInteger, data, sizeData );
                m_normIntSize = sizeData;
            }
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT:
            getVscpEventFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_GUID:
            getGuidFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_DATA:
            getVscpDataFromString( &m_event, strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_CLASS:
            m_event.vscp_class = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_TYPE:
            m_event.vscp_type = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_VSCP_EVENT_TIMESTAMP:
            m_event.timestamp = readStringValue( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_DATETIME:
            m_timestamp.ParseDateTime( strValue );
            break;

        case VSCP_DAEMON_VARIABLE_CODE_UNASSIGNED:
            
            // Fall through - Not allowed here

        default:
            return false;

    }

    return true;

}
void DoubleParameter::SetStep(const wxString &step)
{
    step.ToDouble(&m_Step);
}
예제 #26
0
파일: ys_calc.cpp 프로젝트: mentat/YardSale
double YardCalc::StringToDouble(wxString str){
	double  tempvalue;
	str.ToDouble(&tempvalue);
	return tempvalue;
}
예제 #27
0
/*---------------------------------------------------------------------------*/
void wxGridColumnsTable::SetValue(int row, int col, const wxString& value)
{
   if (col == 0)
   {
      if (CheckName(value, row))
         m_Columns[row]->SetName(value.Upper());
   }
   else if (col == 1)
   {
      if (value == ("INTEGER"))
      {
         long l_Long;
         wxString val;

         m_Columns[row]->SetType(cttInteger);
         val = m_Columns[row]->GetDefault();
         if ((val != wxEmptyString) && !val.ToLong(&l_Long))
            SetValue(row, 4, wxEmptyString);
      }
      else if (value == ("INTEGER AUTOINCREMENT"))
      {
         if (CheckAutoInc())
            return;
         m_Columns[row]->SetType(cttIntegerAutoinc);
         SetValueAsBool(row, 3, true);
         SetValue(row, 4, wxEmptyString);
         // Oblige la grille à prendre en compte le changement
         GetView()->SetCellValue(row, 3, ("1"));
      }
      else if (value == ("REAL"))
      {
         double l_Double;
         wxString val;

         m_Columns[row]->SetType(cttReal);
         val = m_Columns[row]->GetDefault();
         if ((val != wxEmptyString) && !val.ToDouble(&l_Double))
            SetValue(row, 4, wxEmptyString);
      }
      else if (value == ("TEXT"))
         m_Columns[row]->SetType(cttText);
      else if (value == ("BLOB"))
         m_Columns[row]->SetType(cttBlob);
   }
   else if (col == 4)
   {
      if (value != wxEmptyString)
      {
         long l_Long;
         double l_Double;

         switch (m_Columns[row]->GetType())
         {
            case cttInteger :
               if (value.ToLong(&l_Long))
                  m_Columns[row]->SetDefault(wxString::Format(("%li"), l_Long));
               break;
            case cttIntegerAutoinc : return;
            case cttReal :
               if (value.ToDouble(&l_Double))
                  m_Columns[row]->SetDefault(wxString::Format(("%f"), l_Double));
               break;
            case cttText :
            case cttBlob :
               if ((value.Upper() == ("CURRENT_TIME"))||
                  (value.Upper() == ("CURRENT_DATE"))||
                  (value.Upper() == ("CURRENT_TIMESTAMP")))
                  m_Columns[row]->SetDefault(value.Upper());
               else
                  m_Columns[row]->SetDefault(value);
         }
      }
      else
         m_Columns[row]->SetDefault(wxEmptyString);
   }
}
void DoubleParameter::SetValue(const wxString& value)
{
    double temp;
    if (value.ToDouble(&temp))
        SetValue(temp);
}