Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ToolboxGui.cc
1 
5 #include "AlignPlugin.hh"
6 
8 {
9  sourceMeshCombo_ = new QComboBox;
10  sourceMeshCombo_->setModel(&sourceMeshList_);
11  connect(sourceMeshCombo_, SIGNAL(currentIndexChanged(int)),
12  this, SLOT(slotSourceMeshChanged(int)));
13 
14  targetMeshCombo_ = new QComboBox;
15  targetMeshCombo_->setModel(&targetMeshList_);
16  connect(targetMeshCombo_, SIGNAL(currentIndexChanged(int)),
17  this, SLOT(slotTargetMeshChanged(int)));
18 
19  doScaleCheckBox_ = new QCheckBox(tr("Scale to target's bounding box"));
20  doScaleCheckBox_->setChecked(true);
21 
22  alignMeshesButton_ = new QPushButton(tr("Align meshes"));
23  connect(alignMeshesButton_, SIGNAL(clicked()),
24  this, SLOT(slotAlignMeshes()));
25 
26  QFormLayout *layout = new QFormLayout;
27  layout->addRow(new QLabel("Source mesh"), sourceMeshCombo_);
28  layout->addRow(new QLabel("Target mesh"), targetMeshCombo_);
29  layout->addRow(doScaleCheckBox_);
30  layout->addRow(alignMeshesButton_);
31 
32  QWidget *toolbox = new QWidget;
33  toolbox->setLayout(layout);
34 
35  updateGui();
36 
37  emit addToolbox(tr("Align"), toolbox, NULL);
38 }
39 
40 void AlignPlugin::pluginsInitialized()
41 {
42 }
43 
44 void AlignPlugin::slotSourceMeshChanged(int objectId)
45 {
46  sourceId_ = sourceMeshCombo_->itemData(sourceMeshCombo_->currentIndex()).toInt();
47  updateGui();
48 }
49 
50 void AlignPlugin::slotTargetMeshChanged(int objectId)
51 {
52  targetId_ = targetMeshCombo_->itemData(targetMeshCombo_->currentIndex()).toInt();
53  updateGui();
54 }
55 
56 void AlignPlugin::slotObjectSelectionChanged(int)
57 {
58  sourceMeshList_.refresh();
59  targetMeshList_.refresh();
60  updateGui();
61 }
62 
63 void AlignPlugin::slotObjectUpdated(int, UpdateType const&)
64 {
65  sourceMeshList_.refresh();
66  targetMeshList_.refresh();
67  updateGui();
68 }
69 
70 void AlignPlugin::objectDeleted(int objectId)
71 {
72  sourceMeshList_.removeObject(objectId);
73  targetMeshList_.removeObject(objectId);
74 
75  if (objectId == sourceId_) {
76  sourceId_ = -1;
77  sourceMeshCombo_->setCurrentIndex(-1);
78  }
79 
80  if (objectId == targetId_) {
81  targetId_ = -1;
82  targetMeshCombo_->setCurrentIndex(-1);
83  }
84 
85  updateGui();
86 }
87 
88 void AlignPlugin::updateGui()
89 {
90  alignMeshesButton_->setEnabled(sourceId_ != -1 && targetId_ != -1);
91 }
Update type class.
Definition: UpdateType.hh:70
void initializePlugin()
Definition: ToolboxGui.cc:7