source: ThirdParty/mpqc_open/src/lib/chemistry/cca/MPQC_Chemistry_MoleculeViewer_Impl.cc@ bbc982

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.0 Candidate_v1.6.1 ChangeBugEmailaddress ChangingTestPorts ChemicalSpaceEvaluator Combining_Subpackages Debian_Package_split Debian_package_split_molecuildergui_only Disabling_MemDebug Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enable_parallel_make_install Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph FitPartialCharges_GlobalError Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_goodresults ForceAnnealing_oldresults ForceAnnealing_tocheck ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool JobMarket_unresolvable_hostname_fix ODR_violation_mpqc_open PartialCharges_OrthogonalSummation PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction Subpackage_levmar Subpackage_vmg ThirdParty_MPQC_rebuilt_buildsystem TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps Ubuntu_1604_changes stable
Last change on this file since bbc982 was 860145, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '0b990dfaa8c6007a996d030163a25f7f5fc8a7e7' as 'ThirdParty/mpqc_open'

  • Property mode set to 100644
File size: 5.1 KB
Line 
1//
2// File: MPQC_Chemistry_MoleculeViewer_Impl.cc
3// Symbol: MPQC.Chemistry_MoleculeViewer-v0.2
4// Symbol Type: class
5// Babel Version: 0.10.2
6// Description: Server-side implementation for MPQC.Chemistry_MoleculeViewer
7//
8// WARNING: Automatically generated; only changes within splicers preserved
9//
10// babel-version = 0.10.2
11//
12#include "MPQC_Chemistry_MoleculeViewer_Impl.hh"
13
14// DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer._includes)
15#include <sstream>
16#include <iostream>
17// DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer._includes)
18
19// user-defined constructor.
20void MPQC::Chemistry_MoleculeViewer_impl::_ctor() {
21 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer._ctor)
22 is_updated=0;
23 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer._ctor)
24}
25
26// user-defined destructor.
27void MPQC::Chemistry_MoleculeViewer_impl::_dtor() {
28 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer._dtor)
29
30#if USE_SOCKET
31 try {
32 socket_.close();
33 }
34 catch (std::exception &e) {
35 std::cout << "NOTE: could not close viewer connection: "
36 << e.what()
37 << std::endl;
38 }
39#endif // USE_SOCKET
40
41 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer._dtor)
42}
43
44// static class initializer.
45void MPQC::Chemistry_MoleculeViewer_impl::_load() {
46 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer._load)
47 // guaranteed to be called at most once before any other method in this class
48 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer._load)
49}
50
51// user-defined static methods: (none)
52
53// user-defined non-static methods:
54/**
55 * Method: set_molecule[]
56 */
57void
58MPQC::Chemistry_MoleculeViewer_impl::set_molecule (
59 /* in */ ::Chemistry::Molecule molecule )
60throw ()
61{
62 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer.set_molecule)
63 molecule_ = molecule;
64 is_updated=1;
65 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer.set_molecule)
66}
67
68/**
69 * Method: set_coor[]
70 */
71void
72MPQC::Chemistry_MoleculeViewer_impl::set_coor (
73 /* in */ const ::std::string& coords )
74throw ()
75{
76 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer.set_coor)
77 // insert implementation here
78 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer.set_coor)
79}
80
81/**
82 * Method: run_gui[]
83 */
84void
85MPQC::Chemistry_MoleculeViewer_impl::run_gui ()
86throw ()
87
88{
89 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer.run_gui)
90 // insert implementation here
91 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer.run_gui)
92}
93
94/**
95 * Method: draw[]
96 */
97void
98MPQC::Chemistry_MoleculeViewer_impl::draw ()
99throw ()
100
101{
102 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer.draw)
103 if (molecule_._is_nil()) {
104 return;
105 }
106
107 std::cout << "drawing" << std::endl;
108
109 for (int i=0; i<molecule_.get_n_atom(); i++) {
110 std::cout << "====="
111 << " " << molecule_.get_cart_coor(i,0)
112 << " " << molecule_.get_cart_coor(i,1)
113 << " " << molecule_.get_cart_coor(i,2)
114 << std::endl;
115 }
116
117#if USE_SOCKET
118 try {
119
120 if (!socket_.initialized()) socket_.create();
121 if (!socket_.bound()) socket_.bind(10002,12000);
122 if (!socket_.connected()) socket_.connect("localhost", 10001);
123
124 std::ostringstream str;
125 const double f = 1.0/(1.0e-10/5.29177249e-11); // m
126 for (int i=0; i<molecule_.get_n_atom(); i++) {
127 str << " " << f*molecule_.get_cart_coor(i,0)
128 << " " << f*molecule_.get_cart_coor(i,1)
129 << " " << f*molecule_.get_cart_coor(i,2);
130 }
131 str << " ";
132 socket_.write(str.str().c_str(), str.str().size());
133 std::cout << "sent to socket: " << str.str() << std::endl;
134 }
135 catch (std::exception &e) {
136 std::cout << "NOTE: Could not draw to viewer: "
137 << e.what()
138 << std::endl;
139 }
140#endif // USE_SOCKET
141 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer.draw)
142}
143
144/**
145 * Starts up a component presence in the calling framework.
146 * @param Svc the component instance's handle on the framework world.
147 * Contracts concerning Svc and setServices:
148 *
149 * The component interaction with the CCA framework
150 * and Ports begins on the call to setServices by the framework.
151 *
152 * This function is called exactly once for each instance created
153 * by the framework.
154 *
155 * The argument Svc will never be nil/null.
156 *
157 * Those uses ports which are automatically connected by the framework
158 * (so-called service-ports) may be obtained via getPort during
159 * setServices.
160 */
161void
162MPQC::Chemistry_MoleculeViewer_impl::setServices (
163 /* in */ ::gov::cca::Services services )
164throw (
165 ::gov::cca::CCAException
166){
167 // DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer.setServices)
168 services.addProvidesPort(self,"MoleculeViewer","Chemistry.MoleculeViewer",
169 services.createTypeMap());
170 // DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer.setServices)
171}
172
173
174// DO-NOT-DELETE splicer.begin(MPQC.Chemistry_MoleculeViewer._misc)
175// Put miscellaneous code here
176// DO-NOT-DELETE splicer.end(MPQC.Chemistry_MoleculeViewer._misc)
177
Note: See TracBrowser for help on using the repository browser.