Example #1
0
QAction* ActionResource::toQAction() const {
    Log log( Log::LT_TRACE, Log::MOD_MAIN, "QAction* ActionResource::toQAction() const" );

    if( !( m_Type == AT_ITEM || m_Type == AT_SEPARATOR ) ) {
        return NULL;
    };

    log.write( Log::LT_TRACE, "Produce item %s", getText() );
    QAction* act = new QAction( getText(), NULL );
    act->setAutoRepeat( getAutoRepeat() );
    act->setCheckable( getCheckable() );
    act->setChecked( getChecked() );
    act->setData( getData() );
    act->setFont( getFont() );
    act->setIcon( getIcon() );
    act->setIconVisibleInMenu( getIconVisibleInMenu() );
    act->setMenuRole( getMenuRole() );
    act->setSeparator( m_Type == AT_SEPARATOR );
    act->setShortcut( getShortcut() );
    act->setShortcutContext( getShortcutContext() );
    act->setStatusTip( getStatusTip() );
    act->setToolTip( getTooltip() );
    act->setVisible( getVisible() );
    act->setWhatsThis( getWhatsThis() );

    return act;
};
AnnotationImagePaletteWidget::AnnotationImagePaletteWidget(QWidget* pParent) : QToolBox(pParent)
{
   mDesktopAttachments.addSignal(SIGNAL_NAME(DesktopServices, WindowAdded),
      Slot(this, &AnnotationImagePaletteWidget::windowAdded));
   mDesktopAttachments.addSignal(SIGNAL_NAME(DesktopServices, WindowRemoved),
      Slot(this, &AnnotationImagePaletteWidget::windowRemoved));
   mDesktopAttachments.reset(Service<DesktopServices>().get());
   std::vector<Window*> windows;
   Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows);
   for (std::vector<Window*>::iterator window = windows.begin(); window != windows.end(); ++window)
   {
      SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(*window);
      if (pWindow != NULL)
      {
         pWindow->getWidget()->installEventFilter(this);
         pWindow->getWidget()->setAcceptDrops(true);
         mWindows.insert(pWindow);
      }
   }
   setContextMenuPolicy(Qt::ActionsContextMenu);
   QAction* pRefreshAction = new QAction("Refresh", this);
   pRefreshAction->setAutoRepeat(false);
   addAction(pRefreshAction);
   VERIFYNR(connect(pRefreshAction, SIGNAL(triggered()), this, SLOT(refresh())));

   setMinimumHeight(50);
}
QAction* RangeProfilePlotManager::createAction()
{
   QAction* pWindowAction = NULL;
   // Add a menu command to invoke the window
   MenuBar* pMenuBar = Service<DesktopServices>()->getMainMenuBar();
   if (pMenuBar != NULL)
   {
      QAction* pBeforeAction = NULL;
      QAction* pToolsAction = pMenuBar->getMenuItem("&Tools");
      if (pToolsAction != NULL)
      {
         QMenu* pMenu = pToolsAction->menu();
         if (pMenu != NULL)
         {
            QList<QAction*> actions = pMenu->actions();
            for (int i = 0; i < actions.count(); ++i)
            {
               QAction* pAction = actions[i];
               if (pAction != NULL)
               {
                  if ((pAction->text() == "S&cripting Window") && (pAction != actions.back()))
                  {
                     pBeforeAction = actions[i + 1];
                     break;
                  }
               }
            }
         }
      }

      pWindowAction = pMenuBar->addCommand("&Tools/&" + getName(), getName(), pBeforeAction);
      if (pWindowAction != NULL)
      {
         pWindowAction->setAutoRepeat(false);
         pWindowAction->setCheckable(true);
         pWindowAction->setToolTip(QString::fromStdString(getName()));
         pWindowAction->setStatusTip("Toggles the display of the " + QString::fromStdString(getName()));
      }
   }
   return pWindowAction;
}
Example #4
0
OverviewWindow::OverviewWindow(SpatialDataViewImp* pView, QWidget* parent) :
   QDialog(parent),
   mpView(pView),
   mpOverview(NULL),
   mpSelectionWidget(NULL),
   mpTrailLayer(NULL),
   mpTrail(NULL),
   mZoomThreshold(100)
{
   // get trail defaults from ConfigurationSettings
   mTrailColor = SpatialDataWindow::getSettingOverviewTrailColor();
   mZoomThreshold = SpatialDataWindow::getSettingOverviewTrailThreshold();

   // View widget
   mpOverview = createOverview();
   mpSelectionWidget = new ZoomPanWidget(mpOverview, this);

   // Overview trail object
   mpTrail = createSnailTrail(mpOverview);

   // Context menu
   Service<DesktopServices> pDesktop;
   string shortcutContext = "Overview Window";

   QAction* pClearAction = new QAction("Clear the Trail", this);
   pClearAction->setAutoRepeat(false);
   pDesktop->initializeAction(pClearAction, shortcutContext);
   addAction(pClearAction);

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

   QAction* pColorAction = new QAction("Change Trail color...", this);
   pColorAction->setAutoRepeat(false);
   pDesktop->initializeAction(pColorAction, shortcutContext);
   addAction(pColorAction);

   QAction* pOpacityAction = new QAction("Change Trail opacity...", this);
   pOpacityAction->setAutoRepeat(false);
   pDesktop->initializeAction(pOpacityAction, shortcutContext);
   addAction(pOpacityAction);

   QAction* pThresholdAction = new QAction("Change zoom threshold...", this);
   pThresholdAction->setAutoRepeat(false);
   pDesktop->initializeAction(pThresholdAction, shortcutContext);
   addAction(pThresholdAction);

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

   QAction* pSnapshotAction = new QAction("Take a snapshot", this);
   pSnapshotAction->setAutoRepeat(false);
   pSnapshotAction->setShortcut(QKeySequence("Ctrl+Shift+C"));
   pSnapshotAction->setToolTip("Take a snapshot");
   pSnapshotAction->setStatusTip("Copies a snapshot of the view into the clipboard");
   addAction(pSnapshotAction);

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(0);
   pLayout->setSpacing(0);
   pLayout->addWidget(mpSelectionWidget, 10);

   // Initialization
   setModal(false);
   setContextMenuPolicy(Qt::DefaultContextMenu);
   setMinimumSize(200, 200);
   int maxWidth = 400;
   int maxHeight = 400;
   setMaximumSize(maxWidth, maxHeight);
   updateSelectionBox();

   if (mpTrail != NULL)
   {
      mpTrail->setStencilBufferSize(maxWidth, maxHeight);
   }

   const std::vector<LocationType> selectionBox = mpSelectionWidget->getSelection();
   updateView(selectionBox);

   // Set the window icon
   if (mpView != NULL)
   {
      QIcon viewIcon = mpView->windowIcon();
      if (viewIcon.isNull() == false)
      {
         setWindowIcon(viewIcon);
      }
   }

   // Set the caption of the dialog
   QString strCaption = "Overview";
   if (mpView != NULL)
   {
      QString strName = QString::fromStdString(mpView->getName());
      if (strName.isEmpty() == false)
      {
         QFileInfo fileInfo(strName);
         QString strFilename = fileInfo.fileName();
         if (strFilename.isEmpty() == false)
         {
            strCaption += ": " + strFilename;
         }
      }
   }

   setWindowTitle(strCaption);

   // Connections
   VERIFYNR(connect(mpSelectionWidget, SIGNAL(selectionChanged(const std::vector<LocationType>&)), this,
      SLOT(updateView(const std::vector<LocationType>&))));
   VERIFYNR(connect(mpView, SIGNAL(displayAreaChanged()), this, SLOT(updateSelectionBox())));
   VERIFYNR(connect(pClearAction, SIGNAL(triggered()), this, SLOT(clearTrail())));
   VERIFYNR(connect(pColorAction, SIGNAL(triggered()), this, SLOT(changeTrailColor())));
   VERIFYNR(connect(pOpacityAction, SIGNAL(triggered()), this, SLOT(changeTrailOpacity())));
   VERIFYNR(connect(pThresholdAction, SIGNAL(triggered()), this, SLOT(changeTrailThreshold())));
   VERIFYNR(connect(pSnapshotAction, SIGNAL(triggered()), this, SLOT(takeSnapshot())));
}
void SpectralLibraryMatchResults::updateContextMenu(Subject& subject, const std::string& signal,
                                                    const boost::any& value)
{
   ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value);
   if (pMenu == NULL)
   {
      return;
   }

   // only add actions if there are some results
   if (mpTabWidget->count() > 0)
   {
      bool isSessionItem(false);
      if (dynamic_cast<SessionExplorer*>(&subject) != NULL)
      {
         std::vector<SessionItem*> items = pMenu->getSessionItems();
         if (items.size() > 1)                                        // make sure only one item selected
         {
            return;
         }
         DockWindow* pWindow = getDockWindow();
         if (items.front() != pWindow)                             // make sure it's the results window
         {
            return;
         }
         isSessionItem = true;
      }

      QObject* pParent = pMenu->getActionParent();

      // add separator
      QAction* pSeparatorAction = new QAction(pParent);
      pSeparatorAction->setSeparator(true);
      pMenu->addAction(pSeparatorAction, SPECTRAL_LIBRARY_MATCH_RESULTS_SEPARATOR_ACTION);

      QAction* pClearAction = new QAction("&Clear", pParent);
      pClearAction->setAutoRepeat(false);
      pClearAction->setStatusTip("Clears the results from the current page");
      VERIFYNR(connect(pClearAction, SIGNAL(triggered()), this, SLOT(clearPage())));
      pMenu->addAction(pClearAction, SPECTRAL_LIBRARY_MATCH_RESULTS_CLEAR_RESULTS_ACTION);

      QAction* pAutoClearAction = new QAction("&AutoClear", pParent);
      pAutoClearAction->setAutoRepeat(false);
      pAutoClearAction->setCheckable(true);
      pAutoClearAction->setStatusTip("Enable/disable clearing existing results before adding new results");
      ResultsPage* pPage = dynamic_cast<ResultsPage*>(mpTabWidget->currentWidget());
      if (pPage != NULL)
      {
         pAutoClearAction->setChecked(pPage->getAutoClear());
         VERIFYNR(connect(pAutoClearAction, SIGNAL(toggled(bool)), pPage, SLOT(setAutoClear(bool))));
         pMenu->addAction(pAutoClearAction, SPECTRAL_LIBRARY_MATCH_RESULTS_AUTOCLEAR_ACTION);
      }

      QAction* pExpandAllAction = new QAction("&Expand All", pParent);
      pExpandAllAction->setAutoRepeat(false);
      pExpandAllAction->setStatusTip("Expands all the results nodes on the current page");
      VERIFYNR(connect(pExpandAllAction, SIGNAL(triggered()), this, SLOT(expandAllPage())));
      pMenu->addAction(pExpandAllAction, SPECTRAL_LIBRARY_MATCH_RESULTS_EXPAND_ALL_ACTION);

      QAction* pCollapseAllAction = new QAction("&Collapse All", pParent);
      pCollapseAllAction->setAutoRepeat(false);
      pCollapseAllAction->setStatusTip("Collapses all the results nodes on the current page");
      VERIFYNR(connect(pCollapseAllAction, SIGNAL(triggered()), this, SLOT(collapseAllPage())));
      pMenu->addAction(pCollapseAllAction, SPECTRAL_LIBRARY_MATCH_RESULTS_COLLAPSE_ALL_ACTION);

      QAction* pDeleteTabAction = new QAction("&Delete Page", pParent);
      pDeleteTabAction->setAutoRepeat(false);
      pDeleteTabAction->setStatusTip("Deletes the current page");
      VERIFYNR(connect(pDeleteTabAction, SIGNAL(triggered()), this, SLOT(deletePage())));
      pMenu->addAction(pDeleteTabAction, SPECTRAL_LIBRARY_MATCH_RESULTS_DELETE_PAGE_ACTION);

      if (isSessionItem == false)
      {
         QAction* pLocateAction = new QAction("&Locate Signatures", pParent);
         pLocateAction->setAutoRepeat(false);
         pLocateAction->setStatusTip("Locates the selected Signatures in the spatial data view");
         VERIFYNR(connect(pLocateAction, SIGNAL(triggered()), this, SLOT(locateSignaturesInScene())));
         pMenu->addAction(pLocateAction, SPECTRAL_LIBRARY_MATCH_RESULTS_LOCATE_ACTION);
         QAction* pCreateAverageAction = new QAction("&Create average Signature", pParent);
         pCreateAverageAction->setAutoRepeat(false);
         pCreateAverageAction->setStatusTip("Creates an average Signature from the selected "
            "Signatures in the spatial data view");
         VERIFYNR(connect(pCreateAverageAction, SIGNAL(triggered()), this, SLOT(createAverageSignature())));
         pMenu->addAction(pCreateAverageAction, SPECTRAL_LIBRARY_MATCH_RESULTS_CREATE_AVERAGE_ACTION);
      }
   }
}
Example #6
0
void PlotSetImp::updateContextMenu(Subject& subject, const string& signal, const boost::any& value)
{
   ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value);
   if (pMenu == NULL)
   {
      return;
   }

   QObject* pParent = pMenu->getActionParent();
   vector<SessionItem*> items = pMenu->getSessionItems();

   if (items.empty() == true)
   {
      return;
   }

   bool bAddSeparator = false;
   bool bAddActivate = false;
   bool bAddDelete = false;
   string afterId;

   vector<DockWindow*> windowItems = pMenu->getSessionItems<DockWindow>();
   if (windowItems.size() == 1)
   {
      DockWindow* pDockWindow = windowItems.front();
      if (pDockWindow != NULL)
      {
         PlotSetGroup* pPlotSetGroup = dynamic_cast<PlotSetGroup*>(pDockWindow->getWidget());
         if (pPlotSetGroup != NULL)
         {
            if (dynamic_cast<PlotSetImp*>(pPlotSetGroup->getCurrentPlotSet()) == this)
            {
               bAddSeparator = true;
               bAddDelete = true;
            }
         }
      }
   }
   else if (dynamic_cast<SessionExplorer*>(&subject) != NULL)
   {
      // Make sure all of the selected session items for the menu are plot widgets
      vector<PlotWidget*> plots = pMenu->getSessionItems<PlotWidget>();
      if (plots.size() != items.size())
      {
         return;
      }

      // Make sure all selected plot widget items are contained in this plot set
      vector<PlotWidget*>::iterator iter;
      for (iter = plots.begin(); iter != plots.end(); ++iter)
      {
         PlotWidget* pPlot = *iter;
         if (pPlot != NULL)
         {
            if (containsPlot(pPlot) == false)
            {
               return;
            }
         }
      }

      // Check for only one selected plot widget item
      if (plots.size() == 1)
      {
         bAddSeparator = true;

         // Add an activate action if the selected plot widget is not currently active
         PlotWidget* pPlot = plots.front();
         if (pPlot != NULL)
         {
            if (pPlot != getCurrentPlot())
            {
               bAddActivate = true;
            }
         }
      }

      bAddDelete = true;
      afterId = APP_PLOTWIDGET_PRINT_ACTION;
   }

   // Separator
   if (bAddSeparator == true)
   {
      QAction* pSeparatorAction = new QAction(pParent);
      pSeparatorAction->setSeparator(true);
      pMenu->addActionAfter(pSeparatorAction, APP_PLOTSET_SEPARATOR_ACTION, afterId);

      if (afterId.empty() == false)
      {
         afterId = APP_PLOTSET_SEPARATOR_ACTION;
      }
   }

   // Activate
   if (bAddActivate == true)
   {
      QAction* pActivateAction = new QAction("&Activate", pParent);
      pActivateAction->setAutoRepeat(false);
      pActivateAction->setStatusTip("Activates the selected plot in the plot set");
      VERIFYNR(connect(pActivateAction, SIGNAL(triggered()), this, SLOT(activateSelectedPlot())));
      pMenu->addActionAfter(pActivateAction, APP_PLOTSET_ACTIVATE_ACTION, afterId);

      if (afterId.empty() == false)
      {
         afterId = APP_PLOTSET_ACTIVATE_ACTION;
      }
   }

   // Delete
   if (bAddDelete == true)
   {
      QAction* pDeleteAction = new QAction(QIcon(":/icons/Delete"), "&Delete", pParent);
      pDeleteAction->setAutoRepeat(false);
      VERIFYNR(connect(pDeleteAction, SIGNAL(triggered()), this, SLOT(destroyCurrentPlot())));
      pMenu->addActionAfter(pDeleteAction, APP_PLOTSET_DELETE_ACTION, afterId);
   }
}
Example #7
0
void QActionProto::setAutoRepeat(bool b)
{
  QAction *item = qscriptvalue_cast<QAction*>(thisObject());
  if (item)
    item->setAutoRepeat(b);
}