Ejemplo n.º 1
0
 bool MutableMessage::addDataField(const char *field, const char *value) {
     DataField *e = createDataField(m_field_allocator, strlen(value) + 1, field, value);
     auto result = m_keys.insert(std::make_pair(e->identifier(), m_payload.size()));
     if (result.second) {
         m_payload.emplace_back(e);
     } else {
         destroyField(m_field_allocator, e);
     }
     return result.second;
 }
Ejemplo n.º 2
0
BOOL dlgKeyboard(WndProperty* theProperty){
	DataField* pField = theProperty->GetDataField();
	if(pField) {
		if(pField->CreateKeyboard()){
			theProperty->RefreshDisplay();
			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 3
0
int main(int argc, char**argv)
{
    Init();
    
    data_field.Load(argv[1]);
    data_field.Adjust();
//    data_field.LoadTestData();
    data_field.Show();

//    data_field.IDW(2);
    
//    data_field.Show();
//
//    int current = 0;
//    namedWindow( "Display window", WINDOW_NORMAL );
//    imshow( "Display window", data_field.slices[current]->Matrix2Image());
//    
//    
//    
//
//    char c;
//    while(1)
//    {
//        c = waitKey(0);
//        cout<<c<<endl;
//        if (c == 'f')
//            current++;
//        if (c == 'b')
//            current--;
//        cout<<"current: "<<current<<endl;
//        imshow( "Display window", data_field.slices[current]->Matrix2Image());
//    }
//
   
//    while (true){
        int height,width,distance;
        cout<<"please input height , width , distance"<<endl;
        cin>>height>>width>>distance;
        cout<<"please input angel x, y, z"<<endl;
        double ang_x,ang_y,ang_z;
        cin>>ang_x>>ang_y>>ang_z;
    
        //弧度制,毫米
        clock_t start,finish;
        double totaltime;
        start=clock();
        RayCast(rate(ang_x),rate(ang_y),rate(ang_z),height,width,distance);
        finish=clock();
        totaltime=(double)(finish-start)/CLOCKS_PER_SEC;
        cout<<"Time consumed: "<<totaltime<<"s"<<endl;
//    }
    
    return 0;
}
Ejemplo n.º 4
0
static void
SetDataAccessCallback(SubForm &form, const TCHAR *name,
                      DataField::DataAccessCallback cb)
{
  WndProperty *edit = (WndProperty *)form.FindByName(name);
  assert(edit != nullptr);

  DataField *df = edit->GetDataField();
  assert(df != nullptr);
  df->SetDataAccessCallback(cb);
}
Ejemplo n.º 5
0
void
FilterDataFieldListener::OnModified(DataField &df)
{
  if (&df == distance_filter->GetDataField())
    dialog_state.distance_index = df.GetAsInteger();
  else if (&df == direction_filter->GetDataField())
    dialog_state.direction_index = df.GetAsInteger();
  else if (&df == type_filter->GetDataField())
    dialog_state.type_index = (TypeFilter)df.GetAsInteger();

  UpdateList();
}
Ejemplo n.º 6
0
void
RouteConfigPanel::OnModified(DataField &df)
{
  if (IsDataField(RoutePlannerMode, df)) {
    RoutePlannerConfig::Mode mode =
      (RoutePlannerConfig::Mode)df.GetAsInteger();
    ShowRouteControls(mode != RoutePlannerConfig::Mode::NONE);
  } else if (IsDataField(TurningReach, df)) {
    RoutePlannerConfig::ReachMode mode =
      (RoutePlannerConfig::ReachMode)df.GetAsInteger();
    ShowReachControls(mode != RoutePlannerConfig::ReachMode::OFF);
  }
}
Ejemplo n.º 7
0
BOOL dlgKeyboard(WndProperty* theProperty){
    BOOL Ret = FALSE;

    wKeyboardPopupWndProperty = theProperty;
	DataField* pField = theProperty->GetDataField();
	if(pField) {
		if(pField->CreateKeyboard()){
			theProperty->RefreshDisplay();
			Ret = TRUE;
		}
	}
    wKeyboardPopupWndProperty = nullptr;

	return Ret;
}
Ejemplo n.º 8
0
static void UpdateTextboxProp(void)
{

  WndProperty *wp;
  wp = (WndProperty*)wf->FindByName(TEXT("prpText"));
  if (wp) {
    wp->SetText(edittext);

    if(WaypointKeyRed)
      wp->SetCaption(MsgToken(949));
    else
      wp->SetCaption(TEXT("Text"));
  }


  wp = (WndProperty*)wf->FindByName(TEXT("prpUnit"));
  if(wp && wKeyboardPopupWndProperty) {
      DataField* pField = wKeyboardPopupWndProperty->GetDataField();
      if(pField) {
        wp->SetCaption(pField->GetUnits());
        wp->RefreshDisplay();
        wp->Redraw();
      }
  }


  {
    WndButton *wb;
    if(WaypointKeyRed)
    {
      ReduceKeysByWaypointList();

	  wb =  (WndButton*) wf->FindByName(TEXT("prpDate")); if(wb != NULL) wb->SetVisible(false);
	  wb =  (WndButton*) wf->FindByName(TEXT("prpTime")); if(wb != NULL) wb->SetVisible(false);
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpMatch"));; if(wp != NULL) wp->SetVisible(WaypointKeyRed);
/*
    CharUpper(szLanguageFile);
    BOOL bGerChar = false;
    if( _tcscmp(szLanguageFile,_T("GERMAN.LNG"))==0)
	  bGerChar = true;

    wb = (WndButton*) wf->FindByName(TEXT("prpAe")); if(wb != NULL) wb->SetVisible(bGerChar);
    wb = (WndButton*) wf->FindByName(TEXT("prpOe")); if(wb != NULL) wb->SetVisible(bGerChar);
    wb = (WndButton*) wf->FindByName(TEXT("prpUe")); if(wb != NULL) wb->SetVisible(bGerChar);
*/
  }
}
Ejemplo n.º 9
0
void
LoadFormProperty(WndForm &form, const TCHAR *control_name,
                 UnitGroup_t unit_group, int value)
{
  assert(control_name != NULL);

  WndProperty *ctl = (WndProperty *)form.FindByName(control_name);
  if (ctl == NULL)
    return;

  Units_t unit = Units::GetUserUnitByGroup(unit_group);
  DataField *df = ctl->GetDataField();
  df->SetUnits(Units::GetUnitName(unit));
  df->SetAsInteger(iround(Units::ToUserUnit(fixed(value), unit)));
  ctl->RefreshDisplay();
}
Ejemplo n.º 10
0
void
WaypointListWidget::OnModified(DataField &df)
{
  if (filter_widget.IsDataField(NAME, df)) {
    dialog_state.name = df.GetAsString();

    /* pass the focus to the list so the user can use the up/down keys
       to select an item right away after the text input dialog has
       been closed; however if the value was changed by
       incrementing/decrementing the first letter (cursor left/right),
       don't move the focus; we don't know for sure how the value was
       changed, but if the filter has only one letter, it's most
       likely changed by left/right */
    if (dialog_state.name.length() > 1)
      GetList().SetFocus();
  } else if (filter_widget.IsDataField(DISTANCE, df)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    dialog_state.distance_index = dfe.GetValue();
  } else if (filter_widget.IsDataField(DIRECTION, df)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    dialog_state.direction_index = dfe.GetValue();
  } else if (filter_widget.IsDataField(TYPE, df)) {
    const DataFieldEnum &dfe = (const DataFieldEnum &)df;
    dialog_state.type_index = (TypeFilter)dfe.GetValue();
  }

  UpdateList();
}
Ejemplo n.º 11
0
void
SymbolsConfigPanel::OnModified(DataField &df)
{
  if (IsDataField(Trail, df)) {
    TrailSettings::Length trail_length = (TrailSettings::Length)df.GetAsInteger();
    ShowTrailControls(trail_length != TrailSettings::Length::OFF);
  }
}
Ejemplo n.º 12
0
static void UpdateTextboxProp(void)
{
  WndProperty *wp;
  wp = (WndProperty*)wf->FindByName(TEXT("prpText"));
  if (wp) {
    wp->SetText(edittext);
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpUnit"));
  if(wp && wKeyboardPopupWndProperty) {
      DataField* pField = wKeyboardPopupWndProperty->GetDataField();
      if(pField) {
        wp->SetCaption(pField->GetUnits());
        wp->RefreshDisplay();
        wp->Redraw();
      }
  }
}
Ejemplo n.º 13
0
void
AirspaceFilterListener::OnModified(DataField &df)
{
  if (&df == distance_control->GetDataField())
    dialog_state.distance = (unsigned)df.GetAsInteger() != WILDCARD
      ? Units::ToSysDistance(fixed(df.GetAsInteger()))
      : fixed(-1);

  else if (&df == direction_control->GetDataField())
    dialog_state.direction = df.GetAsInteger();

  else if (&df == type_control->GetDataField())
    dialog_state.type = df.GetAsInteger();

  FilterMode(&df == name_control->GetDataField());
  UpdateList();
}
Ejemplo n.º 14
0
gcc_pure
static DeviceConfig::PortType
GetPortType(DataField &df)
{
  unsigned port = df.GetAsInteger();

  if (port < num_port_types)
    return port_types[port].type;

  return (DeviceConfig::PortType)(port >> 16);
}
Ejemplo n.º 15
0
void init_AdditionFilter(char* i_filterName,
		long int i_size,
		double i_a, double i_b,
		char* i_inName1, double* i_in1,
		char* i_inName2, double* i_in2,
		char* i_outName, double* o_out){
	string filterNameToMap = string(i_filterName);
	string inName1 = string(i_inName1);
	string inName2 = string(i_inName2);
	string outName = string(i_outName);

	assert(i_in1 != NULL);
	assert(i_in2 != NULL);
	assert(o_out != NULL);

	if( filterList.count(filterNameToMap) ){
        ERROR_OUT("FilterLib: A filter with name : " + filterNameToMap + "has already been initialized!");
        exit(EXIT_FAILURE);
	}
	else{
		/// Create DataFields objects and initialize them
		DataField* inData1 = new DataField(inName1, i_size);
		inData1->setSize(i_size);
		inData1->setData(i_in1);

		DataField* inData2 = new DataField(inName2, i_size);
		inData2->setSize(i_size);
		inData2->setData(i_in2);

		DataField* outData = new DataField(outName, i_size);
		outData->setSize(i_size);
		outData->setData(o_out);

		/// Initialize filter
		filterList[filterNameToMap] = new AdditionFilter(i_a, i_b);
		filterList[filterNameToMap]->addInput(inData1);
		filterList[filterNameToMap]->addInput(inData2);
		filterList[filterNameToMap]->addOutput(outData);
		filterList[filterNameToMap]->init();
	}
}
Ejemplo n.º 16
0
bool
EditDataFieldDialog(const TCHAR *caption, DataField &df,
                    const TCHAR *help_text)
{
  if (df.supports_combolist) {
    ComboPicker(caption, df, help_text);
    return true;
  } else if (df.GetType() == DataField::Type::ROUGH_TIME) {
    RoughTimeDataField &tdf = (RoughTimeDataField &)df;
    RoughTime value = tdf.GetValue();
    if (!TimeEntryDialog(caption, value, tdf.GetTimeZone(), true))
      return true;

    tdf.ModifyValue(value);
    return true;
  } else if (df.GetType() == DataField::Type::GEOPOINT) {
    GeoPointDataField &gdf = (GeoPointDataField &)df;
    GeoPoint value = gdf.GetValue();
    if (!GeoPointEntryDialog(caption, value, false))
      return true;

    gdf.ModifyValue(value);
    return true;
  } else {
    const TCHAR *value = df.GetAsString();
    if (value == NULL)
      return false;

    StaticString<EDITSTRINGSIZE> buffer(value);

    PrefixDataField::AllowedCharactersFunction acf;
    if (df.GetType() == DataField::Type::PREFIX)
      acf = ((PrefixDataField &)df).GetAllowedCharactersFunction();

    if (!TextEntryDialog(buffer, caption, acf))
      return true;

    df.SetAsString(buffer);
    return true;
  }
}
Ejemplo n.º 17
0
void init_WeakCouplingFilter(char* i_filterName, int i_beta,
		long int i_size,
		char* i_inName, double* i_in,
		char* i_outName, double* o_out){
	string filterNameToMap = string(i_filterName);
	string inName = string(i_inName);
	string outName = string(i_outName);

	assert(i_in != NULL);
	assert(o_out != NULL);

	if( filterList.count(filterNameToMap) ){
	    ERROR_OUT("FilterLib: A filterer with name : " + filterNameToMap + "has already been initialized!");
	    exit(EXIT_FAILURE);
		}
	else{
		/// Create and initialize DataField objects
		DataField* inData = new DataField(inName, i_size);
		inData->setSize(i_size);
		inData->setData(i_in);

		DataField* outData = new DataField(outName,i_size);
		outData->setSize(i_size);
		outData->setData(o_out);

		/// Assign to filter and the initialize the filter
		filterList[filterNameToMap] = new WeakCouplingFilter(i_beta);
		filterList[filterNameToMap]->addInput(inData);
		filterList[filterNameToMap]->addOutput(outData);
		filterList[filterNameToMap]->init();
	}
}
Ejemplo n.º 18
0
gcc_pure
static bool
CanPassThrough(const DataField &df)
{
  const TCHAR *driver_name = df.GetAsString();
  if (driver_name == nullptr)
    return false;

  const struct DeviceRegister *driver = FindDriverByName(driver_name);
  if (driver == nullptr)
    return false;

  return driver->HasPassThrough();
}
Ejemplo n.º 19
0
gcc_pure
static bool
CanSendSettings(const DataField &df)
{
  const TCHAR *driver_name = df.GetAsString();
  if (driver_name == NULL)
    return false;

  const struct DeviceRegister *driver = FindDriverByName(driver_name);
  if (driver == NULL)
    return false;

  return driver->CanSendSettings();
}
Ejemplo n.º 20
0
gcc_pure
static bool
SupportsBulkBaudRate(const DataField &df)
{
  const TCHAR *driver_name = df.GetAsString();
  if (driver_name == NULL)
    return false;

  const struct DeviceRegister *driver = FindDriverByName(driver_name);
  if (driver == NULL)
    return false;

  return driver->SupportsBulkBaudRate();
}
Ejemplo n.º 21
0
int Item::indexOf(const DataField &field) const
{
    return indexOf(field.getFieldName());
}
Ejemplo n.º 22
0
static void setVariables(void) {
  WndProperty *wp;

  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu1"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu1);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu2"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu2);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu3"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu3);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu4"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu4);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu5"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu5);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu6"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu6);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu7"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu7);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu8"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu8);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu9"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu9);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu10"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	AddCustomKeyList(dfe); dfe->Set(CustomMenu10);
	wp->RefreshDisplay();
  }
}
Ejemplo n.º 23
0
result_t DataField::create(vector<string>::iterator& it,
		const vector<string>::iterator end,
		DataFieldTemplates* templates, DataField*& returnField,
		const bool isWriteMessage,
		const bool isTemplate, const bool isBroadcastOrMasterDestination,
		const unsigned char maxFieldLength)
{
	vector<SingleDataField*> fields;
	string firstName, firstComment;
	result_t result = RESULT_OK;
	if (it == end)
		return RESULT_ERR_EOF;

	while (it != end && result == RESULT_OK) {
		string unit, comment;
		PartType partType;
		int divisor = 0;
		bool hasPartStr = false;
		string token;

		// template: name,basetype[:len]|template[:name][,[divisor|values][,[unit][,[comment]]]]
		// std: name,part,basetype[:len]|template[:name][,[divisor|values][,[unit][,[comment]]]]
		const string name = *it++; // name
		if (it == end) {
			if (!name.empty())
				result = RESULT_ERR_MISSING_TYPE;
			break;
		}

		if (isTemplate) {
			partType = pt_any;
		} else {
			const char* partStr = (*it++).c_str(); // part
			hasPartStr = partStr[0] != 0;
			if (it == end) {
				if (!name.empty() || hasPartStr)
					result = RESULT_ERR_MISSING_TYPE;
				break;
			}
			if (isBroadcastOrMasterDestination
				|| (isWriteMessage && !hasPartStr)
				|| strcasecmp(partStr, "M") == 0) { // master data
				partType = pt_masterData;
			} else if ((!isWriteMessage && !hasPartStr)
				|| strcasecmp(partStr, "S") == 0) { // slave data
				partType = pt_slaveData;
			} else {
				result = RESULT_ERR_INVALID_PART;
				break;
			}
		}

		if (fields.empty()) {
			firstName = name;
			firstComment = comment;
		}

		const string typeStr = *it++; // basetype[:len]|template[:name]
		if (typeStr.empty()) {
			if (!name.empty() || hasPartStr) {
				result = RESULT_ERR_MISSING_TYPE;
			}
			break;
		}

		map<unsigned int, string> values;
		string constantValue;
		bool verifyValue = false;
		if (it != end) {
			const string divisorStr = *it++; // [divisor|values]
			if (!divisorStr.empty()) {
				size_t equalPos = divisorStr.find('=');
				if (equalPos == string::npos) {
					divisor = parseSignedInt(divisorStr.c_str(), 10, -MAX_DIVISOR, MAX_DIVISOR, result);
				} else if (equalPos == 0 && divisorStr.length() > 1) {
					verifyValue = divisorStr[1]=='='; // == forced verification of constant value
					if (verifyValue && divisorStr.length() == 1) {
						result = RESULT_ERR_INVALID_LIST;
						break;
					}
					constantValue = divisorStr.substr(equalPos+(verifyValue?2:1));
				} else {
					istringstream stream(divisorStr);
					while (getline(stream, token, VALUE_SEPARATOR)) {
						FileReader::trim(token);
						const char* str = token.c_str();
						char* strEnd = NULL;
						unsigned long int id;
						if (strncasecmp(str, "0x", 2) == 0) {
							str += 2;
							id = strtoul(str, &strEnd, 16); // hexadecimal
						} else {
							id = strtoul(str, &strEnd, 10); // decimal
						}
						if (strEnd == NULL || strEnd == str || id > MAX_VALUE) {
							result = RESULT_ERR_INVALID_LIST;
							break;
						}
						// remove blanks around '=' sign
						while (*strEnd == ' ') strEnd++;
						if (*strEnd != '=') {
							result = RESULT_ERR_INVALID_LIST;
							break;
						}
						token = string(strEnd + 1);
						FileReader::trim(token);
						values[(unsigned int)id] = token;
					}
				}
				if (result != RESULT_OK) {
					break;
				}
			}
		}

		if (it == end) {
			unit = "";
		} else {
			const string str = *it++; // [unit]
			if (strcasecmp(str.c_str(), NULL_VALUE) == 0) {
				unit = "";
			} else {
				unit = str;
			}
		}

		if (it == end) {
			comment = "";
		} else {
			const string str = *it++; // [comment]
			if (strcasecmp(str.c_str(), NULL_VALUE) == 0) {
				comment = "";
			} else {
				comment = str;
			}
		}

		bool firstType = true;
		istringstream stream(typeStr);
		while (result == RESULT_OK && getline(stream, token, VALUE_SEPARATOR)) {
			FileReader::trim(token);
			DataField* templ = templates->get(token);
			size_t pos = token.find(LENGTH_SEPARATOR);
			if (templ == NULL && pos != string::npos) {
				templ = templates->get(token.substr(0, pos));
			}
			if (templ == NULL) { // basetype[:len]
				unsigned char length;
				string typeName;
				if (pos == string::npos) {
					length = 0; // no length specified
					typeName = token;
				} else {
					if (pos+2==token.length() && token[pos+1]=='*') {
						length = REMAIN_LEN;
					} else {
						length = (unsigned char)parseInt(token.substr(pos+1).c_str(), 10, 1, maxFieldLength, result);
						if (result != RESULT_OK) {
							break;
						}
					}
					typeName = token.substr(0, pos);
				}
				transform(typeName.begin(), typeName.end(), typeName.begin(), ::toupper);
				SingleDataField* add = NULL;
				result = SingleDataField::create(typeName, length, firstType ? name : "", firstType ? comment : "", firstType ? unit : "", partType, divisor, values, constantValue, verifyValue, add);
				if (add != NULL) {
					fields.push_back(add);
				} else if (result == RESULT_OK) {
					result = RESULT_ERR_NOTFOUND; // type not found
				}
			} else if (!constantValue.empty()) {
				result = RESULT_ERR_INVALID_ARG; // invalid value list
			} else { // template[:name]
				string fieldName;
				bool lastType = stream.eof();
				if (pos != string::npos) { // replacement name specified
					fieldName = token.substr(pos+1);
				} else {
					fieldName = (firstType && lastType) ? name : "";
				}
				result = templ->derive(fieldName, firstType ? comment : "", firstType ? unit : "", partType, divisor, values, fields);
			}
			firstType = false;
		}
	}

	if (result != RESULT_OK) {
		while (!fields.empty()) { // cleanup already created fields
			delete fields.back();
			fields.pop_back();
		}
		return result;
	}

	if (fields.size() == 1) {
		returnField = fields[0];
	} else {
		returnField = new DataFieldSet(firstName, firstComment, fields);
	}
	return RESULT_OK;
}
Ejemplo n.º 24
0
static void OnResetClicked(WndButton* pWnd){

  WndProperty *wp;
  extern void Reset_CustomMenu(void);
  Reset_CustomMenu();

  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu1"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu1);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu2"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu2);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu3"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu3);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu4"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu4);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu5"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu5);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu6"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu6);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu7"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu7);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu8"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu8);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu9"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu9);
	wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpCustomMenu10"));
  if (wp) {
	DataField* dfe = wp->GetDataField();
	dfe->Set(CustomMenu10);
	wp->RefreshDisplay();
  }

}
Ejemplo n.º 25
0
 void FillProperty(CHardwareParameters::value_type& Val) {
     if(!wfDlg) return;
     CHardwareParameter& Param = Val.second;
     
     WndProperty* pWnd = (WndProperty*)wfDlg->FindByName(Param.Code().c_str());
     if(pWnd) {
         DataField* pData = pWnd->GetDataField();
         if(pData) {
             AssocFieldParam[pData] = Param.Code();
             switch(Param.Type()) {
                 case TYPE_BOOLEAN:
                     pData->Set(Param.ValueBool());
                     break;
                 case TYPE_DOUBLE:
                     pData->SetMax((double)Param.Max());
                     pData->SetMin((double)Param.Min());
                     pData->Set(Param.ValueDouble());
                     break;
                 case TYPE_INT:
                 case TYPE_INTOFFSET:
                     pData->SetMax((int)Param.Max());
                     pData->SetMin((int)Param.Min());
                     pData->Set(Param.ValueInt());
                     break;
                 case TYPE_INTLIST:
                     pData->SetMax((int)Param.Max());
                     pData->SetMin((int)Param.Min());
                     pData->Set(Param.ValueInt());
                     break;
             }
         }
         pWnd->RefreshDisplay();
     }
 }
Ejemplo n.º 26
0
static void setVariables(void) {
    WndProperty *wp;

    wp = (WndProperty*)wf->FindByName(TEXT("prpIP11"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP11);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP12"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP12);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP13"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP13);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP14"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP14);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP15"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP15);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP16"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP16);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP17"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP17);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP21"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP21);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP22"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP22);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP23"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP23);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP24"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP24);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP31"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP31);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP32"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP32);
        wp->RefreshDisplay();
    }
    wp = (WndProperty*)wf->FindByName(TEXT("prpIP33"));
    if (wp) {
        DataField* dfb = wp->GetDataField();
        dfb->Set(ConfIP33);
        wp->RefreshDisplay();
    }

}
Ejemplo n.º 27
0
bool Item::hasDataField(const DataField &field) const
{
    return hasDataField(field.getFieldName());
}
Ejemplo n.º 28
0
//GetGrayValue
//step: sample frequency
double GetGrayValue(Matrix coor_init, Matrix g, double step)
{
    double alpha_in = 0;
    double alpha = 0;
    double alpha_out = 0;
    double gray = 0;
    double gray_out = 0;
    Matrix coor;
    coor.Init(1,3);
    
    char main_direction;
    //judge the main dirction
    if (fabs(g.elmt[0][0]) > fabs(g.elmt[0][1]) && fabs(g.elmt[0][0]) > fabs(g.elmt[0][2]))
        main_direction = 'x';
    if (fabs(g.elmt[0][1]) > fabs(g.elmt[0][0]) && fabs(g.elmt[0][1]) > fabs(g.elmt[0][2]))
        main_direction = 'y';
    if (fabs(g.elmt[0][2]) > fabs(g.elmt[0][0]) && fabs(g.elmt[0][2]) > fabs(g.elmt[0][1]))
        main_direction = 'z';
    
//    cout<<"main_direction: "<<main_direction<<endl;
    
    int i = 0;
    while (true)
    {
        //calculate sample's coordinate
        coor.elmt[0][0] = coor_init.elmt[0][0]+i*step*g.elmt[0][0];
        coor.elmt[0][1] = coor_init.elmt[0][1]+i*step*g.elmt[0][1];
        coor.elmt[0][2] = coor_init.elmt[0][2]+i*step*g.elmt[0][2];
//        cout<<"sample "<<i<<": "<<coor.elmt[0][0]<<"    "<<coor.elmt[0][1]<<"   "<<coor.elmt[0][2]<<endl;
        i++;
        
        //GetSampleValue
        
        //loop control, if the coordiante is already outrange in the main direction, stop loop
        if (main_direction == 'x')
            if ((g.elmt[0][0] > 0 && coor.elmt[0][0] > data_field.limit[1][0]) || (g.elmt[0][0] < 0 && coor.elmt[0][0] < data_field.limit[0][0]))
                break;
        if (main_direction == 'y')
            if ((g.elmt[0][1] > 0 && coor.elmt[0][1] > data_field.limit[1][1]) || (g.elmt[0][1] < 0 && coor.elmt[0][1] < data_field.limit[0][1]))
                break;
        if (main_direction == 'z')
            if ((g.elmt[0][2] > 0 && coor.elmt[0][2] > data_field.limit[1][2]) || (g.elmt[0][2] < 0 && coor.elmt[0][2] < data_field.limit[0][2]))
                break;
        
        
        
        //judge while the pixel is in the datafield
        if (!data_field.Is_InField(coor))
            continue;
        
//        cout<<"sample "<<i<<": "<<coor.elmt[0][0]<<"    "<<coor.elmt[0][1]<<"   "<<coor.elmt[0][2]<<"   ";
        
        
//        gray = data_field.Linear_GetValue(coor);
        gray = data_field.IDW_GetValue(coor);
        
        
//        cout<<"in field,gray: "<<gray<<endl;
//        getchar();
//        //**************this is for test
//        if (gray)
//            return gray;
//        //**************this is for test

        
        //judge alpha according to the gray value
        //background
//        if (gray < 100)
//            continue;
        //else, linera relationship

//        if (gray < 107 || gray > 150)
//            continue;
        
//        alpha = (2*gray)/(double)215-(double)128/(double)215;
//        alpha = gray/(double)255;
        
//        if (gray != 255 && gray != 100)
//            continue;
//        if (gray == 255)
//            alpha = 0.1;
//        if (gray == 100)
//            alpha = 0.9;
//        if (gray == 50)
//            alpha = 0;
        
        
//        data lung bone
        if (gray < 230)
            continue;
        alpha = (gray*9)/(double)1050-(double)83/(double)70;
        
//        if (gray<100)
//            continue;
//            alpha = 0.9;

        
//        if (gray < 220)
//            continue;
//        alpha = gray/(double)1275+0.6;
//        alpha = -gray/(double)1275+0.8;
//        alpha = gray*4/(double)350-(double)67/(double)35;
//        alpha = 1;
//        alpha = 0.8;

        
        
//
//        
//        if (gray < 150)
//        {
//            continue;
//        }
        
        alpha_out = alpha_in + (1-alpha_in)*alpha;

        
        
        gray_out = (gray_out*alpha_in + gray*alpha*(1-alpha_in))/alpha_out;
//        cout<<"gray: "<<gray<<" alpha: "<<alpha<<" alpha out: "<<alpha_out<<" alpha in: "<<alpha_in<<" gray out: "<<gray_out<<endl;
        alpha_in =alpha_out;

    }

    return gray_out;
}
Ejemplo n.º 29
0
static void SetWaypointValues(bool first=false) {
  WndProperty* wp;

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATType"));
  if (wp) {
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M210_ = "Cylinder" 
      dfe->addEnumText(MsgToken(210));
	// LKTOKEN  _@M590_ = "Sector" 
      dfe->addEnumText(MsgToken(590));
      if(DoOptimizeRoute()) {
        // Conical ESS
        dfe->addEnumText(MsgToken(2175));
        // Circle ESS
        dfe->addEnumText(MsgToken(2189));
      }
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(Task[twItemIndex].AATType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  WindowControl* pFrm = wf->FindByName(_T("frmCircle"));
  if(pFrm) {
    pFrm->SetVisible((Task[twItemIndex].AATType==0) || (Task[twItemIndex].AATType==3));
  }
  pFrm = wf->FindByName(_T("frmSector"));
  if(pFrm) {
    pFrm->SetVisible(Task[twItemIndex].AATType==1);
  }
  pFrm = wf->FindByName(_T("frmCone"));
  if(pFrm) {
    pFrm->SetVisible(Task[twItemIndex].AATType==2);
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATCircleRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].AATCircleRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATSectorRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].AATSectorRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();    
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATStartRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].AATStartRadial);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATFinishRadial"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].AATFinishRadial);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpOutCircle"));
  if (wp) {
	  DataField* dfe = wp->GetDataField();
	  if (dfe) {
		  if (first) {
			  // LKTOKEN  _@M2226_ = "Enter" 
			  dfe->addEnumText(MsgToken(2145));
			  // LKTOKEN  _@M2227_ = "Exit" 
			  dfe->addEnumText(MsgToken(2146));
		  }
		  dfe->Set(Task[twItemIndex].OutCircle);
	  }
	  wp->SetVisible(DoOptimizeRoute());
	  wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpConeSlope"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].PGConeSlope);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpConeBase"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(Task[twItemIndex].PGConeBase*ALTITUDEMODIFY);
    wp->GetDataField()->SetUnits(Units::GetAltitudeName());
    wp->RefreshDisplay();
  }
  wp = (WndProperty*)wf->FindByName(TEXT("prpConeRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(Task[twItemIndex].PGConeBaseRadius
                                          *DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }
  
}
Ejemplo n.º 30
0
static void SetValues(bool first=false) {
  WndProperty* wp;

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskFinishLine"));
  if (wp) {
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M210_ = "Cylinder" 
      dfe->addEnumText(MsgToken(210));
	// LKTOKEN  _@M393_ = "Line" 
      dfe->addEnumText(MsgToken(393));
	// LKTOKEN  _@M274_ = "FAI Sector" 
      dfe->addEnumText(MsgToken(274));
    }
    dfe->Set(FinishLine);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskFinishRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(FinishRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskStartLine"));
  if (wp) {
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M210_ = "Cylinder" 
      dfe->addEnumText(MsgToken(210));
	// LKTOKEN  _@M393_ = "Line" 
      dfe->addEnumText(MsgToken(393));
	// LKTOKEN  _@M274_ = "FAI Sector" 
      dfe->addEnumText(MsgToken(274));
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(StartLine);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskStartRadius"));
  if (wp) {
    wp->GetDataField()->SetAsFloat(round(StartRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskFAISector"));
  if (wp) {
    // 110223 CAN ANYONE PLEASE CHECK WHAT THE HACK IS A BOOL FOR BILL GATES? BECAUSE IF FALSE IS -1 THEN
    // WE HAVE MANY PROBLEMS! I THINK IT IS TIME TO GO BACK TO bool AND GET RID OF MS BOOLS!!
  //  wp->SetVisible((AATEnabled==0) || (twItemIndex >0) );
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M210_ = "Cylinder" 
      dfe->addEnumText(MsgToken(210));
	// LKTOKEN  _@M274_ = "FAI Sector" 
      dfe->addEnumText(MsgToken(274));
      dfe->addEnumText(LKGetText(TEXT("DAe 0.5/10")));
      	// LKTOKEN  _@M393_ = "Line" 
      dfe->addEnumText(MsgToken(393));
    }
    dfe->SetDetachGUI(true); // disable call to OnAATEnabled
    dfe->Set(SectorType);
    dfe->SetDetachGUI(false);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpTaskSectorRadius"));
  if (wp) {
    wp->SetVisible(AATEnabled==0);
    wp->GetDataField()->SetAsFloat(round(SectorRadius*DISTANCEMODIFY*DISTANCE_ROUNDING)/DISTANCE_ROUNDING);
    wp->GetDataField()->SetUnits(Units::GetDistanceName());
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAutoAdvance"));
  if (wp) {
    DataField* dfe = wp->GetDataField();
    if (first) {
	// LKTOKEN  _@M418_ = "Manual" 
      dfe->addEnumText(MsgToken(418));
	// LKTOKEN _@M897_ "Auto"
      dfe->addEnumText(MsgToken(897));
	// LKTOKEN  _@M97_ = "Arm" 
      dfe->addEnumText(MsgToken(97));
	// LKTOKEN  _@M96_ = "Arm start" 
      dfe->addEnumText(MsgToken(96));
	// LKTOKEN  _@M1798_ = "Arm TPs" 
      dfe->addEnumText(MsgToken(1798));
    }
    dfe->Set(AutoAdvance);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpMinTime"));
  if (wp) {
    wp->SetVisible(AATEnabled>0 && (!PGOptimizeRoute || !ISPARAGLIDER));
    wp->GetDataField()->SetAsFloat(AATTaskLength);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpEnableMultipleStartPoints"));
  if (wp) {
    wp->SetVisible(!ISPARAGLIDER);
    wp->GetDataField()->Set(EnableMultipleStartPoints);
    wp->RefreshDisplay();
  }

  wp = (WndProperty*)wf->FindByName(TEXT("prpAATEnabled"));
  if (wp) {
	if (ISPARAGLIDER && PGOptimizeRoute) {
		wp->SetVisible(false);
		AATEnabled=true;
		wp->RefreshDisplay(); 
	} else {
		bool aw = (AATEnabled != 0);
		wp->GetDataField()->Set(aw);
		wp->RefreshDisplay(); 
	}
  }

  WndButton* wb;
  wb = (WndButton *)wf->FindByName(TEXT("EditStartPoints"));
  if (wb) {
    wb->SetVisible(EnableMultipleStartPoints!=0 && !ISPARAGLIDER);
  }

}