#include "MyApp.h"
#include "MainFrame.h"
#include <regex>
#include "Calculate.h"
using namespace std;
//画时域波形
void MainFrame::draw_time_domain(wxDC* dc) {
int w=0, h=0;
//获得面板大小
this->imagePanel->GetSize(&w, &h);
//画信号一x轴
dc->DrawLine(wxPoint(0.03*w, h*0.3), wxPoint(0.98*w, h*0.3));
//画信号一x轴箭头
dc->DrawLine(wxPoint(0.98*w, h*0.3), wxPoint(0.98*w - 8, h*0.3 + 8));
dc->DrawLine(wxPoint(0.98*w, h*0.3), wxPoint(0.98*w - 8, h*0.3 - 8));
//画信号一x轴标注
dc->DrawText(_T("t"), wxPoint(0.95*w, h*0.3 + 30));
//画信号一y轴
dc->DrawLine(wxPoint(0.05*w, h*0.1), wxPoint(0.05*w, h*0.5));
//画信号一轴箭头
dc->DrawLine(wxPoint(0.05*w, h*0.1), wxPoint(0.05*w - 8, h*0.1 + 8));
dc->DrawLine(wxPoint(0.05*w, h*0.1), wxPoint(0.05*w + 8, h*0.1 + 8));
//画信号一轴标注
dc->DrawText(_T("signal"), wxPoint(0.05*w + 8, h*0.1 - 8));
dc->SetPen(*wxBLACK_PEN);
//画信号二x轴
dc->DrawLine(wxPoint(0.03*w, h*0.8), wxPoint(0.98*w, h*0.8));
//画信号二x轴箭头
dc->DrawLine(wxPoint(0.98*w, h*0.8), wxPoint(0.98*w - 8, h*0.8 + 8));
dc->DrawLine(wxPoint(0.98*w, h*0.8), wxPoint(0.98*w - 8, h*0.8 - 8));
//画信号二x轴标注
dc->DrawText(_T("t"), wxPoint(0.95*w, h*0.8 + 30));
//画信号二y轴
dc->DrawLine(wxPoint(0.05*w, h*0.6), wxPoint(0.05*w, h));
//画信号二轴箭头
dc->DrawLine(wxPoint(0.05*w, h*0.6), wxPoint(0.05*w - 8, h*0.6 + 8));
dc->DrawLine(wxPoint(0.05*w, h*0.6), wxPoint(0.05*w + 8, h*0.6 + 8));
//画信号二轴标注
dc->DrawText(_T("signal"), wxPoint(0.05*w + 8, h*0.6 - 8));
//画信号一
if (isUseSignal1->GetValue()) {
wxString type = signal_1_choice->GetValue();
std::regex r("([1-9]+[0-9]*|0)(\\.[\\d]+)?");
std::regex r_i("^[10]*$");
if (type.Contains(_T("BOC"))) {
string signal = string(signal_1_in_signal_input->GetValue().mb_str());
string fs = string(signal_1_in_fs_input->GetValue().mb_str());
string fc = string(signal_1_in_fc_input->GetValue().mb_str());
if (regex_match(signal, r_i) && regex_match(fs, r) && regex_match(fc, r)) {
dc->DrawText(_T("信号一:BOC"), wxPoint(5, 5));
int signal_len = signal.length();
int element_len = 0.9*w / signal.length();
int n = 2 * Calculate::stringToNum<double>(fs) / Calculate::stringToNum<double>(fc);
int v_len = element_len / n;
dc->SetPen(*wxBLACK_DASHED_PEN);
for (int signal_inex = 0; signal_inex < signal_len; signal_inex++) {
for (int i = 1; i <= n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.1), wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.5));
}
}
dc->SetPen(*wxRED_PEN);
for (int signal_inex = 0; signal_inex < signal_len; signal_inex++) {
if (signal[signal_inex] == '0') {
for (int i = 0; i < n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, i % 2 == 0 ? h*0.45 : h*0.15), wxPoint(0.05*w + (i + 1)*v_len + element_len*signal_inex, i % 2 == 0 ? h*0.45 : h*0.15));
}
}
else{
for (int i = 0; i < n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, i % 2 == 0 ? h*0.15 : h*0.45), wxPoint(0.05*w + (i + 1)*v_len + element_len*signal_inex, i % 2 == 0 ? h*0.15 : h*0.45));
}
}
}
}
else{
dc->DrawText(_T("输入错误"), wxPoint(5, 5));
}
}
else if (type.Contains(_T("BPSK"))) {
string signal = string(signal_1_in_signal_input->GetValue().mb_str());
if (regex_match(signal, r_i)) {
dc->DrawText(_T("信号一:BPSK"), wxPoint(5, 5));
int signal_len = signal.length();
int element_len = 0.9*w / signal.length();
dc->SetPen(*wxBLACK_DASHED_PEN);
for (int signal_inex = 1; signal_inex <= signal_len; signal_inex++) {
dc->DrawLine(wxPoint(0.05*w + element_len*signal_inex, h*0.1), wxPoint(0.05*w + element_len*signal_inex, h*0.5));
}
dc->SetPen(*wxRED_PEN);
for (int signal_inex = 1; signal_inex <= signal_len; signal_inex++) {
int i_x_o = (signal_inex - 1)*element_len+0.05*w, i_y_o = 0.3*h, x = 0, y = 0;
if (signal[signal_inex-1] == '0') {
for (x = i_x_o; x < signal_inex*element_len + 0.05*w; x++) {
y = 0.3*h + sin((x - (signal_inex - 1)*element_len - 0.05*w) * 2 * PI / element_len)*0.15*h;
dc->DrawLine(wxPoint(i_x_o, i_y_o), wxPoint(x, y));
i_x_o = x;
i_y_o = y;
}
}
else {
for (x = i_x_o; x < signal_inex*element_len + 0.05*w; x++) {
y = 0.3*h - sin((x - (signal_inex - 1)*element_len - 0.05*w) * 2 * PI / element_len)*0.15*h;
dc->DrawLine(wxPoint(i_x_o, i_y_o), wxPoint(x, y));
i_x_o = x;
i_y_o = y;
}
}
}
}
else{
dc->DrawText(_T("输入错误"), wxPoint(5, 5));
}
}
else{
dc->DrawText(_T("未选择信号类型"), wxPoint(5, 5));
}
}
//画信号二
if (isUseSignal1->GetValue()) {
wxString type = signal_2_choice->GetValue();
std::regex r("([1-9]+[0-9]*|0)(\\.[\\d]+)?");
std::regex r_i("^[10]*$");
if (type.Contains(_T("BOC"))) {
string signal = string(signal_2_in_signal_input->GetValue().mb_str());
string fs = string(signal_2_in_fs_input->GetValue().mb_str());
string fc = string(signal_2_in_fc_input->GetValue().mb_str());
if (regex_match(signal, r_i) && regex_match(fs, r) && regex_match(fc, r)) {
dc->DrawText(_T("信号二:BOC"), wxPoint(5, h*0.5 + 5));
int signal_len = signal.length();
int element_len = 0.9*w / signal.length();
int n = 2 * Calculate::stringToNum<double>(fs) / Calculate::stringToNum<double>(fc);
int v_len = element_len / n;
dc->SetPen(*wxBLACK_DASHED_PEN);
for (int signal_inex = 0; signal_inex < signal_len; signal_inex++) {
for (int i = 1; i <= n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.1 + h*0.5), wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.5 + h*0.5));
}
}
dc->SetPen(*wxRED_PEN);
for (int signal_inex = 0; signal_inex < signal_len; signal_inex++) {
if (signal[signal_inex] == '0') {
for (int i = 0; i < n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.5 + (i % 2 == 0 ? h*0.45 : h*0.15)), wxPoint(0.05*w + (i + 1)*v_len + element_len*signal_inex, h*0.5 + (i % 2 == 0 ? h*0.45 : h*0.15)));
}
}
else {
for (int i = 0; i < n; i++) {
dc->DrawLine(wxPoint(0.05*w + i*v_len + element_len*signal_inex, h*0.5 + (i % 2 == 0 ? h*0.15 : h*0.45)), wxPoint(0.05*w + (i + 1)*v_len + element_len*signal_inex, h*0.5 + (i % 2 == 0 ? h*0.15 : h*0.45)));
}
}
}
}
else {
dc->DrawText(_T("输入错误"), wxPoint(5, h*0.5 + 5));
}
}
else if (type.Contains(_T("BPSK"))) {
string signal = string(signal_2_in_signal_input->GetValue().mb_str());
if (regex_match(signal, r_i)) {
dc->DrawText(_T("信号二:BPSK"), wxPoint(5, h*0.5 + 5));
int signal_len = signal.length();
int element_len = 0.9*w / signal.length();
dc->SetPen(*wxBLACK_DASHED_PEN);
for (int signal_inex = 1; signal_inex <= signal_len; signal_inex++) {
dc->DrawLine(wxPoint(0.05*w + element_len*signal_inex, h*0.5 + h*0.1), wxPoint(0.05*w + element_len*signal_inex, h*0.5 + h*0.5));
}
dc->SetPen(*wxRED_PEN);
for (int signal_inex = 1; signal_inex <= signal_len; signal_inex++) {
int i_x_o = (signal_inex - 1)*element_len + 0.05*w, i_y_o = h*0.5 + 0.3*h, x = 0, y = 0;
if (signal[signal_inex - 1] == '0') {
for (x = i_x_o; x < signal_inex*element_len + 0.05*w; x++) {
y = h*0.5 + 0.3*h + sin((x - (signal_inex - 1)*element_len - 0.05*w) * 2 * PI / element_len)*0.15*h;
dc->DrawLine(wxPoint(i_x_o, i_y_o), wxPoint(x, y));
i_x_o = x;
i_y_o = y;
}
}
else {
for (x = i_x_o; x < signal_inex*element_len + 0.05*w; x++) {
y = h*0.5 + 0.3*h - sin((x - (signal_inex - 1)*element_len - 0.05*w) * 2 * PI / element_len)*0.15*h;
dc->DrawLine(wxPoint(i_x_o, i_y_o), wxPoint(x, y));
i_x_o = x;
i_y_o = y;
}
}
}
}
else {
dc->DrawText(_T("输入错误"),
热爱技术。
- 粉丝: 2819
- 资源: 7864
最新资源
- 房屋租赁平台:提升租赁交易透明度的数字化路径
- sfnt-pingpong
- EtherCAT和CANOPEN stm32f4主控,keil工程 带EtherCAT和CANOPEN总线通信
- STM32MP1系列微处理器USB DFU/USART协议详解与编程服务
- 手法手检测5-YOLO(v5至v11)、COCO、CreateML、Paligemma、TFRecord、VOC数据集合集.rar
- 并联式混合动力系统simulink控制策略模型 ①(工况可自行添加); ②仿真图像包括 发动机转矩变化图像、电机转矩变化图像、电池SOC变化图像、速度跟随图像、车速变化图像; ③整车similink模
- 高通410随身WiFi通用超频Debian12固件
- 淘乐乐员工购物商城:技术架构与功能实现详解
- STM32WB系列上使用Zigbee群集模板的技术指南
- STM32WB系列微控制器ZigBee配网指南
- 雷达信号处理:运动目标相参积累-Radon-Fourier算法,用于检测运动目标,实现距离和多普勒参数估计 Matlab程序,包含函数文件和使用文件,代码简洁易懂,注释详细
- STM32微控制器双存储区即时固件更新技术详解
- 无人驾驶轨迹跟踪控制(Carsim2020+matlab2020b)实现基于mpc的分布式驱动电动汽车变道轨迹跟踪控制,仿真效果较好,涉及分布式驱动转矩分配
- 扑克牌和骰子检测4-YOLO(v5至v9)、COCO、CreateML、Darknet、Paligemma、TFRecord数据集合集.rar
- 基于stm32的智能除湿器(无阿里云版)
- 学生成绩链表处理-C语言实现学生成绩链表处理与优化
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈