Logo Search packages:      
Sourcecode: caret version File versions  Download package

void GuiDisplayControlDialog::createAndUpdateModelsMainPage (  )  [private]

create and update the models main page

create and update the models main page as models added/deleted

Definition at line 11285 of file GuiDisplayControlDialog.cxx.

References FileUtilities::basename(), FileUtilities::filenameWithoutExtension(), AbstractFile::getAssociatedTransformationMatrix(), VtkModelFile::getDisplayFlag(), AbstractFile::getFileName(), TransformationMatrixFile::getMatrixIndex(), modelCheckBoxes, modelSelectionGridWidgetLayout, modelsSubPageMainLayout, modelTransformControls, numValidModels, readModelMainPage(), and GuiTransformationMatrixSelectionControl::setSelectedMatrix().

Referenced by createModelsMainPage(), and updateModelMainPage().

{
   numValidModels = theMainWindow->getBrainSet()->getNumberOfVtkModelFiles();
   
   const int numExistingModels = static_cast<int>(modelCheckBoxes.size());
   
   if (modelSelectionGridWidgetLayout == NULL) {
      QWidget* modelsWidget = new QWidget;
      modelSelectionGridWidgetLayout = new QGridLayout(modelsWidget);
      
      modelSelectionGridWidgetLayout->addWidget(new QLabel("Model"), 0, 0);
      modelSelectionGridWidgetLayout->addWidget(new QLabel("  Transform"), 0, 1);
      modelSelectionGridWidgetLayout->addWidget(new QLabel(""), 0, 2);
      const int rowStretchNumber = 15000;
      modelSelectionGridWidgetLayout->addWidget(new QLabel(""), rowStretchNumber, 0);
      modelSelectionGridWidgetLayout->setRowStretch(rowStretchNumber, 1000);
      modelSelectionGridWidgetLayout->setColumnStretch(0, 1);
      modelSelectionGridWidgetLayout->setColumnStretch(1, 1);
      modelSelectionGridWidgetLayout->setColumnStretch(2, 100);
      
      modelsSubPageMainLayout->addWidget(modelsWidget);
   }
   
   //
   // Add row of checkbox and transform matrix selection 
   //
   for (int i = numExistingModels; i < numValidModels; i++) {
      QCheckBox* cb = new QCheckBox("adding");
      modelCheckBoxes.push_back(cb);
      QObject::connect(cb, SIGNAL(toggled(bool)),
                       this, SLOT(readModelMainPage()));
      GuiTransformationMatrixSelectionControl* msc = new
           GuiTransformationMatrixSelectionControl(0,
                                                   theMainWindow->getBrainSet()->getTransformationMatrixFile(),
                                                   true);
      
      const VtkModelFile* vmf = theMainWindow->getBrainSet()->getVtkModelFile(i);
      const TransformationMatrix* tm = vmf->getAssociatedTransformationMatrix();
      msc->setSelectedMatrix(tm);
      modelTransformControls.push_back(msc);
      QObject::connect(msc, SIGNAL(activated(int)),
                       this, SLOT(readModelMainPage()));
                       
      modelSelectionGridWidgetLayout->addWidget(cb, i + 1, 0, 1, 1, Qt::AlignLeft);
      modelSelectionGridWidgetLayout->addWidget(msc, i + 1, 1, 1, 1, Qt::AlignLeft);
   }
   
   //
   // update items already in dialog
   //
   TransformationMatrixFile* tmf = theMainWindow->getBrainSet()->getTransformationMatrixFile();
   for (int i = 0; i < numValidModels; i++) {
      VtkModelFile* vmf = theMainWindow->getBrainSet()->getVtkModelFile(i);
      const TransformationMatrix* tm = vmf->getAssociatedTransformationMatrix();
      const QString name(FileUtilities::basename(
                              FileUtilities::filenameWithoutExtension(vmf->getFileName())));
      modelCheckBoxes[i]->blockSignals(true);
      modelCheckBoxes[i]->setText(name);
      modelCheckBoxes[i]->show();
      modelCheckBoxes[i]->setChecked(vmf->getDisplayFlag());
      modelCheckBoxes[i]->blockSignals(false);
      modelTransformControls[i]->blockSignals(true);
      modelTransformControls[i]->updateControl();
      modelTransformControls[i]->setSelectedMatrixIndex(tmf->getMatrixIndex(tm));
      modelTransformControls[i]->show();
      modelTransformControls[i]->blockSignals(false);
   }
   
   //
   // Hide widgets that are not needed
   //
   for (int i = numValidModels; i < numExistingModels; i++) {
      modelCheckBoxes[i]->hide();
      modelTransformControls[i]->hide();
   }
}


Generated by  Doxygen 1.6.0   Back to index