00001 // Filename: pStatCollectorDef.cxx 00002 // Created by: drose (09Jul00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "pStatCollectorDef.h" 00020 00021 #include <datagram.h> 00022 #include <datagramIterator.h> 00023 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: PStatCollectorDef::Default Constructor 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 PStatCollectorDef:: 00031 PStatCollectorDef() { 00032 _index = 0; 00033 _parent_index = 0; 00034 _suggested_color.set(0.0, 0.0, 0.0); 00035 _sort = -1; 00036 _suggested_scale = 0.0; 00037 _factor = 1.0; 00038 _is_active = true; 00039 _active_explicitly_set = false; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: PStatCollectorDef::Constructor 00044 // Access: Public 00045 // Description: 00046 //////////////////////////////////////////////////////////////////// 00047 PStatCollectorDef:: 00048 PStatCollectorDef(int index, const string &name) : 00049 _index(index), 00050 _name(name) 00051 { 00052 _parent_index = 0; 00053 _suggested_color.set(0.0, 0.0, 0.0); 00054 _sort = -1; 00055 _suggested_scale = 0.0; 00056 _factor = 1.0; 00057 _is_active = true; 00058 _active_explicitly_set = false; 00059 } 00060 00061 //////////////////////////////////////////////////////////////////// 00062 // Function: PStatCollectorDef::set_parent 00063 // Access: Public 00064 // Description: This is normally called only by the PStatClient when 00065 // the new PStatCollectorDef is created; it sets the 00066 // parent of the CollectorDef and inherits whatever 00067 // properties are appropriate. 00068 //////////////////////////////////////////////////////////////////// 00069 void PStatCollectorDef:: 00070 set_parent(const PStatCollectorDef &parent) { 00071 _parent_index = parent._index; 00072 _level_units = parent._level_units; 00073 _suggested_scale = parent._suggested_scale; 00074 _factor = parent._factor; 00075 _is_active = parent._is_active; 00076 _active_explicitly_set = parent._active_explicitly_set; 00077 } 00078 00079 //////////////////////////////////////////////////////////////////// 00080 // Function: PStatCollectorDef::write_datagram 00081 // Access: Public 00082 // Description: Writes the definition of the collectorDef to the 00083 // datagram. 00084 //////////////////////////////////////////////////////////////////// 00085 void PStatCollectorDef:: 00086 write_datagram(Datagram &destination) const { 00087 destination.add_int16(_index); 00088 destination.add_string(_name); 00089 destination.add_int16(_parent_index); 00090 _suggested_color.write_datagram(destination); 00091 destination.add_int16(_sort); 00092 destination.add_string(_level_units); 00093 destination.add_float32(_suggested_scale); 00094 destination.add_float32(_factor); 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: PStatCollectorDef::read_datagram 00099 // Access: Public 00100 // Description: Extracts the collectorDef definition from the datagram. 00101 //////////////////////////////////////////////////////////////////// 00102 void PStatCollectorDef:: 00103 read_datagram(DatagramIterator &source, PStatClientVersion *) { 00104 _index = source.get_int16(); 00105 _name = source.get_string(); 00106 _parent_index = source.get_int16(); 00107 _suggested_color.read_datagram(source); 00108 _sort = source.get_int16(); 00109 _level_units = source.get_string(); 00110 _suggested_scale = source.get_float32(); 00111 _factor = source.get_float32(); 00112 }