bool dlgTaskPointType(OrderedTask &task, const unsigned index) { point_types.clear(); task.GetFactory().GetValidTypes(index) .CopyTo(std::back_inserter(point_types)); if (point_types.empty()) { assert(1); return false; } if (point_types.size() == 1) return SetPointType(task, index, point_types[0]); const auto &point = task.GetPoint(index); const auto current_type = task.GetFactory().GetType(point); unsigned initial_index = 0; const auto b = point_types.begin(), e = point_types.end(); auto i = std::find(b, e, current_type); if (i != e) initial_index = std::distance(b, i); MutateTaskPointRenderer item_renderer(current_type); int result = ListPicker(_("Task Point Type"), point_types.size(), initial_index, item_renderer.CalculateLayout(UIGlobals::GetDialogLook()), item_renderer, false, nullptr, TPTypeItemHelp); return result >= 0 && SetPointType(task, index, point_types[result]); }
bool dlgTaskPointType(OrderedTask** task, const unsigned index) { ordered_task = *task; active_index = index; point = &ordered_task->GetPoint(active_index); point_types.clear(); ordered_task->GetFactory().GetValidTypes(index) .CopyTo(std::back_inserter(point_types)); if (point_types.empty()) { assert(1); return false; } if (point_types.size() == 1) return SetPointType(point_types[0]); unsigned initial_index = 0; const auto b = point_types.begin(), e = point_types.end(); auto i = std::find(b, e, get_point_type()); if (i != e) initial_index = std::distance(b, i); FunctionListItemRenderer item_renderer(OnPointPaintListItem); int result = ListPicker(_("Task Point Type"), point_types.size(), initial_index, Layout::Scale(18), item_renderer, false, nullptr, TPTypeItemHelp); return result >= 0 && SetPointType(point_types[result]); }
bool dlgTaskPointType(SingleWindow &parent, OrderedTask** task, const unsigned index) { ordered_task = *task; task_modified = false; active_index = index; point = ordered_task->get_tp(active_index); if (point) way_point = &point->GetWaypoint(); else way_point = NULL; if (Layout::landscape) wf = LoadDialog(CallBackTable, parent, _T("IDR_XML_TASKPOINTTYPE_L")); else wf = LoadDialog(CallBackTable, parent, _T("IDR_XML_TASKPOINTTYPE")); if (!wf) return false; assert(wf != NULL); wPointTypes = (WndListFrame*)wf->FindByName(_T("frmPointTypes")); assert(wPointTypes != NULL); point_types = ordered_task->GetFactory().GetValidTypes(index); if (point_types.empty()) { assert(1); return false; } wPointTypes->SetActivateCallback(OnPointListEnter); wPointTypes->SetPaintItemCallback(OnPointPaintListItem); wPointTypes->SetCursorCallback(OnPointCursorCallback); wPointTypes->SetLength(point_types.size()); if (point) for (unsigned i=0; i<point_types.size(); i++) if (point_types[i] == get_point_type()) wPointTypes->SetCursorIndex(i); RefreshView(); if (point_types.size()==1) SetPointType(point_types[0]); else wf->ShowModal(); delete wf; wf = NULL; return task_modified; }
static void OnSelect() { if (wPointTypes->GetCursorIndex() >= point_types.size()) return; if (SetPointType(get_cursor_type())) wf->SetModalResult(mrOK); else wf->SetModalResult(mrCancel); }
void SubsetAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("SubsetAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("colorType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 3) SetColorType(ColoringMethod(ival)); } else if(node->GetNodeType() == STRING_NODE) { ColoringMethod value; if(ColoringMethod_FromString(node->AsString(), value)) SetColorType(value); } } if((node = searchNode->GetNode("colorTableName")) != 0) SetColorTableName(node->AsString()); if((node = searchNode->GetNode("invertColorTable")) != 0) SetInvertColorTable(node->AsBool()); if((node = searchNode->GetNode("filledFlag")) != 0) SetFilledFlag(node->AsBool()); if((node = searchNode->GetNode("legendFlag")) != 0) SetLegendFlag(node->AsBool()); if((node = searchNode->GetNode("lineStyle")) != 0) SetLineStyle(node->AsInt()); if((node = searchNode->GetNode("lineWidth")) != 0) SetLineWidth(node->AsInt()); if((node = searchNode->GetNode("singleColor")) != 0) singleColor.SetFromNode(node); if((node = searchNode->GetNode("multiColor")) != 0) multiColor.SetFromNode(node); if((node = searchNode->GetNode("subsetNames")) != 0) SetSubsetNames(node->AsStringVector()); if((node = searchNode->GetNode("subsetType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 6) SetSubsetType(Subset_Type(ival)); } else if(node->GetNodeType() == STRING_NODE) { Subset_Type value; if(Subset_Type_FromString(node->AsString(), value)) SetSubsetType(value); } } if((node = searchNode->GetNode("opacity")) != 0) SetOpacity(node->AsDouble()); if((node = searchNode->GetNode("wireframe")) != 0) SetWireframe(node->AsBool()); if((node = searchNode->GetNode("drawInternal")) != 0) SetDrawInternal(node->AsBool()); if((node = searchNode->GetNode("smoothingLevel")) != 0) SetSmoothingLevel(node->AsInt()); if((node = searchNode->GetNode("pointSize")) != 0) SetPointSize(node->AsDouble()); if((node = searchNode->GetNode("pointType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 8) SetPointType(PointType(ival)); } else if(node->GetNodeType() == STRING_NODE) { PointType value; if(PointType_FromString(node->AsString(), value)) SetPointType(value); } } if((node = searchNode->GetNode("pointSizeVarEnabled")) != 0) SetPointSizeVarEnabled(node->AsBool()); if((node = searchNode->GetNode("pointSizeVar")) != 0) SetPointSizeVar(node->AsString()); if((node = searchNode->GetNode("pointSizePixels")) != 0) SetPointSizePixels(node->AsInt()); }
void FilledBoundaryAttributes::SetFromNode(DataNode *parentNode) { if(parentNode == 0) return; DataNode *searchNode = parentNode->GetNode("FilledBoundaryAttributes"); if(searchNode == 0) return; DataNode *node; if((node = searchNode->GetNode("colorType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 3) SetColorType(ColoringMethod(ival)); } else if(node->GetNodeType() == STRING_NODE) { ColoringMethod value; if(ColoringMethod_FromString(node->AsString(), value)) SetColorType(value); } } if((node = searchNode->GetNode("colorTableName")) != 0) SetColorTableName(node->AsString()); if((node = searchNode->GetNode("invertColorTable")) != 0) SetInvertColorTable(node->AsBool()); if((node = searchNode->GetNode("filledFlag")) != 0) SetFilledFlag(node->AsBool()); if((node = searchNode->GetNode("legendFlag")) != 0) SetLegendFlag(node->AsBool()); if((node = searchNode->GetNode("lineStyle")) != 0) SetLineStyle(node->AsInt()); if((node = searchNode->GetNode("lineWidth")) != 0) SetLineWidth(node->AsInt()); if((node = searchNode->GetNode("singleColor")) != 0) singleColor.SetFromNode(node); if((node = searchNode->GetNode("multiColor")) != 0) multiColor.SetFromNode(node); if((node = searchNode->GetNode("boundaryNames")) != 0) SetBoundaryNames(node->AsStringVector()); if((node = searchNode->GetNode("boundaryType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 4) SetBoundaryType(Boundary_Type(ival)); } else if(node->GetNodeType() == STRING_NODE) { Boundary_Type value; if(Boundary_Type_FromString(node->AsString(), value)) SetBoundaryType(value); } } if((node = searchNode->GetNode("opacity")) != 0) SetOpacity(node->AsDouble()); if((node = searchNode->GetNode("wireframe")) != 0) SetWireframe(node->AsBool()); if((node = searchNode->GetNode("drawInternal")) != 0) SetDrawInternal(node->AsBool()); if((node = searchNode->GetNode("smoothingLevel")) != 0) SetSmoothingLevel(node->AsInt()); if((node = searchNode->GetNode("cleanZonesOnly")) != 0) SetCleanZonesOnly(node->AsBool()); if((node = searchNode->GetNode("mixedColor")) != 0) mixedColor.SetFromNode(node); if((node = searchNode->GetNode("pointSize")) != 0) SetPointSize(node->AsDouble()); if((node = searchNode->GetNode("pointType")) != 0) { // Allow enums to be int or string in the config file if(node->GetNodeType() == INT_NODE) { int ival = node->AsInt(); if(ival >= 0 && ival < 8) SetPointType(PointType(ival)); } else if(node->GetNodeType() == STRING_NODE) { PointType value; if(PointType_FromString(node->AsString(), value)) SetPointType(value); } } if((node = searchNode->GetNode("pointSizeVarEnabled")) != 0) SetPointSizeVarEnabled(node->AsBool()); if((node = searchNode->GetNode("pointSizeVar")) != 0) SetPointSizeVar(node->AsString()); if((node = searchNode->GetNode("pointSizePixels")) != 0) SetPointSizePixels(node->AsInt()); // We are no longer using MultiColor as the source for the "mixed" // color (in clean zones only), but someone may have saved their // settings with the "mixed" color in the list. Remove it if it's // in there. // // NOTE: This code can be removed in a few months, as soon as // 1.3 is at least a few versions old, since it represents a little // bit of a hack. bool done = false; while (!done) { done = true; size_t index; for (index=0; index<boundaryNames.size(); index++) { if (boundaryNames[index] == "mixed") { done = false; break; } } if (!done) { multiColor.RemoveColors((int)index); for (size_t i=index+1; i<boundaryNames.size(); i++) boundaryNames[i-1] = boundaryNames[i]; boundaryNames.resize(boundaryNames.size() - 1); } } }