qmg_gui.cpp
来自「算断裂的」· C++ 代码 · 共 144 行
CPP
144 行
// ------------------------------------------------------------------// qmg_gui.cpp//// This file contains routines for creating the Tcl 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"namespace { using namespace QMG; using namespace QMG::MG; void dump_err(FrontEnd::Interpreter& interp, int returncode, ostream& os) { Tcl_Interp* gui_interp = interp.get_interp(); if (returncode == TCL_OK) return; os << "interp -> result = " << gui_interp -> result << std::endl; const char* c = Tcl_GetVar(gui_interp, "errorInfo", 0); if (c) os << "error_info = " << c << std::endl; ostringstream errstr; errstr << "Error has occurred in the GUI panel: " << gui_interp -> result; throw_error(errstr.str()); }}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; int returncode = Tcl_VarEval(interp_.get_interp(), "gm_meshgui init", 0); dump_err(interp_, returncode, logstr_.str()); 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; ostringstream os; os << "gm_meshgui update " << ActiveBox::active_box_count() << " " << ((dagp_)? dagp_ -> size() : 0) << " " << ((scp_)? scp_ -> num_elements() : 0) << " " << ((scp_)? scp_ -> num_nodes() : 0) << " "; string s = os.str(); const char* cmd = s.c_str(); int returncode = Tcl_Eval(interp_.get_interp(), const_cast<char*>(cmd)); dump_err(interp_, returncode, logstr_.str()); last_update_time_ = time(0);};void QMG::MG::Meshgen_gui::indicate_error_has_occurred(const string& s) { if (!active_) return; scp_ = 0; dagp_= 0; Tcl_VarEval(interp_.get_interp(), "gm_meshgui errormsg {", s.c_str(), "}", 0);} // ------------------------------------------------------------------// Destructor// Terminates the GUI.// ------------------------------------------------------------------QMG::MG::Meshgen_gui::~Meshgen_gui() { if (!active_) return; Tcl_VarEval(interp_.get_interp(), "gm_meshgui end", 0);}// ------------------------------------------------------------------// indicate_phase_start// Passes a string to gm_mggui// ------------------------------------------------------------------void QMG::MG::Meshgen_gui::operation(const string& s) { if (!this -> active_) return; int returncode = Tcl_VarEval(interp_.get_interp(), "gm_meshgui operation {", s.c_str(), "}", 0); dump_err(interp_, returncode, logstr_.str()); this -> update();}// ------------------------------------------------------------------// indicate_operation// Passes a string to gm_mggui// ------------------------------------------------------------------void QMG::MG::Meshgen_gui::operation2(const string& s) { if (!this -> active_) return; int returncode = Tcl_VarEval(interp_.get_interp(), "gm_meshgui operation2 {", s.c_str(), "}", 0); dump_err(interp_, returncode, logstr_.str()); 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 + =
减小字号Ctrl + -
显示快捷键?