📄 qmg_gui.cpp
字号:
// ------------------------------------------------------------------// qmg_gui.cpp//// This file contains routines for creating the Matlab GUI for the// mesh generator.// Part of the QMG quadtree/octree mesh generator.// ------------------------------------------------------------------// Copyright (c) 1999 by Cornell University. All rights reserved.// // See the accompanying file 'Copyright' for authorship information,// the terms of the license governing this software, and disclaimers// concerning this software.// ------------------------------------------------------------------// This file is part of the QMG software. // Version 2.0 of QMG, release date September 3, 1999// ------------------------------------------------------------------#include "qmg_gui.h"#include "qboxstack.h"#include "qfrontend.h"QMG::MG::Meshgen_gui::Meshgen_gui(bool active, QMG::FrontEnd::Interpreter& interp, const Brep& brep, Logstream& logstr) :active_(active), interp_(interp),logstr_(logstr),last_update_time_(0),scp_(0),dagp_(0){ if (!active_) return; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 0.0; mxArray* prhs[1]; prhs[0] = opcode; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 1, prhs, "gm_meshgui"); mxDestroyArray(opcode); this -> update();}void QMG::MG::Meshgen_gui::check_update() { if (!active_) return; time_t this_time = time(0); if (this_time - last_update_time_ > 0) update();}void QMG::MG::Meshgen_gui::update() { if (!active_) return; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 1.0; mxArray* additional_data = mxCreateDoubleMatrix(1, 4, mxREAL); double* moredata = mxGetPr(additional_data); moredata[0] = static_cast<double>(ActiveBox::active_box_count()); moredata[1] = static_cast<double>((dagp_)? dagp_ -> size() : 0); moredata[2] = static_cast<double>((scp_)? scp_ -> num_elements() : 0); moredata[3] = static_cast<double>((scp_)? scp_ -> num_nodes() : 0); mxArray* prhs[2]; prhs[0] = opcode; prhs[1] = additional_data; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 2, prhs, "gm_meshgui"); mxDestroyArray(additional_data); mxDestroyArray(opcode); const mxArray* cancel_button = mexGetArrayPtr("GM_CANCEL_BUTTON", "global"); if (!cancel_button) throw_error("No cancel button handle"); if (*mxGetPr(cancel_button) > 0.0) throw_error("Cancel button has been pressed."); last_update_time_ = time(0);};void QMG::MG::Meshgen_gui::indicate_error_has_occurred(const string& s) { if (!active_) return; scp_ = 0; dagp_= 0; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 2.0; mxArray* additional_data = mxCreateString(s.c_str()); mxArray* prhs[2]; prhs[0] = opcode; prhs[1] = additional_data; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 2, prhs, "gm_meshgui"); mxDestroyArray(additional_data); mxDestroyArray(opcode);}// ------------------------------------------------------------------// Destructor// Terminates the GUI.// ------------------------------------------------------------------QMG::MG::Meshgen_gui::~Meshgen_gui() { if (!active_) return; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 3.0; mxArray* prhs[1]; prhs[0] = opcode; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 1, prhs, "gm_meshgui"); mxDestroyArray(opcode);}// ------------------------------------------------------------------// indicate_phase_start// Passes a string to gm_mggui// ------------------------------------------------------------------void QMG::MG::Meshgen_gui::operation(const string& s) { if (!active_) return; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 4.0; mxArray* additional_data = mxCreateString(s.c_str()); mxArray* prhs[2]; prhs[0] = opcode; prhs[1] = additional_data; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 2, prhs, "gm_meshgui"); mxDestroyArray(additional_data); mxDestroyArray(opcode); this -> update();}// ------------------------------------------------------------------// indicate_operation// Passes a string to gm_mggui// ------------------------------------------------------------------void QMG::MG::Meshgen_gui::operation2(const string& s) { if (!active_) return; mxArray* opcode = mxCreateDoubleMatrix(1, 1, mxREAL); *mxGetPr(opcode) = 5.0; mxArray* additional_data = mxCreateString(s.c_str()); mxArray* prhs[2]; prhs[0] = opcode; prhs[1] = additional_data; mxArray* plhs[1]; mexCallMATLAB(0, plhs, 2, prhs, "gm_meshgui"); mxDestroyArray(additional_data); mxDestroyArray(opcode); this -> update();}void QMG::MG::Meshgen_gui::associate_sc_and_dag(const SimpComplex& sc, const BoxFaceDag& dag) { scp_ = ≻ dagp_ = &dag;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -