Open CASCADE学习|视图

目录

Mainwin.h

Mainwin.cpp


Mainwin.h

#pragma once#include <QtWidgets/QMainWindow>#include "Displaywin.h"#include "OCC.h"class Mainwin : public QMainWindow{  Q_OBJECTpublic:  Mainwin(QWidget* parent = nullptr);  ~Mainwin();private:  Mainwin* Mui;  Displaywin* Dui;private:  QMenu* fliemenuBar;  QAction* openstepfileaction;  QMenu* drawmenuBar;  QAction* drawboxaction;  QAction* drawbottleaction;  QAction* drawhelixaction;  QMenu* viewenuBar;  QAction* viewfrontaction;  QAction* viewbackaction;  QAction* viewtopaction;  QAction* viewbottomaction;  QAction* viewleftaction;  QAction* viewrightaction;  QAction* viewaxoaction;  QAction* viewresetaction;  QAction* viewfitallaction;  QAction* viewfitareaaction;  QAction* viewzoomaction;private:  void InitAction();  void InitMenu();private:  OCC occ;private slots:  void trigeropenfile();  void trigerdrawbox();  void trigerdrawbottle();  void trigerdrawhelix();  void trigerviewfront();  void trigerviewback();  void trigerviewtop();  void trigerviewbottom();  void trigerviewleft();  void trigerviewright();  void trigerviewaxo();  void trigerviewreset();  void trigerfitall();  void trigerfitarea();  void trigerzoom();};

Mainwin.cpp

#include "Mainwin.h"
#include<QMenu>
#include<QMenuBar>
#include <QMessageBox>
#include<QFileDialog>
Mainwin::Mainwin(QWidget* parent): QMainWindow(parent)
{setWindowTitle(tr("my draw"));resize(500, 500);
​Dui = new Displaywin(this);setCentralWidget(Dui);InitAction();InitMenu();
}
Mainwin::~Mainwin()
{}
void Mainwin::InitAction()
{openstepfileaction = new QAction(tr("open"), this);openstepfileaction->setShortcut(tr("Ctrl+O"));openstepfileaction->setStatusTip(tr("open a step file"));connect(openstepfileaction, SIGNAL(triggered()), this, SLOT(trigeropenfile()));
​drawboxaction = new QAction(tr("box"), this);drawboxaction->setShortcut(tr("Ctrl+1"));drawboxaction->setStatusTip(tr("draw a box"));connect(drawboxaction, SIGNAL(triggered()), this, SLOT(trigerdrawbox()));
​drawbottleaction = new QAction(tr("bottle"), this);drawbottleaction->setShortcut(tr("Ctrl+2"));drawbottleaction->setStatusTip(tr("draw a bottle"));connect(drawbottleaction, SIGNAL(triggered()), this, SLOT(trigerdrawbottle()));
​drawhelixaction = new QAction(tr("helix"), this);drawhelixaction->setShortcut(tr("Ctrl+3"));drawhelixaction->setStatusTip(tr("draw a helix"));connect(drawhelixaction, SIGNAL(triggered()), this, SLOT(trigerdrawhelix()));
​viewfrontaction = new QAction(tr("front"), this);viewfrontaction->setShortcut(tr("Ctrl+4"));viewfrontaction->setStatusTip(tr("front"));connect(viewfrontaction, SIGNAL(triggered()), this, SLOT(trigerviewfront()));
​viewbackaction = new QAction(tr("back"), this);viewbackaction->setShortcut(tr("Ctrl+5"));viewbackaction->setStatusTip(tr("back"));connect(viewbackaction, SIGNAL(triggered()), this, SLOT(trigerviewback()));
​viewtopaction = new QAction(tr("top"), this);viewtopaction->setShortcut(tr("Ctrl+6"));viewtopaction->setStatusTip(tr("top"));connect(viewtopaction, SIGNAL(triggered()), this, SLOT(trigerviewtop()));
​viewbottomaction = new QAction(tr("bottom"), this);viewbottomaction->setShortcut(tr("Ctrl+7"));viewbottomaction->setStatusTip(tr("bottom"));connect(viewbottomaction, SIGNAL(triggered()), this, SLOT(trigerviewbottom()));
​viewleftaction = new QAction(tr("left"), this);viewleftaction->setShortcut(tr("Ctrl+8"));viewleftaction->setStatusTip(tr("left"));connect(viewleftaction, SIGNAL(triggered()), this, SLOT(trigerviewleft()));
​viewrightaction = new QAction(tr("right"), this);viewrightaction->setShortcut(tr("Ctrl+9"));viewrightaction->setStatusTip(tr("right"));connect(viewrightaction, SIGNAL(triggered()), this, SLOT(trigerviewright()));
​viewaxoaction = new QAction(tr("axo"), this);viewaxoaction->setShortcut(tr("Ctrl+A"));viewaxoaction->setStatusTip(tr("axo"));connect(viewaxoaction, SIGNAL(triggered()), this, SLOT(trigerviewaxo()));
​viewresetaction = new QAction(tr("reset"), this);viewresetaction->setShortcut(tr("Ctrl+B"));viewresetaction->setStatusTip(tr("reset"));connect(viewresetaction, SIGNAL(triggered()), this, SLOT(trigerviewreset()));
​viewfitallaction = new QAction(tr("fitall"), this);viewfitallaction->setShortcut(tr("Ctrl+C"));viewfitallaction->setStatusTip(tr("fitall"));connect(viewfitallaction, SIGNAL(triggered()), this, SLOT(trigerfitall()));
​viewfitareaaction = new QAction(tr("fitarea"), this);viewfitareaaction->setShortcut(tr("Ctrl+D"));viewfitareaaction->setStatusTip(tr("fitarea"));connect(viewfitareaaction, SIGNAL(triggered()), this, SLOT(trigerfitarea()));
​viewzoomaction = new QAction(tr("zoom"), this);viewzoomaction->setShortcut(tr("Ctrl+E"));viewzoomaction->setStatusTip(tr("zoom"));connect(viewzoomaction, SIGNAL(triggered()), this, SLOT(trigerzoom()));
}
​
void Mainwin::InitMenu()
{fliemenuBar = menuBar()->addMenu("Flie");fliemenuBar->addAction(openstepfileaction);
​
​drawmenuBar = menuBar()->addMenu("Draw");drawmenuBar->addAction(drawboxaction);drawmenuBar->addAction(drawbottleaction);drawmenuBar->addAction(drawhelixaction);
​viewenuBar = menuBar()->addMenu("View");viewenuBar->addAction(viewfrontaction);viewenuBar->addAction(viewbackaction);viewenuBar->addAction(viewtopaction);viewenuBar->addAction(viewbottomaction);viewenuBar->addAction(viewleftaction);viewenuBar->addAction(viewrightaction);viewenuBar->addAction(viewaxoaction);viewenuBar->addAction(viewresetaction);viewenuBar->addAction(viewfitallaction);viewenuBar->addAction(viewfitareaaction);viewenuBar->addAction(viewzoomaction);
​
}
void Mainwin::trigeropenfile()
{
​QString filename = QFileDialog::getOpenFileName(this, "open file dialog", "/", "step files(*.step)");std::string stdfilename = filename.toStdString();const char* cstr = stdfilename.c_str();TopoDS_Shape stepShape = occ.Open_STEP(cstr);Quantity_Color color = Quantity_Color(0.3, 0.5, 0.3, Quantity_TOC_RGB);Handle(AIS_Shape) aisstep = new AIS_Shape(stepShape);Dui->GetInteractiveContext()->Display(aisstep, Standard_True);Dui->GetView()->FitAll();
​
}
​
void Mainwin::trigerdrawbox()
{TopoDS_Shape box = occ.createBox();Handle(AIS_Shape) aisBox = new AIS_Shape(box);Dui->GetInteractiveContext()->Display(aisBox, Standard_True);Dui->GetView()->FitAll();
​
}
void Mainwin::trigerdrawbottle()
{TopoDS_Shape bottle = occ.MakeBottle(50, 70, 30);Handle(AIS_Shape) aisBottle = new AIS_Shape(bottle);Dui->GetInteractiveContext()->Display(aisBottle, Standard_True);Dui->GetView()->FitAll();
}
void Mainwin::trigerdrawhelix()
{TopoDS_Shape helix = occ.createHelix2(3.0, M_PI/3,3.63);Handle(AIS_Shape) aishelix = new AIS_Shape(helix);Dui->GetInteractiveContext()->Display(aishelix, Standard_True);Dui->GetView()->FitAll();
}
void Mainwin::trigerviewfront()
{Dui->GetView()->SetProj(V3d_Yneg);
}
​
void Mainwin::trigerviewback()
{Dui->GetView()->SetProj(V3d_Ypos);
}
​
void Mainwin::trigerviewtop()
{Dui->GetView()->SetProj(V3d_Zpos);
}
​
void Mainwin::trigerviewbottom()
{Dui->GetView()->SetProj(V3d_Zneg);
}
​
void Mainwin::trigerviewleft()
{Dui->GetView()->SetProj(V3d_Xneg);
}
​
void Mainwin::trigerviewright()
{Dui->GetView()->SetProj(V3d_Xpos);
}
​
void Mainwin::trigerviewaxo()
{Dui->GetView()->SetProj(V3d_XposYnegZpos);
}
​
void Mainwin::trigerviewreset()
{Dui->GetView()->Reset();
}
void Mainwin::trigerfitall()
{Dui->GetView()->FitAll();Dui->GetView()->ZFitAll();Dui->GetView()->Redraw();
}
​
void Mainwin::trigerfitarea()
{//setCurrentAction(CurAction3d_WindowZooming);
}
​
void Mainwin::trigerzoom()
{//setCurrentAction(CurAction3d_DynamicZooming);
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/2813321.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

Stable Diffusion 绘画入门教程(webui)-ControlNet(Shuffle)

Shuffle(随机洗牌)&#xff0c;这个预处理器会把参考图的颜色打乱搅拌到一起&#xff0c;然后重新组合的方式重新生成一张图&#xff0c;可以想象出来这是一个整体风格控制的处理器。 那么问题来了&#xff0c;官方为啥会设计个这样的处理器呢&#xff0c;主要是给懒人用的&am…

idea生成WebServices接口

文章目录 idea生成WebServices接口1.创建接口2.生成wsdl文件3.在soapUI中&#xff0c;生成6个文件4.将生成的文件拷贝到工程中5.在service-config中注册服务 idea生成WebServices接口 1.创建接口 新建一个webServices工程&#xff0c;按照接口规范生成接口、请求类、响应类。…

低代码与大语言模型的探索实践

低代码系列文章&#xff1a; 可视化拖拽组件库一些技术要点原理分析可视化拖拽组件库一些技术要点原理分析&#xff08;二&#xff09;可视化拖拽组件库一些技术要点原理分析&#xff08;三&#xff09;可视化拖拽组件库一些技术要点原理分析&#xff08;四&#xff09;低代码…

《TCP/IP详解 卷一》第8章 ICMPv4和ICMPv6

目录 8.1 引言 8.1.1 在IPv4和IPv6中的封装 8.2 ICMP 报文 8.2.1 ICMPv4 报文 8.2.2 ICMPv6 报文 8.2.3 处理ICMP报文 8.3 ICMP差错报文 8.3.1 扩展的ICMP和多部报文 8.3.2 目的不可达和数据包太大 8.3.3 重定向 8.3.4 ICMP 超时 8.3.5 参数问题 8.4 ICMP查询/信息…

Mysql主从GTID与binlog

GTID与binlog **MySQL GTID&#xff08;Global Transaction Identifier&#xff09;和binlog&#xff08;二进制日志&#xff09;是用于搭建主从复制的两种不同的机制。** **GTID是MySQL 5.6版本引入的一种全局事务标识符&#xff0c;用于跟踪和标识复制过程中的事务。每个事务…

【玩转pandas系列】pandas数据结构—DataFrame

文章目录 前言一、DataFrame创建1.1 字典创建1.2 NumPy二维数组创建 二、DataFrame切片2.1 行切片2.2 列切片2.3 行列切片 三、DataFrame运算3.1 DataFrame和标量的运算3.2 DataFrame之间的运算3.3 Series和DataFrame之间的运算 四、DataFrame多层次索引4.1 多层次索引构造1.隐…

解决“设备未经过play保护认证”问题

第一步&#xff1a;获取GSF id 可以通过apkPure安装device id&#xff0c;复制GSF id&#xff0c;如下图 第二步&#xff1a;注册 打开网址&#xff1a;&#xff08;https://www.google.com/android/uncertified/?pli1 &#xff09;等待注册&#xff0c;很快就能完成, 第三步…

js 实战小案例

实战 时间 js 格式化时间 <script type"text/javascript">function formatDate(date) { let year date.getFullYear(); let month String(date.getMonth() 1).padStart(2, 0); // getMonth() 返回的月份是从0开始的&#xff0c;所以要加1&#xff0c;并…

如何快速起盘 七人拼团模式帮您解决 企业家可以过来看看!

七人团购模式&#xff0c;又称即拼模式&#xff0c;是一种创新的商业模式&#xff0c;通过结合拼团与二二复制的玩法&#xff0c;实现了快速的裂变和引流。该模式不仅具有完善的奖励激励制度&#xff0c;能够激发会员的推广积极性&#xff0c;还能显著提高平台产品的销量&#…

JavaWeb个人学习01

1:RequestParam(defaultValue "默认的值") 这个可以在一个参数的前面写上 要是前端不传值进来的话 这个形参就是你定义的默认值 2: slf4j 对应的是日志的输出 log.info("参数是 {}", detail); 3: 分页插件 PageHelper 用法: 准备工作: 引入依赖 …

mybatis 集成neo4j功能实现

文章目录 前言一、引入jar包依赖二、配置 application.properties三、Mybatis Neo4j分页插件四、Mybatis Neo4j自定义转换器handler五、MybatisNeo4j代码示例总结 前言 MyBatis是一个基于Java语言的持久层框架&#xff0c;它通过XML描述符或注解将对象与存储过程或SQL语句进行…

微信自动回复消息如何设置?演示如下

自动回复 当下&#xff0c;微信已经成为在工作中必不可少的沟通工具。但微信并没有自动回复的功能&#xff0c;一旦咨询量非常大&#xff0c;往往会出现回复不及时的情况。这样不仅会影响客户满意度&#xff0c;降低客户转化率&#xff0c;甚至会导致客户流失。 那如何实现自动…

Springboot教程(二)——过滤器、拦截器

过滤器 过滤器可以在调用控制器方法之前进行一些操作&#xff0c;过滤器类一般放在filter包下。 配置类注册 使用过滤器时&#xff0c;要实现Filter接口&#xff0c;并重写doFilter方法&#xff1a; class TestFilter : Filter {override fun doFilter(request: ServletReq…

怎么消除照片上的路人?分享几个无痕消除工具

穿梭于繁忙的街头&#xff0c;我们总会在不经意间捕捉到那些精彩的瞬间&#xff0c;但往往也会因为一些无关的路人破坏了整个画面的和谐。在摄影后期处理中&#xff0c;消除照片中的路人是一项常见的需求。现在&#xff0c;让我们一起探索如何巧妙地消除照片中的路人&#xff0…

Elasticsearch使用function_score查询酒店和排序

需求 基于用户地理位置&#xff0c;对酒店做简单的排序&#xff0c;非个性化的推荐。酒店评分包含以下&#xff1a; 酒店类型&#xff08;依赖用户历史订单数据&#xff09;&#xff1a;希望匹配出更加符合用户使用的酒店类型酒店评分&#xff1a;评分高的酒店用户体验感好ge…

2024河北国际光伏展

2024河北国际光伏展是一个专门展示和促进光伏技术与产业发展的国际性展览会。该展览会将于2024年在中国河北省举办&#xff0c;吸引来自世界各地的光伏企业、专家、学者和投资者参加。 展览会将展示最新的光伏技术和产品&#xff0c;包括太阳能电池板、光伏组件、逆变器、储能系…

洛谷 P2678 [NOIP2015 提高组] 跳石头(二分答案)

前提知识&#xff1a; 二分法往下其实有一些小分支&#xff0c;最常见的是二分查找&#xff0c;然后就是二分答案&#xff0c;浮点数二分等等 主要谈谈二分查找和二分答案的具体区别&#xff0c;我们不能光报个菜名随口就来&#xff0c;一问具体也说不出来个所以然。 前提&a…

GB28181 —— Ubuntu20.04下使用ZLMediaKit+WVP搭建GB28181流媒体监控平台(连接带云台摄像机)

最终效果 简介 GB28181协议是视频监控领域的国家标准。该标准规定了公共安全视频监控联网系统的互联结构, 传输、交换、控制的基本要求和安全性要求, 以及控制、传输流程和协议接口等技术要求,是视频监控领域的国家标准。GB28181协议信令层面使用的是SIP(Session Initiatio…

物联网手持终端机 超高频RFID手持终端工业级盘点PDA设备

在数字化时代&#xff0c;物联网手持终端机已经成为各行业不可或缺的工具。联强优创自主研发远距离手柄式超高频RFID读写手持终端&#xff0c;搭载高性能UHF读写模块&#xff0c;距离可达1-15米&#xff0c;基于IMPINJ E710芯片超高频模块与设备完美兼容&#xff0c;支持协议标…

图论基础(一)

一、图论 图论是数学的一个分支&#xff0c;它以图为研究对象。图论中的图是若干给定的点&#xff08;顶点&#xff09;以及连接两点的线&#xff08;边&#xff09;构成的图像&#xff0c;这种图形通常用来描述某些事物之间的某种特定关系&#xff0c;用点代表事物&#xff0c…