活动介绍
file-type

Geometry_demo: VC/MFC对角框源代码深入解析

ZIP文件

35KB | 更新于2025-08-17 | 94 浏览量 | 0 下载量 举报 收藏
download 立即下载
在IT行业,特别是在Windows编程领域,使用Visual C++ (VC) 和Microsoft Foundation Classes (MFC) 编写对话框应用程序是一种非常常见且基础的任务。对话框是用户与软件交互的一个重要界面元素,通过它可以接收用户的输入,显示信息,或者提供程序的配置选项。本知识点将重点阐述标题中提到的“对话框VC源代码:Geometry_demo”这一概念,以及其背后的编程技术和实践。 首先,让我们来详细解释标题中的几个关键词: 1. 对话框(Dialog Box):是Windows应用中用于输入信息或更改设置的一种特殊窗口。它包括一系列控件,例如文本框、按钮、复选框、单选按钮等。对话框可以模态或非模态两种形式存在,模态对话框需要用户先与之交互完成后才能与程序的其他部分交互,而非模态对话框则允许用户同时与多个窗口交互。 2. VC源代码:代表使用Visual C++工具创建的源代码。Visual C++是一个强大的集成开发环境(IDE),它提供了一套完整的工具,包括代码编辑器、调试器和编译器,用于创建Windows桌面应用程序和其他类型的软件。 3. Geometry_demo:这是一个示例项目的名称,可能代表了一个教学或演示性质的程序。在这个程序中,可能涉及到几何学的概念,例如使用对话框来输入或显示几何图形的参数,或对几何图形进行操作等。 根据描述和标签,我们可以推断出以下知识点: 1. 对话框源代码的创建和使用:在VC/MFC中,创建对话框通常涉及几个步骤:设计对话框界面,使用资源编辑器定义控件和布局,然后在代码中响应用户事件和处理数据。开发者需要对MFC类库有一定的了解,尤其是与对话框相关的CDialog类。 2. 对话框的几何属性控制:通过对话框,开发者可以控制窗口的几何属性,例如大小、位置、形状等。在“Geometry_demo”项目中,可能会演示如何通过代码动态改变对话框的几何属性,例如根据用户输入调整对话框的尺寸或形状,或者实现特定的布局效果。 3. Windows窗口视图的编程:这涉及到Windows API和MFC类库的使用,以实现窗口的创建、管理和绘制。开发者需要了解窗口消息处理机制,以及如何在MFC中通过消息映射表将消息映射到相应处理函数。 4. 关键字“Geometry_demo,对话框”:这表明项目可能具有以下特征: - 在程序中重点展示了对话框的几何学应用,可能包括计算几何元素的属性或处理与几何学相关的用户输入。 - 使用对话框作为主要的用户界面组件,可能是教学或实验性质的,以帮助学习和理解几何学和对话框编程。 5. 关于VC/MFC源代码:一个典型的VC/MFC项目结构包括各种资源文件(.rc)、头文件(.h)、源文件(.cpp)以及项目文件(.vcproj)。开发者需要对这些文件类型及其在项目中的作用有所了解。 6. 项目文件的结构:由于“Projects”文件夹通常包含项目的所有资源和源文件,开发者应当熟悉这些文件之间的关系,以及如何在Visual Studio环境中组织它们。 结合上述信息,开发者可以从“对话框VC源代码:Geometry_demo”中学习到如何结合几何学知识和对话框编程技术,实现特定功能的应用程序。此外,通过分析和理解提供的源代码,开发者可以进一步提升在Windows平台下的用户界面设计能力和编程实践技能。

相关推荐

filetype

void DataSDMap::parse_graph(OsmGraph const &sdMap, Eigen::Affine3d const &transformationMatrix, std::vector<EdgeInfo> &edges_info, bool crop) const noexcept { // get roi corner points std::vector<Point> canvas_polygon; if (crop) { double min_x = -1 * roiLength; double max_x = roiLength; double min_y = -1 * roiWidth; double max_y = roiWidth; canvas_polygon.push_back(Point(min_x, min_y)); canvas_polygon.push_back(Point(min_x, max_y)); canvas_polygon.push_back(Point(max_x, max_y)); canvas_polygon.push_back(Point(max_x, min_y)); } auto start = std::chrono::high_resolution_clock::now(); edges_info.clear(); // 读取graph中的edges数据,还原edge geometry // std::cout << "Number of edges: " << boost::num_edges(sdMap) << std::endl; std::pair<boost::adjacency_list<>::vertex_iterator, boost::adjacency_list<>::vertex_iterator> vertices_pair = boost::vertices(sdMap); // boost::iterator_range<boost::graph_traits<OsmGraph>::vertex_iterator> // vertices_pair = boost::make_iterator_range(vertices(sdMap)); for (auto e : // boost::make_iterator_range(boost::edges(sdMap))) for (auto e = boost::edges(sdMap).first; e != boost::edges(sdMap).second; ++e) { const OsmEdgeProperties &edgeProps = sdMap[*e]; // get vertices geometry LineString linestring_global; std::string line_geometry_string = edgeProps.geometry; if (line_geometry_string.empty()) { boost::adjacency_list<>::vertex_descriptor source = boost::source(*e, sdMap); boost::adjacency_list<>::vertex_descriptor target = boost::target(*e, sdMap); if (source == target) continue; line_geometry_string = "LINESTRING ("; const OsmNodeProperties &startNodeProps = sdMap[*(vertices_pair.first + source)]; line_geometry_string = line_geometry_string + startNodeProps.x + " " + startNodeProps.y + ", "; const OsmNodeProperties &endNodeProps = sdMap[*(vertices_pair.first + target)]; line_geometry_string = line_geometry_string + " " + endNodeProps.x + " " + endNodeProps.y + ")"; } auto end0 = std::chrono::high_resolution_clock::now(); boost::geometry::read_wkt(line_geometry_string, linestring_global); auto end1 = std::chrono::high_resolution_clock::now() 这段代码在周期调用时,运行时间递增,注释 boost::geometry::read_wkt(line_geometry_string, linestring_global);这行前后代码运行时间差异很大,分析可能的原因?

filetype

void DataSDMap::parse_graph(OsmGraph const &sdMap, Eigen::Affine3d const &transformationMatrix, std::vector<EdgeInfo> &edges_info, bool crop) const noexcept { // get roi corner points std::vector<Point> canvas_polygon; if (crop) { double min_x = -1 * roiLength; double max_x = roiLength; double min_y = -1 * roiWidth; double max_y = roiWidth; canvas_polygon.push_back(Point(min_x, min_y)); canvas_polygon.push_back(Point(min_x, max_y)); canvas_polygon.push_back(Point(max_x, max_y)); canvas_polygon.push_back(Point(max_x, min_y)); } auto start = std::chrono::high_resolution_clock::now(); edges_info.clear(); // 读取graph中的edges数据,还原edge geometry // std::cout << "Number of edges: " << boost::num_edges(sdMap) << std::endl; std::pair<boost::adjacency_list<>::vertex_iterator, boost::adjacency_list<>::vertex_iterator> vertices_pair = boost::vertices(sdMap); // boost::iterator_range<boost::graph_traits<OsmGraph>::vertex_iterator> // vertices_pair = boost::make_iterator_range(vertices(sdMap)); for (auto e : // boost::make_iterator_range(boost::edges(sdMap))) for (auto e = boost::edges(sdMap).first; e != boost::edges(sdMap).second; ++e) { const OsmEdgeProperties &edgeProps = sdMap[*e]; // get vertices geometry LineString linestring_global; std::string line_geometry_string = edgeProps.geometry; if (line_geometry_string.empty()) { boost::adjacency_list<>::vertex_descriptor source = boost::source(*e, sdMap); boost::adjacency_list<>::vertex_descriptor target = boost::target(*e, sdMap); if (source == target) continue; line_geometry_string = "LINESTRING ("; const OsmNodeProperties &startNodeProps = sdMap[*(vertices_pair.first + source)]; line_geometry_string = line_geometry_string + startNodeProps.x + " " + startNodeProps.y + ", "; const OsmNodeProperties &endNodeProps = sdMap[*(vertices_pair.first + target)]; line_geometry_string = line_geometry_string + " " + endNodeProps.x + " " + endNodeProps.y + ")"; } boost::geometry::read_wkt(line_geometry_string, linestring_global); auto end = std::chrono::high_resolution_clock::now(); auto delay = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); 分析这段代码在周期性调用时,运行时间在递增,分析可能的原因?

filetype

void DataSDMap::parse_graph(OsmGraph const &sdMap, Eigen::Affine3d const &transformationMatrix, std::vector<EdgeInfo> &edges_info, bool crop) const noexcept { // get roi corner points std::vector<Point> canvas_polygon; if (crop) { double min_x = -1 * roiLength; double max_x = roiLength; double min_y = -1 * roiWidth; double max_y = roiWidth; canvas_polygon.push_back(Point(min_x, min_y)); canvas_polygon.push_back(Point(min_x, max_y)); canvas_polygon.push_back(Point(max_x, max_y)); canvas_polygon.push_back(Point(max_x, min_y)); } auto start = std::chrono::high_resolution_clock::now(); edges_info.clear(); // 读取graph中的edges数据,还原edge geometry // std::cout << "Number of edges: " << boost::num_edges(sdMap) << std::endl; std::pair<boost::adjacency_list<>::vertex_iterator, boost::adjacency_list<>::vertex_iterator> vertices_pair = boost::vertices(sdMap); // boost::iterator_range<boost::graph_traits<OsmGraph>::vertex_iterator> // vertices_pair = boost::make_iterator_range(vertices(sdMap)); for (auto e : // boost::make_iterator_range(boost::edges(sdMap))) for (auto e = boost::edges(sdMap).first; e != boost::edges(sdMap).second; ++e) { const OsmEdgeProperties &edgeProps = sdMap[*e]; // get vertices geometry LineString linestring_global; std::string line_geometry_string = edgeProps.geometry; if (line_geometry_string.empty()) { boost::adjacency_list<>::vertex_descriptor source = boost::source(*e, sdMap); boost::adjacency_list<>::vertex_descriptor target = boost::target(*e, sdMap); if (source == target) continue; line_geometry_string = "LINESTRING ("; const OsmNodeProperties &startNodeProps = sdMap[*(vertices_pair.first + source)]; line_geometry_string = line_geometry_string + startNodeProps.x + " " + startNodeProps.y + ", "; const OsmNodeProperties &endNodeProps = sdMap[*(vertices_pair.first + target)]; line_geometry_string = line_geometry_string + " " + endNodeProps.x + " " + endNodeProps.y + ")"; } auto end0 = std::chrono::high_resolution_clock::now(); boost::geometry::read_wkt(line_geometry_string, linestring_global); auto end1 = std::chrono::high_resolution_clock::now(); std::cout << "Memory: " << malloc_stats() << " KB\n"; auto delay0 = std::chrono::duration_cast<std::chrono::milliseconds>(end0 - start).count(); auto delay1 = std::chrono::duration_cast<std::chrono::milliseconds>(end1 - start).count(); std::cout << "-----------------sdmap encode timer delay : " << delay0 << " delay1: " << delay1 << std::endl; 分析这段代码在周期性调用时,运行时间在递增,分析可能的原因?

filetype

for (auto e = boost::edges(sdMap).first; e != boost::edges(sdMap).second; ++e) { auto start = std::chrono::high_resolution_clock::now(); const OsmEdgeProperties &edgeProps = sdMap[*e]; // get vertices geometry LineString linestring_global; std::string line_geometry_string = edgeProps.geometry; if (line_geometry_string.empty()) { boost::adjacency_list<>::vertex_descriptor source = boost::source(*e, sdMap); boost::adjacency_list<>::vertex_descriptor target = boost::target(*e, sdMap); if (source == target) continue; line_geometry_string = "LINESTRING ("; const OsmNodeProperties &startNodeProps = sdMap[*(vertices_pair.first + source)]; line_geometry_string = line_geometry_string + startNodeProps.x + " " + startNodeProps.y + ", "; const OsmNodeProperties &endNodeProps = sdMap[*(vertices_pair.first + target)]; line_geometry_string = line_geometry_string + " " + endNodeProps.x + " " + endNodeProps.y + ")"; } // auto end = std::chrono::high_resolution_clock::now(); boost::geometry::read_wkt(line_geometry_string, linestring_global); // auto end = std::chrono::high_resolution_clock::now(); // auto delay = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); // std::cout << "sdmap encode timer delay : " << delay << std::endl; // get Properties std::string fclass = edgeProps.fclass; std::vector<std::string> fclass_explode; if (fclass.front() == '[' && fclass.back() == ']') { fclass = fclass.substr(1, fclass.size() - 2); fclass.erase(std::remove_if(fclass.begin(), fclass.end(), ::isspace), fclass.end()); boost::split(fclass_explode, fclass, boost::is_any_of(",")); } else { fclass_explode.push_back(fclass); } for (size_t i = 0; i < fclass_explode.size(); i++) { fclass = "other"; for (const auto &pair : HIGHWAY_SETS) { if (pair.second.find(fclass_explode[i]) != pair.second.end()) { fclass = pair.first; break; } } fclass_explode[i] = fclass; } // transform geometry to local coordinate LineString linestring_local; transformGlobalToEgo(transformationMatrix, linestring_global, linestring_local); std::vector<LineString> inner_lines; // crop try { if (crop) { get_inner_lines(canvas_polygon, linestring_local, inner_lines); } else { inner_lines.push_back(linestring_local); } } catch (const std::exception &e) { std::cerr << "error: " << e.what() << std::endl; continue; } // 将裁剪得到的线段加入结果 for (std::string sub_fclass : fclass_explode) { for (LineString inner_line : inner_lines) { EdgeInfo edge_info{fclass, inner_line}; edges_info.push_back(edge_info); } } } 分析并理解这段代码,发现耗时逐渐递增主要发生在这行段for循环里。

weixin_38728464
  • 粉丝: 1
上传资源 快速赚钱