Ejemplo n.º 1
0
void QmitkPointListWidget::SetupConnections()
{
  connect(this->m_LoadPointsBtn, SIGNAL(clicked()), this, SLOT(OnBtnLoadPoints()));
  connect(this->m_SavePointsBtn, SIGNAL(clicked()), this, SLOT(OnBtnSavePoints()));
  connect(this->m_MovePointUpBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointUp()));
  connect(this->m_MovePointDownBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointDown()));
  connect(this->m_RemovePointBtn, SIGNAL(clicked()), this, SLOT(RemoveSelectedPoint()));
  connect(this->m_ToggleAddPoint, SIGNAL(toggled(bool)), this, SLOT(OnBtnAddPoint(bool)));
  connect(this->m_AddPoint, SIGNAL(clicked()), this, SLOT(OnBtnAddPointManually()));
  connect(this->m_PointListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(OnListDoubleClick()));
  connect(this->m_PointListView, SIGNAL(SignalPointSelectionChanged()), this, SLOT(OnPointSelectionChanged()));
}
void QmitkCorrespondingPointSetsView::ctxMenu(const QPoint &pos)
{
  QMenu *menu = new QMenu;
  int x = pos.x();
  int y = pos.y();

  int row = QTableView::rowAt(y);
  int col = QTableView::columnAt(x);

  int numNodes = this->GetPointSetNodes().size();

  //add delete point action
  mitk::PointSet::PointsContainer::ElementIdentifier id;
  mitk::PointSet::PointType p;
  bool pointSelected = m_CorrespondingPointSetsModel->GetPointForModelIndex(row, col, p, id);

  QAction *movePointUp = new QAction(this);
  movePointUp->setText("Move point up");
  connect(movePointUp, SIGNAL(triggered()), this, SLOT(MoveSelectedPointUp()));
  if(!pointSelected)
    movePointUp->setEnabled(false);
  menu->addAction(movePointUp);

  QAction *movePointDown = new QAction(this);
  movePointDown->setText("Move point down");
  connect(movePointDown, SIGNAL(triggered()), this, SLOT(MoveSelectedPointDown()));
  if(!pointSelected)
    movePointDown->setEnabled(false);
  menu->addAction(movePointDown);

  QAction *delPoint = new QAction(this);
  delPoint->setText("Delete point");
  connect(delPoint, SIGNAL(triggered()), this, SLOT(RemoveSelectedPoint()));
  if(!pointSelected)
    delPoint->setEnabled(false);
  menu->addAction(delPoint);

  QAction *separator = new QAction(this);
  separator->setSeparator(true);

  menu->addSeparator();

  QAction *clearTS = new QAction(this);
  clearTS->setText("Clear time step");
  connect(clearTS, SIGNAL(triggered()), this, SLOT(ClearCurrentTimeStep()));
  if(numNodes==0 || col!=0 && col!=1)
    clearTS->setEnabled(false);
  menu->addAction(clearTS);

  QAction *clearList = new QAction(this);
  clearList->setText("Clear point set");
  connect(clearList, SIGNAL(triggered()), this, SLOT(ClearSelectedPointSet()));
  if(numNodes==0 || col!=0 && col!=1)
    clearList->setEnabled(false);
  menu->addAction(clearList);

  menu->addSeparator();

  QAction *swapSets = new QAction(this);
  swapSets->setText("Swap point sets");
  connect(swapSets, SIGNAL(triggered(bool)), this, SLOT(SwapPointSets(bool)));
  swapSets->setCheckable(true);
  swapSets->setChecked(m_swapPointSets);
  if (numNodes<2)
    swapSets->setEnabled(false);
  menu->addAction(swapSets);

  QAction *addPoints = new QAction(this);
  addPoints->setText("Check to add new points");
  connect(addPoints, SIGNAL(triggered(bool)), this, SLOT(AddPointsMode(bool)));
  addPoints->setCheckable(true);
  addPoints->setChecked(m_addPointsMode);
  if (numNodes==0)
    addPoints->setEnabled(false);
  menu->addAction(addPoints);

  QAction *addPointSet = new QAction(this);
  addPointSet->setText("Create new point set");
  connect(addPointSet, SIGNAL(triggered()), this, SLOT(AddPointSet()));
  if (!m_DataStorage)
    addPointSet->setEnabled(false);
  menu->addAction(addPointSet);

  menu->exec(this->mapToGlobal(pos));
}
void QmitkCorrespondingPointSetsWidget::SetupUi()
{
  QBoxLayout* lay1 = new QVBoxLayout(this);

  // add status bar buttons
  if (QTPropShowButtonBar)
  {
    QBoxLayout* lay2 = new QHBoxLayout();
    lay1->addLayout(lay2);
    lay2->stretch(true);

    QStatusBar* statusBar = new QStatusBar(this);
    statusBar->setMaximumHeight(25);

    m_CreatePointSetBtn = new QToolButton();
    m_CreatePointSetBtn->setAutoRaise(true);
    m_CreatePointSetBtn->setIcon(QIcon(":/QtWidgetsExt/btnAddPointSet.png"));
    m_CreatePointSetBtn->setToolTip(QString("Create new point set"));
    connect(this->m_CreatePointSetBtn, SIGNAL(clicked()), this, SLOT(AddPointSet()));
    statusBar->addWidget(m_CreatePointSetBtn);

    m_AddPointsBtn = new QToolButton();
    m_AddPointsBtn->setAutoRaise(true);
    m_AddPointsBtn->setIcon(QIcon(":/QtWidgetsExt/btnSetPoints.png"));
    m_AddPointsBtn->setToolTip(QString("Check to add new points (shift-click)"));
    m_AddPointsBtn->setCheckable(true);
    connect(this->m_AddPointsBtn, SIGNAL(clicked(bool)), this, SLOT(AddPointsMode(bool)));
    statusBar->addWidget(m_AddPointsBtn);

    m_MovePointUpBtn = new QToolButton();
    m_MovePointUpBtn->setAutoRaise(true);
    m_MovePointUpBtn->setIcon(QIcon(":/QtWidgetsExt/btnMoveUp.png"));
    m_MovePointUpBtn->setToolTip(QString("Move selected point up"));
    connect(this->m_MovePointUpBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointUp()));
    statusBar->addWidget(m_MovePointUpBtn);

    m_MovePointDownBtn = new QToolButton();
    m_MovePointDownBtn->setAutoRaise(true);
    m_MovePointDownBtn->setIcon(QIcon(":/QtWidgetsExt/btnMoveDown.png"));
    m_MovePointDownBtn->setToolTip(QString("Move selected point down"));
    connect(this->m_MovePointDownBtn, SIGNAL(clicked()), this, SLOT(MoveSelectedPointDown()));
    statusBar->addWidget(m_MovePointDownBtn);

    m_RemovePointBtn = new QToolButton();
    m_RemovePointBtn->setAutoRaise(true);
    m_RemovePointBtn->setIcon(QIcon(":/QtWidgetsExt/btnRemovePoint.png"));
    m_RemovePointBtn->setToolTip(QString("Remove selected point"));
    connect(this->m_RemovePointBtn, SIGNAL(clicked()), this, SLOT(RemoveSelectedPoint()));
    statusBar->addWidget(m_RemovePointBtn);

    m_SwapSetsBtn = new QToolButton();
    m_SwapSetsBtn->setAutoRaise(true);
    m_SwapSetsBtn->setIcon(QIcon(":/QtWidgetsExt/btnSwapSets.png"));
    m_SwapSetsBtn->setToolTip(QString("Swap the two selected point sets"));
    m_SwapSetsBtn->setCheckable(true);
    connect(this->m_SwapSetsBtn, SIGNAL(clicked(bool)), this, SLOT(SwapPointSets(bool)));
    statusBar->addWidget(m_SwapSetsBtn);

    // disable buttons
    m_MovePointUpBtn->setEnabled(false);
    m_MovePointDownBtn->setEnabled(false);
    m_RemovePointBtn->setEnabled(false);
    m_SwapSetsBtn->setEnabled(false);
    m_AddPointsBtn->setEnabled(false);

    lay2->addWidget(statusBar);
  }

  lay1->insertWidget(0,m_CorrespondingPointSetsView);
  this->setLayout(lay1);
}