1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation;
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15 *
16 * Author: John Abraham <john.abraham.in@gmail.com>
17 * Contributions: Dmitrii Shakshin <d.shakshin@gmail.com> (Open Source and Linux Laboratory http://dev.osll.ru/)
18 */
19
20 #include "animpropertybrowser.h"
21 #include "animnode.h"
22 #include "animatormode.h"
23 #include "animresource.h"
24
25 namespace netanim {
26
27 NS_LOG_COMPONENT_DEFINE ("AnimPropertyBroswer");
28
29 AnimPropertyBroswer * pAnimPropertyBrowser = 0;
30
AnimPropertyBroswer()31 AnimPropertyBroswer::AnimPropertyBroswer ():
32 m_vboxLayout (0),
33 m_nodeBrowser (0),
34 m_backgroundBrowser (0),
35 m_nodePosTable (0),
36 m_mode (0),
37 m_nodeIdSelector (0),
38 m_nodeIdProperty (0),
39 m_nodeSysIdProperty (0),
40 m_nodeDescriptionProperty (0),
41 m_nodeXProperty (0),
42 m_nodeYProperty (0),
43 m_nodeColorProperty (0),
44 m_nodeSizeProperty (0),
45 m_fileEditProperty (0),
46 m_ipv4AddressGroupProperty (0),
47 m_ipv6AddressGroupProperty (0),
48 m_macAddressGroupProperty (0),
49 m_nodePositionGroupProperty (0),
50 m_showNodeTrajectoryProperty (0),
51 m_backgroundFileEditProperty (0),
52 m_backgroundX (0),
53 m_backgroundY (0),
54 m_backgroundScaleX (0),
55 m_backgroundScaleY (0),
56 m_backgroundOpacity (0),
57 m_currentNodeId (0),
58 m_intManager (0),
59 m_stringManager (0),
60 m_doubleManager (0),
61 m_backgroundDoubleManager (0),
62 m_colorManager (0),
63 m_filePathManager (0),
64 m_nodePositionManager (0),
65 m_ipv4AddressManager (0),
66 m_ipv6AddressManager (0),
67 m_macAddressManager (0),
68 m_staticStringManager (0),
69 m_boolManager (0),
70 m_doubleSpinBoxFactory (0),
71 m_spinBoxFactory (0),
72 m_fileEditFactory (0),
73 m_lineEditFactory (0),
74 m_checkBoxFactory (0)
75 {
76 m_vboxLayout = new QVBoxLayout;
77
78 setLayout (m_vboxLayout);
79 m_nodeBrowser = new QtTreePropertyBrowser;
80 m_backgroundBrowser = new QtTreePropertyBrowser;
81 m_nodePosTable = new Table;
82 m_mode = new QComboBox;
83 m_nodeIdSelector = new QComboBox;
84 m_mode->addItem ("Node");
85 m_mode->addItem ("Background");
86 m_vboxLayout->addWidget (m_mode);
87
88 m_vboxLayout->addWidget (m_nodeIdSelector);
89 m_vboxLayout->addWidget (m_nodeBrowser);
90 m_vboxLayout->addWidget (m_nodePosTable);
91 m_vboxLayout->addWidget (m_backgroundBrowser);
92 m_backgroundBrowser->setVisible (false);
93 m_nodePosTable->setVisible (false);
94 //m_nodePosTable->setColumnCount (3);
95 connect (m_mode, SIGNAL(currentIndexChanged(QString)), this, SLOT(modeChangedSlot(QString)));
96
97 }
98
99
100 void
show(bool show)101 AnimPropertyBroswer::show (bool show)
102 {
103 setVisible (show);
104 }
105
106 AnimPropertyBroswer *
getInstance()107 AnimPropertyBroswer::getInstance ()
108 {
109 if (!pAnimPropertyBrowser)
110 {
111 pAnimPropertyBrowser = new AnimPropertyBroswer;
112 }
113 return pAnimPropertyBrowser;
114 }
115
116 void
systemReset()117 AnimPropertyBroswer::systemReset ()
118 {
119 reset ();
120 }
121
122
123 void
setCurrentNodeId(uint32_t currentNodeId)124 AnimPropertyBroswer::setCurrentNodeId (uint32_t currentNodeId)
125 {
126 m_nodeIdSelector->setCurrentIndex (currentNodeId);
127 nodeIdSelectorSlot (QString::number (currentNodeId));
128 }
129
130 void
postParse()131 AnimPropertyBroswer::postParse ()
132 {
133 reset ();
134 uint32_t count = AnimNodeMgr::getInstance ()->getCount ();
135 for (uint32_t i = 0; i < count; ++i)
136 {
137 m_nodeIdSelector->addItem (QString::number (i));
138 }
139 setupManagers ();
140 setupFactories ();
141 setupNodeProperties ();
142 setupBackgroundProperties ();
143 connect (m_nodeIdSelector, SIGNAL(currentIndexChanged(QString)), this, SLOT (nodeIdSelectorSlot(QString)));
144
145 }
146
147 void
reset()148 AnimPropertyBroswer::reset ()
149 {
150 m_currentNodeId = 0;
151 m_nodeIdSelector->clear ();
152 disconnect (m_nodeIdSelector, SIGNAL(currentIndexChanged(QString)), this, SLOT (nodeIdSelectorSlot(QString)));
153 if (m_intManager)
154 delete m_intManager;
155 if (m_stringManager)
156 delete m_stringManager;
157 if (m_doubleManager)
158 delete m_doubleManager;
159 if (m_colorManager)
160 delete m_colorManager;
161 if (m_filePathManager)
162 delete m_filePathManager;
163 if (m_nodePositionManager)
164 delete m_nodePositionManager;
165 if (m_ipv4AddressManager)
166 delete m_ipv4AddressManager;
167 if (m_ipv6AddressManager)
168 delete m_ipv6AddressManager;
169 if (m_macAddressManager)
170 delete m_macAddressManager;
171 if (m_staticStringManager)
172 delete m_staticStringManager;
173 if (m_boolManager)
174 delete m_boolManager;
175 if (m_backgroundDoubleManager)
176 delete m_backgroundDoubleManager;
177 m_intManager = 0;
178 m_stringManager = 0;
179 m_doubleManager = 0;
180 m_colorManager = 0;
181 m_filePathManager = 0;
182 m_nodePositionManager = 0;
183 m_ipv4AddressManager = 0;
184 m_ipv6AddressManager = 0;
185 m_macAddressManager = 0;
186 m_staticStringManager = 0;
187 m_boolManager = 0;
188 m_backgroundDoubleManager = 0;
189
190 if (m_doubleSpinBoxFactory)
191 delete m_doubleSpinBoxFactory;
192 if (m_spinBoxFactory)
193 delete m_spinBoxFactory;
194 if (m_fileEditFactory)
195 delete m_fileEditFactory;
196 if (m_lineEditFactory)
197 delete m_lineEditFactory;
198 if (m_checkBoxFactory)
199 delete m_checkBoxFactory;
200
201 m_doubleSpinBoxFactory = 0;
202 m_spinBoxFactory = 0;
203 m_fileEditFactory = 0;
204 m_lineEditFactory = 0;
205 m_checkBoxFactory = 0;
206
207 }
208
209 void
setupManagers()210 AnimPropertyBroswer::setupManagers ()
211 {
212 m_intManager = new QtIntPropertyManager;
213 m_stringManager = new QtStringPropertyManager;
214 m_doubleManager = new QtDoublePropertyManager;
215 m_colorManager = new QtColorPropertyManager;
216 m_filePathManager = new FilePathManager;
217 m_nodePositionManager = new QtGroupPropertyManager;
218 m_ipv4AddressManager = new QtGroupPropertyManager;
219 m_ipv6AddressManager = new QtGroupPropertyManager;
220 m_macAddressManager = new QtGroupPropertyManager;
221 m_staticStringManager = new QtStringPropertyManager;
222 m_boolManager = new QtBoolPropertyManager;
223 m_backgroundDoubleManager = new QtDoublePropertyManager;
224
225 }
226
227 void
setupFactories()228 AnimPropertyBroswer::setupFactories ()
229 {
230 m_doubleSpinBoxFactory = new QtDoubleSpinBoxFactory;
231 m_spinBoxFactory = new QtSpinBoxFactory;
232 m_fileEditFactory = new FileEditFactory;
233 m_lineEditFactory = new QtLineEditFactory;
234 m_checkBoxFactory = new QtCheckBoxFactory;
235 }
236
237
238 void
refreshBackgroundProperties()239 AnimPropertyBroswer::refreshBackgroundProperties ()
240 {
241 BackgroudImageProperties_t prop = AnimatorMode::getInstance ()->getBackgroundProperties ();
242 m_backgroundDoubleManager->setValue (m_backgroundX, prop.x);
243 m_backgroundDoubleManager->setValue (m_backgroundY, prop.y);
244 //m_backgroundDoubleManager->setValue (m_backgroundScaleX, prop.scaleX);
245 //m_backgroundDoubleManager->setValue (m_backgroundScaleY, prop.scaleY);
246 m_backgroundDoubleManager->setValue (m_backgroundOpacity, prop.opacity);
247 m_backgroundBrowser->setFactoryForManager (m_backgroundDoubleManager, m_doubleSpinBoxFactory);
248
249 }
250 void
setupBackgroundProperties()251 AnimPropertyBroswer::setupBackgroundProperties ()
252 {
253 m_backgroundX = m_backgroundDoubleManager->addProperty ("X");
254 m_backgroundY = m_backgroundDoubleManager->addProperty ("Y");
255 m_backgroundScaleX = m_backgroundDoubleManager->addProperty ("Scale X By");
256 m_backgroundScaleY = m_backgroundDoubleManager->addProperty ("Scale Y By");
257 m_backgroundOpacity = m_backgroundDoubleManager->addProperty ("Opacity (0.0 to 1.0)");
258
259 m_backgroundBrowser->addProperty (m_backgroundX);
260 m_backgroundBrowser->addProperty (m_backgroundY);
261 m_backgroundBrowser->addProperty (m_backgroundScaleX);
262 m_backgroundBrowser->addProperty (m_backgroundScaleY);
263 m_backgroundBrowser->addProperty (m_backgroundOpacity);
264
265 BackgroudImageProperties_t prop = AnimatorMode::getInstance ()->getBackgroundProperties ();
266 m_backgroundDoubleManager->setValue (m_backgroundX, prop.x);
267 m_backgroundDoubleManager->setValue (m_backgroundY, prop.y);
268 m_backgroundDoubleManager->setValue (m_backgroundScaleX, prop.scaleX);
269 m_backgroundDoubleManager->setValue (m_backgroundScaleY, prop.scaleY);
270 m_backgroundDoubleManager->setValue (m_backgroundOpacity, prop.opacity);
271 m_backgroundBrowser->setFactoryForManager (m_backgroundDoubleManager, m_doubleSpinBoxFactory);
272 connect (m_backgroundDoubleManager, SIGNAL(valueChanged(QtProperty*,double)), this, SLOT(valueChangedSlot(QtProperty*,double)));
273
274
275 }
276
277 void
setupNodeProperties()278 AnimPropertyBroswer::setupNodeProperties ()
279 {
280
281 // Properties
282
283 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
284
285
286 // Node Id, Node System Id
287 m_nodeIdProperty = m_intManager->addProperty ("Node Id");
288 m_intManager->setValue (m_nodeIdProperty, m_currentNodeId);
289 m_nodeBrowser->addProperty (m_nodeIdProperty);
290 m_nodeSysIdProperty = m_intManager->addProperty ("Node System Id");
291 m_intManager->setValue (m_nodeSysIdProperty, animNode ->getNodeSysId ());
292 m_nodeBrowser->addProperty (m_nodeSysIdProperty);
293
294
295 // Node Description
296 m_nodeDescriptionProperty = m_stringManager->addProperty ("Node Description");
297 m_nodeBrowser->setFactoryForManager (m_stringManager, m_lineEditFactory);
298 connect (m_stringManager, SIGNAL (valueChanged (QtProperty*,QString)), this, SLOT (valueChangedSlot (QtProperty*,QString)));
299 m_nodeBrowser->addProperty (m_nodeDescriptionProperty);
300 m_stringManager->setValue (m_nodeDescriptionProperty, animNode->getDescription ()->toPlainText ());
301
302
303 // Node Position
304 m_nodePositionGroupProperty = m_nodePositionManager->addProperty ("Node Position");
305 m_nodeXProperty = m_doubleManager->addProperty ("Node X");
306 m_nodeYProperty = m_doubleManager->addProperty ("Node Y");
307 m_nodePositionGroupProperty->addSubProperty (m_nodeXProperty);
308 m_nodePositionGroupProperty->addSubProperty (m_nodeYProperty);
309 m_doubleManager->setMinimum (m_nodeXProperty, 0);
310 m_doubleManager->setMinimum (m_nodeYProperty, 0);
311 m_doubleManager->setValue (m_nodeXProperty, animNode->getX ());
312 m_doubleManager->setValue (m_nodeYProperty, animNode->getY ());
313 connect (m_doubleManager, SIGNAL(valueChanged(QtProperty*,double)), this, SLOT(valueChangedSlot(QtProperty*,double)));
314 m_nodeBrowser->addProperty (m_nodePositionGroupProperty);
315 m_nodeBrowser->setFactoryForManager (m_doubleManager, m_doubleSpinBoxFactory);
316
317
318 // Node Color
319 m_nodeColorProperty = m_colorManager->addProperty ("Node Color");
320 connect(m_colorManager, SIGNAL(valueChanged(QtProperty*,QColor)), this, SLOT(valueChangedSlot(QtProperty*,QColor)));
321 m_nodeBrowser->addProperty (m_nodeColorProperty);
322 m_nodeBrowser->setFactoryForManager (m_colorManager->subIntPropertyManager (), m_spinBoxFactory);
323 QColor c = animNode->getColor ();
324 m_colorManager->setValue (m_nodeColorProperty, c);
325
326
327 // Node Size
328 m_nodeSizeProperty = m_doubleManager->addProperty ("Node Size");
329 m_doubleManager->setValue (m_nodeSizeProperty, animNode->getWidth ());
330 m_doubleManager->setMinimum (m_nodeSizeProperty, 0.1);
331 m_nodeBrowser->addProperty (m_nodeSizeProperty);
332
333
334 // Node Resource
335 int resourceId = animNode->getResourceId ();
336 QString resourcePath = "";
337 if (resourceId != -1)
338 {
339 resourcePath = AnimResourceManager::getInstance ()->get (resourceId);
340 }
341 m_fileEditProperty = m_filePathManager->addProperty ("Node Resource");
342 m_filePathManager->setValue (m_fileEditProperty, resourcePath);
343 m_nodeBrowser->addProperty (m_fileEditProperty);
344 m_nodeBrowser->setFactoryForManager (m_filePathManager, m_fileEditFactory);
345 connect (m_filePathManager, SIGNAL(valueChanged(QtProperty*,QString)), this, SLOT(valueChangedSlot(QtProperty*,QString)));
346
347
348 // Node Trajectory
349 m_showNodeTrajectoryProperty = m_boolManager->addProperty ("Show Node Trajectory");
350 m_nodeBrowser->setFactoryForManager (m_boolManager, m_checkBoxFactory);
351 m_boolManager->setValue (m_showNodeTrajectoryProperty, animNode->getShowNodeTrajectory ());
352 m_nodeBrowser->addProperty (m_showNodeTrajectoryProperty);
353 connect (m_boolManager, SIGNAL(valueChanged(QtProperty*,bool)), this, SLOT(valueChangedSlot(QtProperty*,bool)));
354
355
356 // IPv4 and Mac
357 m_ipv4AddressGroupProperty = m_ipv4AddressManager->addProperty ("Ipv4 Addresses");
358 m_ipv6AddressGroupProperty = m_ipv6AddressManager->addProperty ("Ipv6 Addresses");
359
360 m_macAddressGroupProperty = m_macAddressManager->addProperty ("Mac Addresses");
361 AnimNode::Ipv4Set_t ipv4Addresses = animNode->getIpv4Addresses ();
362 for (AnimNode::Ipv4Set_t::const_iterator i = ipv4Addresses.begin ();
363 i != ipv4Addresses.end ();
364 ++i)
365 {
366 QtProperty * property = m_staticStringManager->addProperty (*i);
367 m_ipv4AddressGroupProperty->addSubProperty (property);
368 m_ipv4AddressVectorProperty.push_back (property);
369 }
370
371 AnimNode::Ipv6Set_t ipv6Addresses = animNode->getIpv6Addresses ();
372 for (AnimNode::Ipv6Set_t::const_iterator i = ipv6Addresses.begin ();
373 i != ipv6Addresses.end ();
374 ++i)
375 {
376 QtProperty * property = m_staticStringManager->addProperty (*i);
377 m_ipv6AddressGroupProperty->addSubProperty (property);
378 m_ipv6AddressVectorProperty.push_back (property);
379 }
380
381
382 AnimNode::MacVector_t macAddresses = animNode->getMacAddresses ();
383 for (AnimNode::MacVector_t::const_iterator i = macAddresses.begin ();
384 i != macAddresses.end ();
385 ++i)
386 {
387 QtProperty * property = m_staticStringManager->addProperty (*i);
388 m_macAddressGroupProperty->addSubProperty (property);
389 m_macAddressVectorProperty.push_back (property);
390 }
391 m_nodeBrowser->addProperty (m_ipv4AddressGroupProperty);
392 m_nodeBrowser->addProperty (m_ipv6AddressGroupProperty);
393 m_nodeBrowser->addProperty (m_macAddressGroupProperty);
394
395 AnimNodeMgr::CounterIdName_t doubleCounterNames = AnimNodeMgr::getInstance ()->getDoubleCounterNames ();
396 AnimNodeMgr::CounterIdName_t uint32CounterNames = AnimNodeMgr::getInstance ()->getUint32CounterNames ();
397 for (AnimNodeMgr::CounterIdName_t::const_iterator i = doubleCounterNames.begin ();
398 i != doubleCounterNames.end ();
399 ++i)
400 {
401 QString counterName = i->second;
402 bool result = false;
403 qreal counterValue = animNode->getDoubleCounterValue (i->first, result);
404 if (!result)
405 continue;
406 QtProperty * prop = m_doubleManager->addProperty (counterName);
407 m_doubleManager->setValue (prop, counterValue);
408 m_nodeBrowser->addProperty (prop);
409 m_nodeCounterDoubleProperty.push_back (prop);
410 }
411
412 for (AnimNodeMgr::CounterIdName_t::const_iterator i = uint32CounterNames.begin ();
413 i != uint32CounterNames.end ();
414 ++i)
415 {
416 QString counterName = i->second;
417 bool result = false;
418 qreal counterValue = animNode->getUint32CounterValue (i->first, result);
419 if (!result)
420 continue;
421 QtProperty * prop = m_intManager->addProperty (counterName);
422 m_intManager->setValue (prop, counterValue);
423 m_nodeBrowser->addProperty (prop);
424 m_nodeCounterUint32Property.push_back (prop);
425 }
426
427 }
428
429 void
valueChangedSlot(QtProperty * property,QColor c)430 AnimPropertyBroswer::valueChangedSlot (QtProperty * property, QColor c)
431 {
432 if (m_nodeColorProperty == property)
433 {
434 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
435 animNode->setColor (c.red (), c.green (), c.blue (), c.alpha ());
436 }
437 }
438
439 void
valueChangedSlot(QtProperty * property,double value)440 AnimPropertyBroswer::valueChangedSlot(QtProperty * property, double value)
441 {
442 if (m_nodeXProperty == property)
443 {
444 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
445 animNode->setX (value);
446 qreal x = animNode->getX ();
447 qreal y = animNode->getY ();
448 AnimatorMode::getInstance ()->setNodePos (animNode, x, y);
449 }
450 if (m_nodeYProperty == property)
451 {
452 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
453 animNode->setY (value);
454 qreal x = animNode->getX ();
455 qreal y = animNode->getY ();
456 AnimatorMode::getInstance ()->setNodePos (animNode, x, y);
457
458 }
459 if (m_nodeSizeProperty == property)
460 {
461 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
462 AnimatorMode::getInstance ()->setNodeSize (animNode, value);
463 }
464 AnimatorScene * scene = AnimatorScene ::getInstance();
465 if (m_backgroundX == property)
466 {
467 scene->setBackgroundX (value);
468 }
469 if (m_backgroundY == property)
470 {
471 scene->setBackgroundY (value);
472 }
473
474 if (m_backgroundScaleX == property)
475 {
476 scene->setBackgroundScaleX (value);
477 }
478 if (m_backgroundScaleY == property)
479 {
480 scene->setBackgroundScaleY (value);
481 }
482 if (m_backgroundOpacity == property)
483 {
484 scene->setBackgroundOpacity (value);
485 }
486 }
487
488
489 void
valueChangedSlot(QtProperty * property,QString description)490 AnimPropertyBroswer::valueChangedSlot(QtProperty * property, QString description)
491 {
492 if (m_nodeDescriptionProperty == property)
493 {
494 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
495 animNode->setNodeDescription (description);
496 }
497 if (m_fileEditProperty == property)
498 {
499 if (description == "")
500 return;
501 uint32_t newResourceId = AnimResourceManager::getInstance ()->getNewResourceId ();
502 AnimResourceManager::getInstance ()->add (newResourceId, description);
503 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
504 animNode->setResource (newResourceId);
505 }
506 }
507
508 void
modeChangedSlot(QString mode)509 AnimPropertyBroswer::modeChangedSlot (QString mode)
510 {
511 if (mode == "Node")
512 {
513 m_nodeIdSelector->setVisible (true);
514 m_nodeBrowser->setVisible (true);
515 m_nodePosTable->setVisible (true);
516 m_backgroundBrowser->setVisible (false);
517
518 }
519 else if (mode == "Background")
520 {
521 if (AnimatorScene::getInstance ()->getBackgroundImage())
522 {
523 m_nodeIdSelector->setVisible (false);
524 m_nodeBrowser->setVisible (false);
525 m_nodePosTable->setVisible (false);
526 m_backgroundBrowser->setVisible (true);
527 refreshBackgroundProperties ();
528 }
529 else
530 {
531 AnimatorMode::getInstance ()->showPopup ("No Background image set in the xml file");
532 }
533 }
534 }
535
536 void
valueChangedSlot(QtProperty * property,bool showNodeTrajectory)537 AnimPropertyBroswer::valueChangedSlot (QtProperty * property, bool showNodeTrajectory)
538 {
539 if (m_showNodeTrajectoryProperty == property)
540 {
541 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
542 animNode->setShowNodeTrajectory (showNodeTrajectory);
543 AnimatorMode::getInstance ()->setShowNodeTrajectory (animNode);
544 showNodePositionTable (showNodeTrajectory);
545 }
546 }
547
548 void
refresh()549 AnimPropertyBroswer::refresh ()
550 {
551 nodeIdSelectorSlot (m_nodeIdSelector->currentText ());
552 }
553
554
555 void
showNodePositionTable(bool show)556 AnimPropertyBroswer::showNodePositionTable (bool show)
557 {
558 m_nodePosTable->setVisible (show);
559 m_nodePosTable->clear ();
560 AnimNodeMgr::TimePosVector_t tpv = AnimNodeMgr::getInstance ()->getPositions (m_currentNodeId);
561 QStringList headerList;
562 headerList << "Time" << "X-Coord" << "Y-Coord";
563 m_nodePosTable->setHeaderList (headerList);
564 foreach (TimePosition_t tp, tpv)
565 {
566 QStringList rowStringList;
567 rowStringList << QString::number (tp.t)
568 << QString::number (tp.p.x ())
569 << QString::number (tp.p.y ());
570 m_nodePosTable->addRow (rowStringList);
571 }
572 }
573
574 void
nodeIdSelectorSlot(QString newIndex)575 AnimPropertyBroswer::nodeIdSelectorSlot (QString newIndex)
576 {
577 //NS_LOG_DEBUG (newIndex.toUInt());
578 m_currentNodeId = newIndex.toUInt ();
579
580 AnimNode * animNode = AnimNodeMgr::getInstance ()->getNode (m_currentNodeId);
581
582 // Node Id
583 m_intManager->setValue (m_nodeIdProperty, m_currentNodeId);
584
585
586 if (!animNode)
587 return;
588
589 // Node System Id
590 m_intManager->setValue (m_nodeSysIdProperty, animNode->getNodeSysId ());
591
592
593 // Node Description
594 m_stringManager->setValue (m_nodeDescriptionProperty, animNode->getDescription ()->toPlainText ());
595
596
597 // Node Position
598 m_doubleManager->setValue (m_nodeXProperty, animNode->getX ());
599 m_doubleManager->setValue (m_nodeYProperty, animNode->getY ());
600
601
602 // Node Color
603 QColor c = animNode->getColor ();
604 m_colorManager->setValue (m_nodeColorProperty, c);
605
606
607 // Node Size
608 m_doubleManager->setValue (m_nodeSizeProperty, animNode->getWidth ());
609 m_doubleManager->setMinimum (m_nodeSizeProperty, 0.1);
610
611
612 // Node Resource
613 int resourceId = animNode->getResourceId ();
614 QString resourcePath = "";
615 if (resourceId != -1)
616 {
617 resourcePath = AnimResourceManager::getInstance ()->get (resourceId);
618 }
619 m_filePathManager->setValue (m_fileEditProperty, resourcePath);
620
621
622 m_boolManager->setValue (m_showNodeTrajectoryProperty, animNode->getShowNodeTrajectory ());
623 AnimatorMode::getInstance ()->setShowNodeTrajectory (animNode);
624
625
626 // IPv4 and Mac
627 AnimNode::Ipv4Set_t ipv4Addresses = animNode->getIpv4Addresses ();
628 for (AnimPropertyBroswer::QtPropertyVector_t::const_iterator i = m_ipv4AddressVectorProperty.begin ();
629 i != m_ipv4AddressVectorProperty.end ();
630 ++i)
631 {
632 QtProperty * property = *i;
633 m_ipv4AddressGroupProperty->removeSubProperty (property);
634 }
635 m_ipv4AddressVectorProperty.clear ();
636 for (AnimNode::Ipv4Set_t::const_iterator i = ipv4Addresses.begin ();
637 i != ipv4Addresses.end ();
638 ++i)
639 {
640 QtProperty * property = m_staticStringManager->addProperty (*i);
641 m_ipv4AddressGroupProperty->addSubProperty (property);
642 m_ipv4AddressVectorProperty.push_back (property);
643 }
644 AnimNode::Ipv6Set_t ipv6Addresses = animNode->getIpv6Addresses ();
645 for (AnimPropertyBroswer::QtPropertyVector_t::const_iterator i = m_ipv6AddressVectorProperty.begin ();
646 i != m_ipv6AddressVectorProperty.end ();
647 ++i)
648 {
649 QtProperty * property = *i;
650 m_ipv6AddressGroupProperty->removeSubProperty (property);
651 }
652 m_ipv6AddressVectorProperty.clear ();
653 for (AnimNode::Ipv6Set_t::const_iterator i = ipv6Addresses.begin ();
654 i != ipv6Addresses.end ();
655 ++i)
656 {
657 QtProperty * property = m_staticStringManager->addProperty (*i);
658 m_ipv6AddressGroupProperty->addSubProperty (property);
659 m_ipv6AddressVectorProperty.push_back (property);
660 }
661 AnimNode::MacVector_t macAddresses = animNode->getMacAddresses ();
662
663 for (AnimPropertyBroswer::QtPropertyVector_t::const_iterator i = m_macAddressVectorProperty.begin ();
664 i != m_macAddressVectorProperty.end ();
665 ++i)
666 {
667 QtProperty * property = *i;
668 m_macAddressGroupProperty->removeSubProperty (property);
669 }
670 m_macAddressVectorProperty.clear ();
671
672 for (AnimNode::MacVector_t::const_iterator i = macAddresses.begin ();
673 i != macAddresses.end ();
674 ++i)
675 {
676 QtProperty * property = m_staticStringManager->addProperty (*i);
677 m_macAddressGroupProperty->addSubProperty (property);
678 m_macAddressVectorProperty.push_back (property);
679 }
680
681
682 for (AnimPropertyBroswer::QtPropertyVector_t::const_iterator i = m_nodeCounterDoubleProperty.begin ();
683 i != m_nodeCounterDoubleProperty.end ();
684 ++i)
685 {
686 QtProperty * property = *i;
687 m_nodeBrowser->removeProperty (property);
688 }
689 m_nodeCounterDoubleProperty.clear ();
690
691 for (AnimPropertyBroswer::QtPropertyVector_t::const_iterator i = m_nodeCounterUint32Property.begin ();
692 i != m_nodeCounterUint32Property.end ();
693 ++i)
694 {
695 QtProperty * property = *i;
696 m_nodeBrowser->removeProperty (property);
697 }
698 m_nodeCounterUint32Property.clear ();
699 AnimNodeMgr::CounterIdName_t doubleCounterNames = AnimNodeMgr::getInstance ()->getDoubleCounterNames ();
700 AnimNodeMgr::CounterIdName_t uint32CounterNames = AnimNodeMgr::getInstance ()->getUint32CounterNames ();
701 for (AnimNodeMgr::CounterIdName_t::const_iterator i = doubleCounterNames.begin ();
702 i != doubleCounterNames.end ();
703 ++i)
704 {
705 QString counterName = i->second;
706 bool result = false;
707 qreal counterValue = animNode->getDoubleCounterValue (i->first, result);
708 if (!result)
709 continue;
710 QtProperty * prop = m_doubleManager->addProperty (counterName);
711 m_doubleManager->setValue (prop, counterValue);
712 m_nodeBrowser->addProperty (prop);
713 m_nodeCounterDoubleProperty.push_back (prop);
714 }
715
716 for (AnimNodeMgr::CounterIdName_t::const_iterator i = uint32CounterNames.begin ();
717 i != uint32CounterNames.end ();
718 ++i)
719 {
720 QString counterName = i->second;
721 bool result = false;
722 qreal counterValue = animNode->getUint32CounterValue (i->first, result);
723 if (!result)
724 continue;
725 QtProperty * prop = m_intManager->addProperty (counterName);
726 m_intManager->setValue (prop, counterValue);
727 m_nodeBrowser->addProperty (prop);
728 m_nodeCounterUint32Property.push_back (prop);
729 }
730
731 }
732
733
734 } // namespace netanim
735