ResultsPage* SpectralLibraryMatchResults::createPage(const RasterElement* pRaster)
{
   ResultsPage* pPage = getPage(pRaster);
   if (pPage != NULL)
   {
      return NULL;
   }

   QString tabName = QString::fromStdString(pRaster->getDisplayName(true));
   pPage = new ResultsPage();
   if (pPage == NULL)
   {
      return NULL;
   }

   int index = mpTabWidget->addTab(pPage, tabName);
   mpTabWidget->setTabToolTip(index, QString::fromStdString(pRaster->getName()));
   mpTabWidget->setCurrentIndex(index);
   VERIFYNR(const_cast<RasterElement*>(pRaster)->attach(SIGNAL_NAME(Subject, Deleted),
      Slot(this, &SpectralLibraryMatchResults::elementDeleted)));
   VERIFYNR(const_cast<RasterElement*>(pRaster)->attach(SIGNAL_NAME(Subject, Modified),
      Slot(this, &SpectralLibraryMatchResults::elementModified)));
   mPageMap[pRaster] = pPage;

   return pPage;
}
示例#2
0
void GetLayer<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   const std::vector<View*> views = getViews();
   for (std::vector<View*>::const_iterator iter = views.begin(); iter != views.end(); ++iter)
   {
      View* pView = *iter;
      VERIFYNR(pView != NULL);

      std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem);
      std::string name = pView->getDisplayName();
      if (name.empty() == true)
      {
         name = pView->getName();
      }

      std::vector<std::string> classList;
      Service<DesktopServices>()->getViewTypes(pView->getObjectType(), classList);
      VERIFYNR(classList.empty() == false);

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pView));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(classList.front()));
      pChild->setFlags(Qt::NoItemFlags);

      populateTreeWidgetItemWithLayers(pChild.get());
      if (pChild->childCount() > 0)
      {
         pRoot->addChild(pChild.release());
      }
   }
}
示例#3
0
QtClusterGui::QtClusterGui(QWidget* pParent) : QDialog(pParent)
{
   mpClusterSize = new QDoubleSpinBox(this);
   mpClusterSize->setDecimals(1);
   mpClusterSize->setRange(0.1, 10000.0);
   mpClusterSize->setSuffix(" pixels");

   mpResultName = new QLineEdit(this);

   mpDisplayType = new QComboBox(this);
   std::vector<std::string> vals = StringUtilities::getAllEnumValuesAsDisplayString<DisplayType>();
   for (std::vector<std::string>::const_iterator val = vals.begin(); val != vals.end(); ++val)
   {
      mpDisplayType->addItem(QString::fromStdString(*val));
   }

   QDialogButtonBox* pButtons = new QDialogButtonBox(
      QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this);

   QFormLayout* pTopLevel = new QFormLayout(this);
   pTopLevel->addRow("Cluster radius", mpClusterSize);
   pTopLevel->addRow("Result layer name", mpResultName);
   pTopLevel->addRow("Result type", mpDisplayType);
   pTopLevel->addRow(pButtons);

   VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(accept())));
   VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(reject())));

   // some reasonable default
   setDisplayType(CENTROID);
}
示例#4
0
void GetView<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   const std::vector<View*> views = getViews();
   for (std::vector<View*>::const_iterator iter = views.begin(); iter != views.end(); ++iter)
   {
      View* pView = *iter;
      VERIFYNR(pView != NULL);
      if (pView->isKindOf(TypeConverter::toString<T>()) == false)
      {
         continue;
      }

      QTreeWidgetItem* pChild = new QTreeWidgetItem;
      std::string name = pView->getDisplayName();
      if (name.empty() == true)
      {
         name = pView->getName();
      }

      std::vector<std::string> classList;
      Service<DesktopServices>()->getViewTypes(pView->getObjectType(), classList);
      VERIFYNR(classList.empty() == false);

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pView));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(classList.front()));
      pChild->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
      pRoot->addChild(pChild);
   }
}
示例#5
0
void GetLayer<T>::populateTreeWidgetItemWithLayers(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
   void* pValue = value.value<void*>();
   View* const pView = reinterpret_cast<View*>(pValue);
   VERIFYNR(pView != NULL);

   std::vector<Layer*> layers;
   SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pView);
   if (pSpatialDataView != NULL)
   {
      LayerList* pLayerList = pSpatialDataView->getLayerList();
      if (pLayerList != NULL)
      {
         pLayerList->getLayers(layers);
      }
   }

   ProductView* pProductView = dynamic_cast<ProductView*>(pView);
   if (pProductView != NULL)
   {
      layers.push_back(pProductView->getLayoutLayer());
      layers.push_back(pProductView->getClassificationLayer());
   }

   PlotView* pPlotView = dynamic_cast<PlotView*>(pView);
   if (pPlotView != NULL)
   {
      layers.push_back(pPlotView->getAnnotationLayer());
   }

   // Add the layer items in reverse order so that the top-most layer is added first
   for (std::vector<Layer*>::reverse_iterator iter = layers.rbegin(); iter != layers.rend(); ++iter)
   {
      Layer* pLayer = *iter;
      if (pLayer == NULL || pLayer->isKindOf(TypeConverter::toString<T>()) == false)
      {
         continue;
      }

      QTreeWidgetItem* pChild = new QTreeWidgetItem;
      std::string name = pLayer->getDisplayName();
      if (name.empty() == true)
      {
         name = pLayer->getName();
      }

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pLayer));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(StringUtilities::toDisplayString(pLayer->getLayerType())));
      pChild->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
      pRoot->addChild(pChild);
   }
}
void SpectralLibraryMatchResults::deletePage(const RasterElement* pRaster)
{
   std::map<const RasterElement*, ResultsPage*>::iterator pit = mPageMap.find(pRaster);
   if (pit != mPageMap.end())
   {
      ResultsPage* pPage = pit->second;
      mPageMap.erase(pit);
      delete pPage;

      VERIFYNR(const_cast<RasterElement*>(pRaster)->detach(SIGNAL_NAME(Subject, Deleted),
         Slot(this, &SpectralLibraryMatchResults::elementDeleted)));
      VERIFYNR(const_cast<RasterElement*>(pRaster)->detach(SIGNAL_NAME(Subject, Modified),
         Slot(this, &SpectralLibraryMatchResults::elementModified)));
   }
}
示例#7
0
TimelineWidget::TimelineWidget(QWidget *pParent) : QWidget(pParent),
      mDragType(TimelineWidget::DRAGGING_NONE),
      mpDragging(NULL),
      mpToolbar(SIGNAL_NAME(AnimationToolBar, ControllerChanged), Slot(this, &TimelineWidget::controllerChanged)),
      mpControllerAttachments(SIGNAL_NAME(AnimationController, FrameChanged), Slot(this, &TimelineWidget::currentFrameChanged)),
      mpSessionExplorer(SIGNAL_NAME(DockWindow, AboutToShowContextMenu), Slot(this, &TimelineWidget::polishSessionExplorerContextMenu))
{
   mpControllerAttachments.addSignal(SIGNAL_NAME(AnimationController, AnimationAdded), Slot(this, &TimelineWidget::currentFrameChanged));

   mpD = new PrivateData;
   setRange(mpD->minValue, mpD->maxValue, false);
   setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
   setMouseTracking(true);
   setContextMenuPolicy(Qt::PreventContextMenu);

   AnimationToolBar *pToolBar = static_cast<AnimationToolBar*>(Service<DesktopServices>()->getWindow("Animation", TOOLBAR));
   mpToolbar.reset(pToolBar);
   setAnimationController(pToolBar->getAnimationController());

   // install context menu listeners
   SessionExplorer *pSes = static_cast<SessionExplorer*>(Service<DesktopServices>()->getWindow("Session Explorer", DOCK_WINDOW));
   mpSessionExplorer.reset(pSes);
   mpNewAnimationAction = new QAction("New Animation", this);
   mpNewAnimationAction->setStatusTip("Create an empty animation controller of a specified type.");
   VERIFYNR(connect(mpNewAnimationAction, SIGNAL(triggered()), this, SLOT(createNewController())));
}
ExtensionListDialog::ExtensionListDialog(QWidget* pParent) : QDialog(pParent)
{
    mpExtensionList = new QListWidget(this);
    mpExtensionList->setItemDelegate(new ExtensionListDelegate(this));
    mpExtensionList->setEditTriggers(QAbstractItemView::CurrentChanged);
    reloadExtensions();

    QVBoxLayout* pTopLevel = new QVBoxLayout(this);
    pTopLevel->addWidget(mpExtensionList, 10);
    QDialogButtonBox* pButtons = new QDialogButtonBox(QDialogButtonBox::Close, Qt::Horizontal, this);
    pButtons->addButton("&Install...", QDialogButtonBox::AcceptRole);
    pTopLevel->addWidget(pButtons);
    VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(accept())));
    VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(install())));
    resize(480, 500);
}
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);
}
bool SpectralLibraryManager::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
    mpProgress = Service<PlugInManagerServices>()->getProgress(this);
    if (mpProgress != NULL)
    {
        Service<DesktopServices>()->createProgressDialog(getName(), mpProgress);
    }

    // Create edit library action
    if (isBatch() == false)
    {
        QPixmap pixEditLib(EditSpectralLibraryIcon);
        mpEditSpectralLibraryAction = new QAction(QIcon(pixEditLib),
                "&Edit Spectral Library", this);
        mpEditSpectralLibraryAction->setAutoRepeat(false);
        mpEditSpectralLibraryAction->setStatusTip("Display the editor for adding and removing "
                "signatures used by the Spectral Library Match algorithm plug-ins.");
        VERIFYNR(connect(mpEditSpectralLibraryAction, SIGNAL(triggered()), this, SLOT(editSpectralLibrary())));

        ToolBar* pToolBar = static_cast<ToolBar*>(Service<DesktopServices>()->getWindow("Spectral", TOOLBAR));
        if (pToolBar != NULL)
        {
            pToolBar->addSeparator();
            pToolBar->addButton(mpEditSpectralLibraryAction);
        }
    }

    return true;
}
void RangeProfilePlotManager::updateContextMenu(Subject& subject, const std::string& signal, const boost::any& value)
{
   ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value);
   if (pMenu == NULL)
   {
      return;
   }
   QAction* pDiffAction = new QAction("Calculate Difference", pMenu->getActionParent());
   VERIFYNRV(mpView);
   int numSelectedObjects = mpView->getNumSelectedObjects(true);

   if (numSelectedObjects != 2)
   {
      pDiffAction->setEnabled(false);
   }
   else
   {
      std::list<PlotObject*> objects;
      mpView->getSelectedObjects(objects, true);
      for (std::list<PlotObject*>::const_iterator obj = objects.begin(); obj != objects.end(); ++obj)
      {
         std::string name;
         (*obj)->getObjectName(name);
         if (name == "Difference")
         {
            pDiffAction->setEnabled(false);
            break;
         }
      }
   }

   VERIFYNR(connect(pDiffAction, SIGNAL(triggered()), this, SLOT(calculateDifferences())));
   pMenu->addActionBefore(pDiffAction, "SPECTRAL_RANGEPROFILEPLOT_DIFFERENCE_ACTION", APP_PLOTWIDGET_PRINT_ACTION);

   QAction* pDelAction = new QAction(
      (numSelectedObjects > 1) ? "Delete Plots" : "Delete Plot", pMenu->getActionParent());
   if (mpView != NULL && numSelectedObjects == 0)
   {
      pDelAction->setEnabled(false);
   }
   VERIFYNR(connect(pDelAction, SIGNAL(triggered()), this, SLOT(deleteSelectedPlots())));
   pMenu->addActionAfter(pDelAction, "SPECTRAL_RANGEPROFILEPLOT_DELETE_ACTION",
      "SPECTRAL_RANGEPROFILEPLOT_DIFFERENCE_ACTION");
}
示例#12
0
void FeatureProxyConnector::initialize()
{
   if (mProcessInitialized == true)
   {
      return;
   }

   long pid = -1;
#if defined(WIN_API)
   pid = GetCurrentProcessId();
#endif

   mpConnectionTimer = new QTimer(this);
   mpConnectionTimer->setSingleShot(true);
   int connectionTimeout = FeatureProxyConnector::getSettingConnectionTimeout();
   mpConnectionTimer->setInterval(connectionTimeout);
   VERIFYNR(connect(mpConnectionTimer, SIGNAL(timeout()), this, SLOT(abortConnection())));

   if (mpProcess->state() != QProcess::NotRunning)
   {
      terminate();
   }
   mpServer = new QLocalServer(this);
   if (!mpServer->listen("OpticksFeatureProxyConnector" + QString::number(pid)))
   {
      terminate();
      return;
   }

   QStringList args;
   if (pid >= 0)
   {
      args << "-pid" << QString::number(pid);
   }

   mpProcess->start(mExecutable, args);
   mProcessInitialized = true;
   if (!mpProcess->waitForStarted())
   {
      terminate();
      return;
   }

   if (!mpServer->waitForNewConnection(3000))
   {
      terminate();
      return;
   }
   mpSocket = mpServer->nextPendingConnection();
   mpServer->close();
   mStream.setDevice(mpSocket);
   connect(mpSocket, SIGNAL(readyRead()), this, SLOT(processReply()));
   mStream << APP_VERSION_NUMBER << endl;
}
LibraryEditDlg::LibraryEditDlg(const std::vector<Signature*>& signatures, QWidget* pParent) :
   mpTree(NULL),
   QDialog(pParent, Qt::WindowCloseButtonHint)
{
   setWindowTitle("Spectral Library Editor");
   mpTree = new QTreeWidget(this);
   QStringList columnNames;
   columnNames << "Signatures";
   mpTree->setColumnCount(columnNames.count());
   mpTree->setHeaderLabels(columnNames);
   mpTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
   mpTree->setAllColumnsShowFocus(true);
   mpTree->setRootIsDecorated(true);
   mpTree->setSortingEnabled(false);
   mpTree->setToolTip("This list displays the spectral library matches for in-scene spectra.");

   QHeaderView* pHeader = mpTree->header();
   if (pHeader != NULL)
   {
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->resizeSection(0, 150);
   }

   QDialogButtonBox* pButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
      Qt::Vertical, this);
   QPushButton* pAdd = new QPushButton("Add...", this);
   QPushButton* pRemove = new QPushButton("Remove", this);
   pButtons->addButton(pAdd, QDialogButtonBox::ActionRole);
   pButtons->addButton(pRemove, QDialogButtonBox::ActionRole);

   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->addWidget(mpTree, 0, 0, 6, 1);
   pGrid->addWidget(pButtons, 0, 1, 6, 1);

   VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(accept())));
   VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(reject())));
   VERIFYNR(connect(pAdd, SIGNAL(clicked()), this, SLOT(addSignatures())));
   VERIFYNR(connect(pRemove, SIGNAL(clicked()), this, SLOT(removeSignatures())));

   addSignatures(signatures);
}
示例#14
0
WizardProperties::WizardProperties(QWidget* pParent) :
   QWidget(pParent),
   mpNameEdit(NULL),
   mpMenuEdit(NULL),
   mpModeCombo(NULL)
{
   // Name
   QLabel* pNameLabel = new QLabel("Name:", this);
   mpNameEdit = new QLineEdit(this);

   // Menu location
   QLabel* pMenuLabel = new QLabel("Menu Location:", this);
   mpMenuEdit = new QLineEdit(this);

   // Execution mode
   QLabel* pModeLabel = new QLabel("Execution Mode:", this);
   mpModeCombo = new QComboBox(this);
   mpModeCombo->addItem("Batch");
   mpModeCombo->addItem("Interactive");

   // Execute button
   QPushButton* pExecuteButton = new QPushButton("Execute", this);

   // Layout
   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->setMargin(5);
   pGrid->setSpacing(5);
   pGrid->addWidget(pNameLabel, 0, 0);
   pGrid->addWidget(mpNameEdit, 0, 1, 1, 2);
   pGrid->addWidget(pMenuLabel, 1, 0);
   pGrid->addWidget(mpMenuEdit, 1, 1, 1, 2);
   pGrid->addWidget(pModeLabel, 2, 0);
   pGrid->addWidget(mpModeCombo, 2, 1);
   pGrid->addWidget(pExecuteButton, 2, 2);
   pGrid->setColumnStretch(1, 10);

   // Initialization
   setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);

   // Connections
   mpWizard.addSignal(SIGNAL_NAME(WizardObjectImp, Renamed), Slot(this, &WizardProperties::wizardRenamed));
   mpWizard.addSignal(SIGNAL_NAME(WizardObjectImp, MenuLocationChanged),
      Slot(this, &WizardProperties::menuLocationChanged));
   mpWizard.addSignal(SIGNAL_NAME(WizardObjectImp, BatchModeChanged),
      Slot(this, &WizardProperties::executionModeChanged));

   VERIFYNR(connect(mpNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(setWizardName(const QString&))));
   VERIFYNR(connect(mpMenuEdit, SIGNAL(textChanged(const QString&)), this,
      SLOT(setWizardMenuLocation(const QString&))));
   VERIFYNR(connect(mpModeCombo, SIGNAL(activated(int)), this, SLOT(setWizardExecutionMode(int))));
   VERIFYNR(connect(pExecuteButton, SIGNAL(clicked()), this, SLOT(executeWizard())));
}
LibraryEditDlg::~LibraryEditDlg()
{
   int numSigs = mpTree->topLevelItemCount();
   for (int index = 0; index < numSigs; ++index)
   {
      QVariant variant = mpTree->topLevelItem(index)->data(0, Qt::UserRole);
      if (variant.isValid())
      {
         VERIFYNR(variant.value<Signature*>()->detach(SIGNAL_NAME(Subject, Deleted),
            Slot(this, &LibraryEditDlg::signatureDeleted)));
      }
   }
}
示例#16
0
FeatureProxyConnector::~FeatureProxyConnector()
{
   VERIFYNR(mCoordinateTransformations.empty());
   terminate();
   if (mpServer != NULL)
   {
      mpServer->close();
   }
   if (mpSocket != NULL)
   {
      mpSocket->close();
   }
}
void LibraryEditDlg::addSignatures(const std::vector<Signature*>& signatures)
{
   for (std::vector<Signature*>::const_iterator it = signatures.begin(); it != signatures.end(); ++it)
   {
      // if not in list, add
      if (mpTree->findItems(QString::fromStdString((*it)->getName()), Qt::MatchExactly).isEmpty())
      {
         QTreeWidgetItem* pItem = new QTreeWidgetItem(mpTree);
         pItem->setText(0, QString::fromStdString((*it)->getName()));
         pItem->setData(0, Qt::UserRole, QVariant::fromValue(*it));
         VERIFYNR((*it)->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &LibraryEditDlg::signatureDeleted)));
      }
   }
}
ResultsItemModel::~ResultsItemModel()
{
   std::vector<PlugIn*> plugIns = Service<PlugInManagerServices>()->getPlugInInstances(
      SpectralLibraryMatch::getNameLibraryManagerPlugIn());
   if (plugIns.empty() == false)
   {
      SpectralLibraryManager* pLibMgr = dynamic_cast<SpectralLibraryManager*>(plugIns.front());
      if (pLibMgr != NULL)
      {
         VERIFYNR(pLibMgr->detach(SIGNAL_NAME(SpectralLibraryManager, SignatureDeleted),
            Slot(this, &ResultsItemModel::signatureDeleted)));
      }
   }
   clear();
}
SpectralLibraryManager::~SpectralLibraryManager()
{
    clearLibrary();

    // Remove the toolbar button
    Service<DesktopServices> pDesktop;
    ToolBar* pToolBar = static_cast<ToolBar*>(pDesktop->getWindow("Spectral", TOOLBAR));
    if (pToolBar != NULL)
    {
        if (mpEditSpectralLibraryAction != NULL)
        {
            VERIFYNR(disconnect(mpEditSpectralLibraryAction, SIGNAL(triggered()), this, SLOT(editSpectralLibrary())));
            pToolBar->removeItem(mpEditSpectralLibraryAction);
        }
    }
}
void LibraryEditDlg::removeSignatures()
{
   QList<QTreeWidgetItem*> items = mpTree->selectedItems();
   QListIterator<QTreeWidgetItem*> it(items);
   while (it.hasNext())
   {
      QTreeWidgetItem* pItem = it.next();
      QVariant variant = pItem->data(0, Qt::UserRole);
      if (variant.isValid())
      {
         VERIFYNR(variant.value<Signature*>()->detach(SIGNAL_NAME(Subject, Deleted),
            Slot(this, &LibraryEditDlg::signatureDeleted)));
      }
      delete pItem;
   }
}
ResultsItemModel::ResultsItemModel(QObject* pParent) :
   QAbstractItemModel(pParent),
   mAddingResults(false)
{
   std::vector<PlugIn*> plugIns = Service<PlugInManagerServices>()->getPlugInInstances(
      SpectralLibraryMatch::getNameLibraryManagerPlugIn());
   if (plugIns.empty() == false)
   {
      SpectralLibraryManager* pLibMgr = dynamic_cast<SpectralLibraryManager*>(plugIns.front());
      if (pLibMgr != NULL)
      {
         VERIFYNR(pLibMgr->attach(SIGNAL_NAME(SpectralLibraryManager, SignatureDeleted),
            Slot(this, &ResultsItemModel::signatureDeleted)));
      }
   }
}
void LibraryEditDlg::signatureDeleted(Subject& subject, const std::string& signal, const boost::any& value)
{
   Signature* pSignature = dynamic_cast<Signature*>(&subject);
   if (pSignature != NULL && signal == "Subject::Deleted")
   {
      VERIFYNR(pSignature->detach(SIGNAL_NAME(Subject, Deleted), Slot(this, &LibraryEditDlg::signatureDeleted)));
      QList<QTreeWidgetItem*> items =
         mpTree->findItems(QString::fromStdString(pSignature->getName()), Qt::MatchExactly);
      if (items.isEmpty() == false)
      {
         QListIterator<QTreeWidgetItem*> it(items);
         while (it.hasNext())
         {
            delete it.next();
         }
      }
   }
}
示例#23
0
void GetPlotWidget::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   std::vector<Window*> windows;
   Service<DesktopServices>()->getWindows(PLOT_WINDOW, windows);
   for (std::vector<Window*>::const_iterator iter = windows.begin(); iter != windows.end(); ++iter)
   {
      PlotWindow* pPlotWindow = dynamic_cast<PlotWindow*>(*iter);
      if (pPlotWindow == NULL)
      {
         continue;
      }

      std::vector<PlotWidget*> plots;
      pPlotWindow->getPlots(plots);
      for (std::vector<PlotWidget*>::const_iterator plotIter = plots.begin(); plotIter != plots.end(); ++plotIter)
      {
         PlotWidget* pPlotWidget = *plotIter;
         if (pPlotWidget == NULL)
         {
            continue;
         }

         QTreeWidgetItem* pChild = new QTreeWidgetItem;
         std::string name = pPlotWidget->getDisplayName();
         if (name.empty() == true)
         {
            name = pPlotWidget->getName();
         }

         pChild->setText(GetSessionItemBase<PlotWidget>::NameColumn, QString::fromStdString(name));
         pChild->setData(GetSessionItemBase<PlotWidget>::NameColumn,
            GetSessionItemBase<PlotWidget>::SessionItemRole, QVariant::fromValue<void*>(pPlotWidget));
         pChild->setText(GetSessionItemBase<PlotWidget>::TypeColumn,
            QString::fromStdString(TypeConverter::toString<PlotWidget>()));
         pChild->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
         pRoot->addChild(pChild);
      }
   }
}
示例#24
0
bool Legend::insertItem(PlotObject* pObject)
{
   if (pObject == NULL)
   {
      return false;
   }

   if (mSecondaryObjects == false)
   {
      if (pObject->isPrimary() == false)
      {
         return false;
      }
   }

   PlotObjectImp* pObjectImp = dynamic_cast<PlotObjectImp*>(pObject);
   if (pObjectImp == NULL)
   {
      return false;
   }

   QString strName = pObjectImp->getObjectName();

   QTreeWidgetItem* pItem = new QTreeWidgetItem(this);
   if (pItem != NULL)
   {
      bool bSelected = pObjectImp->isSelected();
      const QPixmap& pix = pObjectImp->getLegendPixmap(bSelected);

      pItem->setIcon(0, QIcon(pix));
      pItem->setText(0, strName);

      VERIFYNR(connect(pObjectImp, SIGNAL(renamed(const QString&)), this, SLOT(updateItemText(const QString&))));
      VERIFYNR(connect(pObjectImp, SIGNAL(legendPixmapChanged()), this, SLOT(updateItemPixmap())));

      mObjects.insert(pObject, pItem);
      return true;
   }
示例#25
0
void GetDataElement<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot)
{
   VERIFYNR(pRoot != NULL);
   QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
   void* pValue = value.value<void*>();
   DataElement* const pRootElement = reinterpret_cast<DataElement*>(pValue);
   const std::vector<DataElement*> elements = Service<ModelServices>()->getElements(pRootElement, std::string());
   for (std::vector<DataElement*>::const_iterator iter = elements.begin(); iter != elements.end(); ++iter)
   {
      DataElement* pChildElement = *iter;
      if (pChildElement == NULL)
      {
         // Disallow NULL elements since that would result in infinite recursion.
         continue;
      }

      std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem);
      std::string name = pChildElement->getDisplayName();
      if (name.empty() == true)
      {
         name = pChildElement->getName();
      }

      pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
      pChild->setData(GetSessionItemBase<T>::NameColumn,
         GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pChildElement));
      pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(pChildElement->getType()));
      populateTreeWidgetItem(pChild.get());

      const bool isValid = pChildElement->isKindOf(TypeConverter::toString<T>());
      pChild->setFlags(isValid ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags);
      if (isValid == true || pChild->childCount() > 0)
      {
         pRoot->addChild(pChild.release());
      }
   }
}
示例#26
0
FeatureClassDlg::FeatureClassDlg(QWidget* pParent) :
    QDialog(pParent)
{
    // Classes
    QLabel* pClassLabel = new QLabel("Feature Classes:", this);

    QToolButton* pAddFeatureButton = new QToolButton(this);
    pAddFeatureButton->setAutoRaise(true);
    pAddFeatureButton->setIcon(QIcon(":/icons/New"));
    pAddFeatureButton->setToolTip("Add Feature");

    QToolButton* pRemoveFeatureButton = new QToolButton(this);
    pRemoveFeatureButton->setAutoRaise(true);
    pRemoveFeatureButton->setIcon(QIcon(":/icons/Delete"));
    pRemoveFeatureButton->setToolTip("Remove Feature");

    mpClassList = new QListWidget(this);
    mpClassList->setFixedWidth(150);
    mpClassList->setSelectionMode(QAbstractItemView::SingleSelection);
    mpClassList->setSortingEnabled(true);
    mpClassList->sortItems(Qt::AscendingOrder);

    // Fields
    QLabel* pFieldLabel = new QLabel("Fields:", this);

    QToolButton* pAddFieldButton = new QToolButton(this);
    pAddFieldButton->setAutoRaise(true);
    pAddFieldButton->setIcon(QIcon(":/icons/New"));
    pAddFieldButton->setToolTip("Add Field");

    QToolButton* pRemoveFieldButton = new QToolButton(this);
    pRemoveFieldButton->setAutoRaise(true);
    pRemoveFieldButton->setIcon(QIcon(":/icons/Delete"));
    pRemoveFieldButton->setToolTip("Remove Field");

    QStringList columnNames;
    columnNames.append("Name");
    columnNames.append("Type");
    columnNames.append("Default Value");

    mpFieldTree = new QTreeWidget(this);
    mpFieldTree->setColumnCount(3);
    mpFieldTree->setHeaderLabels(columnNames);
    mpFieldTree->setSelectionMode(QAbstractItemView::SingleSelection);
    mpFieldTree->setRootIsDecorated(false);
    mpFieldTree->setAllColumnsShowFocus(true);
    mpFieldTree->setSortingEnabled(true);
    mpFieldTree->sortByColumn(0, Qt::AscendingOrder);
    mpFieldTree->setItemDelegateForColumn(0, new FieldNameDelegate(mpFieldTree));
    mpFieldTree->setItemDelegateForColumn(1, new FieldTypeDelegate(mpFieldTree));
    mpFieldTree->setItemDelegateForColumn(2, new FieldValueDelegate(mpFieldTree));

    QHeaderView* pHeader = mpFieldTree->header();
    if (pHeader != NULL)
    {
        pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        pHeader->setStretchLastSection(false);
        pHeader->setSortIndicatorShown(true);
    }

    // Horizontal line
    QFrame* pLine = new QFrame(this);
    pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);

    // Dialog buttons
    QDialogButtonBox* pButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
            Qt::Horizontal, this);

    // Layout
    QHBoxLayout* pFeatureButtonLayout = new QHBoxLayout();
    pFeatureButtonLayout->setMargin(0);
    pFeatureButtonLayout->setSpacing(0);
    pFeatureButtonLayout->addWidget(pClassLabel);
    pFeatureButtonLayout->addSpacing(10);
    pFeatureButtonLayout->addStretch();
    pFeatureButtonLayout->addWidget(pAddFeatureButton);
    pFeatureButtonLayout->addWidget(pRemoveFeatureButton);

    QVBoxLayout* pFeatureClassLayout = new QVBoxLayout();
    pFeatureClassLayout->setMargin(0);
    pFeatureClassLayout->setSpacing(2);
    pFeatureClassLayout->addLayout(pFeatureButtonLayout);
    pFeatureClassLayout->addWidget(mpClassList, 10);

    QHBoxLayout* pFieldButtonLayout = new QHBoxLayout();
    pFieldButtonLayout->setMargin(0);
    pFieldButtonLayout->setSpacing(0);
    pFieldButtonLayout->addWidget(pFieldLabel);
    pFieldButtonLayout->addSpacing(10);
    pFieldButtonLayout->addStretch();
    pFieldButtonLayout->addWidget(pAddFieldButton);
    pFieldButtonLayout->addWidget(pRemoveFieldButton);

    QVBoxLayout* pFieldLayout = new QVBoxLayout();
    pFieldLayout->setMargin(0);
    pFieldLayout->setSpacing(2);
    pFieldLayout->addLayout(pFieldButtonLayout);
    pFieldLayout->addWidget(mpFieldTree, 10);

    QGridLayout* pLayout = new QGridLayout(this);
    pLayout->setMargin(10);
    pLayout->setSpacing(10);
    pLayout->addLayout(pFeatureClassLayout, 0, 0);
    pLayout->addLayout(pFieldLayout, 0, 1);
    pLayout->addWidget(pLine, 1, 0, 1, 2);
    pLayout->addWidget(pButtonBox, 2, 0, 1, 2);
    pLayout->setRowStretch(0, 10);
    pLayout->setColumnStretch(1, 10);

    // Initialization
    setWindowTitle("Feature Classes");
    resize(550, 300);
    loadFromSettings();
    updateFields();

    // Connections
    VERIFYNR(connect(pAddFeatureButton, SIGNAL(clicked()), this, SLOT(addFeatureClass())));
    VERIFYNR(connect(pRemoveFeatureButton, SIGNAL(clicked()), this, SLOT(removeFeatureClass())));
    VERIFYNR(connect(mpClassList, SIGNAL(itemChanged(QListWidgetItem*)), this,
                     SLOT(setFeatureClassData(QListWidgetItem*))));
    VERIFYNR(connect(mpClassList, SIGNAL(itemSelectionChanged()), this, SLOT(updateFields())));
    VERIFYNR(connect(pAddFieldButton, SIGNAL(clicked()), this, SLOT(addField())));
    VERIFYNR(connect(pRemoveFieldButton, SIGNAL(clicked()), this, SLOT(removeField())));
    VERIFYNR(connect(mpFieldTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this,
                     SLOT(setFieldData(QTreeWidgetItem*, int))));
    VERIFYNR(connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept())));
    VERIFYNR(connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject())));
}
示例#27
0
FeatureClassWidget::FeatureClassWidget(QWidget* pParent) :
   ModifierWidget(pParent),
   mpEditFeatureClass(NULL),
   mpFeatureClass(NULL),
   mbDisplayOnlyChanges(true)
{
   QTabWidget* pTabWidget = new QTabWidget(this);

   QWidget* pConnectionTab = new QWidget(this);
   QGridLayout* pConnectionLayout = new QGridLayout(pConnectionTab);
   QLabel* pLayerNameLabel = new QLabel("Layer name:", pConnectionTab);
   mpLayerNameEdit = new QLineEdit(pConnectionTab);
   mpConnection = new ConnectionParametersWidget(pConnectionTab);

   pConnectionLayout->addWidget(pLayerNameLabel, 0, 0);
   pConnectionLayout->addWidget(mpLayerNameEdit, 0, 1);
   pConnectionLayout->addWidget(mpConnection, 1, 0, 1, 2);

   QueryOptionsWidget* pInspector = new QueryOptionsWidget(this);
   mpDisplay = new ListInspectorWidget(pInspector, this);

   mpClipping = new QWidget(this);
   mpNoClipButton = new QRadioButton("No clip", mpClipping);
   mpSceneClipButton = new QRadioButton("Clip to scene", mpClipping);
   mpSpecifiedClipButton = new QRadioButton("Specified clip", mpClipping);
   mpNorthEdit = new LatLonLineEdit(mpClipping);
   mpSouthEdit = new LatLonLineEdit(mpClipping);
   mpEastEdit = new LatLonLineEdit(mpClipping);
   mpWestEdit = new LatLonLineEdit(mpClipping);
   QLabel* pNorthLabel = new QLabel("North:", mpClipping);
   QLabel* pSouthLabel = new QLabel("South:", mpClipping);
   QLabel* pEastLabel = new QLabel("East:", mpClipping);
   QLabel* pWestLabel = new QLabel("West:", mpClipping);

   mSpecifiedClipWidgets.push_back(mpNorthEdit);
   mSpecifiedClipWidgets.push_back(mpSouthEdit);
   mSpecifiedClipWidgets.push_back(mpEastEdit);
   mSpecifiedClipWidgets.push_back(mpWestEdit);
   mSpecifiedClipWidgets.push_back(pNorthLabel);
   mSpecifiedClipWidgets.push_back(pSouthLabel);
   mSpecifiedClipWidgets.push_back(pEastLabel);
   mSpecifiedClipWidgets.push_back(pWestLabel);

   QGridLayout* pClipLayout = new QGridLayout(mpClipping);
   pClipLayout->setColumnStretch(2, 10);
   pClipLayout->setColumnMinimumWidth(0, 15);
   pClipLayout->addWidget(mpNoClipButton, 0, 0, 1, 3);
   pClipLayout->addWidget(mpSceneClipButton, 1, 0, 1, 3);
   pClipLayout->addWidget(mpSpecifiedClipButton, 2, 0, 1, 3);
   pClipLayout->addWidget(pNorthLabel, 3, 1);
   pClipLayout->addWidget(mpNorthEdit, 3, 2);
   pClipLayout->addWidget(pSouthLabel, 4, 1);
   pClipLayout->addWidget(mpSouthEdit, 4, 2);
   pClipLayout->addWidget(pEastLabel, 5, 1);
   pClipLayout->addWidget(mpEastEdit, 5, 2);
   pClipLayout->addWidget(pWestLabel, 6, 1);
   pClipLayout->addWidget(mpWestEdit, 6, 2);
   pClipLayout->setRowStretch(7, 10);

   pTabWidget->addTab(pConnectionTab, "Connection");
   pTabWidget->addTab(mpDisplay, "Display");
   pTabWidget->addTab(mpClipping, "Clipping");

   mpErrorLabel = new QLabel(this);
   // Font
   QFont errorFont = mpErrorLabel->font();
   errorFont.setBold(true);
   mpErrorLabel->setFont(errorFont);

   // Text color
   QPalette errorPalette = mpErrorLabel->palette();
   errorPalette.setColor(QPalette::WindowText, Qt::red);
   mpErrorLabel->setPalette(errorPalette);

   // Word wrap
   mpErrorLabel->setWordWrap(true);

   QPushButton* pTestConnectionButton = new QPushButton("Test Connection", this);

   mpProgressBar = new QProgressBar(this);
   mpProgressBar->setRange(0, 0);
   mpProgressBar->setHidden(true);
   
   QGridLayout* pLayout = new QGridLayout(this);
   pLayout->setMargin(0);
   pLayout->setSpacing(5);
   pLayout->setColumnStretch(1, 10);

   pLayout->addWidget(pTabWidget, 0, 0, 1, 3);
   pLayout->addWidget(mpProgressBar, 1, 0);
   pLayout->addWidget(mpErrorLabel, 1, 1);
   pLayout->addWidget(pTestConnectionButton, 1, 2);

   // Initialization
   setWindowTitle("Shape File");

   // Connections
   VERIFYNR(connect(pTabWidget, SIGNAL(currentChanged(int)), this, SLOT(testConnection())));
   VERIFYNR(connect(pTestConnectionButton, SIGNAL(clicked()), this, SLOT(testConnection())));

   VERIFYNR(connect(mpConnection, SIGNAL(modified()), this, SLOT(updateConnectionParameters())));
   VERIFYNR(attachSignal(mpConnection, SIGNAL(modified())));

   VERIFYNR(connect(mpDisplay, SIGNAL(addItems()), this, SLOT(addDisplayItems())));
   VERIFYNR(connect(mpDisplay, SIGNAL(saveInspector(QWidget*, QListWidgetItem*)),
      this, SLOT(saveDisplayInspector(QWidget*, QListWidgetItem*))));
   VERIFYNR(connect(mpDisplay, SIGNAL(loadInspector(QWidget*, QListWidgetItem*)),
      this, SLOT(loadDisplayInspector(QWidget*, QListWidgetItem*))));
   VERIFYNR(connect(mpDisplay, SIGNAL(removeItem(QListWidgetItem*)),
      this, SLOT(removeDisplayItem(QListWidgetItem*))));

   VERIFYNR(connect(mpNoClipButton, SIGNAL(toggled(bool)), this, SLOT(clipButtonClicked())));
   VERIFYNR(connect(mpSceneClipButton, SIGNAL(toggled(bool)), this, SLOT(clipButtonClicked())));
   VERIFYNR(connect(mpSpecifiedClipButton, SIGNAL(toggled(bool)), this, SLOT(clipButtonClicked())));
}
LocateDialog::LocateDialog(const RasterElement* pRaster, QWidget* pParent) :
   QDialog(pParent, Qt::WindowCloseButtonHint),
   mpRaster(pRaster),
   mLayerNameBase("Spectral Library Match Locate Results - "),
   mpAlgCombo(NULL),
   mpThreshold(NULL),
   mpOutputLayerName(NULL),
   mpUseAoi(NULL),
   mpAoiCombo(NULL),
   mpSaveSettings(NULL)
{
   setWindowTitle("Locate Matched Signatures Settings");

   // layout
   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->setSpacing(5);
   pGrid->setMargin(10);

   QLabel* pNameLabel = new QLabel("Dataset:", this);
   QLabel* pDataLabel = new QLabel(QString::fromStdString(pRaster->getDisplayName(true)), this);
   pDataLabel->setToolTip(QString::fromStdString(pRaster->getName()));
   QLabel* pAlgLabel = new QLabel("Algorithm:", this);
   mpAlgCombo = new QComboBox(this);
   QLabel* pThresLabel = new QLabel("Threshold:", this);
   mpThreshold = new QDoubleSpinBox(this);
   mpThreshold->setSingleStep(0.1);
   QLabel* pLayerLabel = new QLabel("Output Layer Name:", this);
   mpOutputLayerName = new QLineEdit(this);
   mpUseAoi = new QCheckBox("Area of Interest:", this);
   mpUseAoi->setToolTip("Check box to limit the Locate function to an AOI");
   mpAoiCombo = new QComboBox(this);
   mpAoiCombo->setEnabled(false);
   mpSaveSettings = new QCheckBox("Save the algorithm and threshold settings", this);
   QFrame* pLineSeparator = new QFrame(this);
   pLineSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken);
   QDialogButtonBox* pButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
      Qt::Horizontal, this);

   pGrid->addWidget(pNameLabel, 0, 0, Qt::AlignRight);
   pGrid->addWidget(pDataLabel, 0, 1);
   pGrid->addWidget(pAlgLabel, 1, 0, Qt::AlignRight);
   pGrid->addWidget(mpAlgCombo, 1, 1);
   pGrid->addWidget(pThresLabel, 2, 0, Qt::AlignRight);
   pGrid->addWidget(mpThreshold, 2, 1);
   pGrid->addWidget(pLayerLabel, 3, 0, Qt::AlignRight);
   pGrid->addWidget(mpOutputLayerName, 3, 1);
   pGrid->addWidget(mpUseAoi, 4, 0, Qt::AlignRight);
   pGrid->addWidget(mpAoiCombo, 4, 1);
   pGrid->addWidget(mpSaveSettings, 5, 1);
   pGrid->addWidget(pLineSeparator, 7, 0, 1, 2);
   pGrid->addWidget(pButtons, 8, 0, 1, 2, Qt::AlignRight);
   pGrid->setRowStretch(6, 10);
   pGrid->setColumnStretch(1, 10);

   // initialize algorithm combo
   std::vector<std::string> algNames =
      StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>();
   for (std::vector<std::string>::const_iterator it = algNames.begin(); it != algNames.end(); ++it)
   {
      mpAlgCombo->addItem(QString::fromStdString(*it));
   }

   // set up algorithm threshold map
   std::vector<std::string> algorithmNames =
      StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>();
   for (std::vector<std::string>::iterator it = algorithmNames.begin();
      it != algorithmNames.end(); ++it)
   {
      float threshold(0.0f);
      switch (StringUtilities::fromDisplayString<SpectralLibraryMatch::LocateAlgorithm>(*it))
      {
      case SpectralLibraryMatch::SLLA_CEM:
         threshold = SpectralLibraryMatchOptions::getSettingLocateCemThreshold();
         break;

      case SpectralLibraryMatch::SLLA_SAM:
         threshold = SpectralLibraryMatchOptions::getSettingLocateSamThreshold();
         break;

      case SpectralLibraryMatch::SLLA_WBI:
         threshold = SpectralLibraryMatchOptions::getSettingLocateWbiThreshold();
         break;

      default:
         threshold = 0.0f;
         break;
      }

      mLocateThresholds.insert(std::pair<std::string, float>(*it, threshold));
   }

   // load aoi combo
   std::vector<DataElement*> aois =
      Service<ModelServices>()->getElements(pRaster, TypeConverter::toString<AoiElement>());
   for (std::vector<DataElement*>::const_iterator it = aois.begin(); it != aois.end(); ++it)
   {
      mpAoiCombo->addItem(QString::fromStdString((*it)->getName()));
   }

   // try to determine the active aoi layer and set combo to the element for that layer
   std::vector<Window*> windows;
   SpatialDataView* pView(NULL);
   Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows);
   for (std::vector<Window*>::iterator it = windows.begin(); it != windows.end(); ++it)
   {
      SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(*it);
      if (pWindow != NULL)
      {
         SpatialDataView* pTmpView = dynamic_cast<SpatialDataView*>(pWindow->getView());
         if (pTmpView != NULL)
         {
            LayerList* pLayerList = pTmpView->getLayerList();
            if (pLayerList != NULL)
            {
               if (pRaster == pLayerList->getPrimaryRasterElement())
               {
                  pView = pTmpView;
                  break;
               }
            }
         }
      }
   }

   if (pView != NULL)
   {
      Layer* pLayer = pView->getActiveLayer();
      if (pLayer != NULL)
      {
         DataElement* pElement = pLayer->getDataElement();
         if (pElement != NULL)
         {
            std::string elementName = pElement->getName();
            int index = mpAoiCombo->findText(QString::fromStdString(elementName));
            if (index != -1)
            {
               mpAoiCombo->setCurrentIndex(index);
            }
         }
      }
   }
   if (mpAoiCombo->count() == 0)
   {
      mpUseAoi->setEnabled(false);
   }

   // Initialize From Settings
   SpectralLibraryMatch::LocateAlgorithm locType =
      StringUtilities::fromXmlString<SpectralLibraryMatch::LocateAlgorithm>(
      SpectralLibraryMatchOptions::getSettingLocateAlgorithm());
   mpAlgCombo->setCurrentIndex(mpAlgCombo->findText(QString::fromStdString(
      StringUtilities::toDisplayString<SpectralLibraryMatch::LocateAlgorithm>(locType))));
   mpThreshold->setValue(mLocateThresholds[mpAlgCombo->currentText().toStdString()]);
   QString layerName = mLayerNameBase;
   switch (locType)
   {
   case SpectralLibraryMatch::SLLA_CEM:
      layerName += "CEM";
      break;

   case SpectralLibraryMatch::SLLA_SAM:
      layerName += "SAM";
      break;

   case SpectralLibraryMatch::SLLA_WBI:
      layerName += "WBI";
      break;

   default:
      layerName += "Unknown Algorithm";
      break;
   }
   mpOutputLayerName->setText(layerName);

   // connections
   VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(accept())));
   VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(reject())));
   VERIFYNR(connect(mpAlgCombo, SIGNAL(currentIndexChanged(const QString&)),
      this, SLOT(algorithmChanged(const QString&))));
   VERIFYNR(connect(mpThreshold, SIGNAL(valueChanged(double)),
      this, SLOT(thresholdChanged(double))));
   VERIFYNR(connect(mpUseAoi, SIGNAL(toggled(bool)), mpAoiCombo, SLOT(setEnabled(bool))));
}
GetConvolveParametersDialog::GetConvolveParametersDialog(SpatialDataView* pView,
        RasterElement* pElement,
        QWidget* pParent)
    : QDialog(pParent),
      mpView(pView)
{
    setWindowTitle("Convolution Parameters");

    mpAoiSelect = new QComboBox(this);
    mpAoiSelect->setEditable(false);
    mpAoiSelect->addItem("<no AOI>");
    std::vector<Layer*> layers;
    if (pView != NULL)
    {
        pView->getLayerList()->getLayers(AOI_LAYER, layers);
    }
    if (!layers.empty())
    {
        for (std::vector<Layer*>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
        {
            Layer* pLayer = *layer;
            if (pLayer != NULL)
            {
                mpAoiSelect->addItem(QString::fromStdString(pLayer->getName()));
            }
        }
    }

    mpBandSelect = new QListWidget(this);
    mpBandSelect->setResizeMode(QListView::Adjust);
    mpBandSelect->setFlow(QListWidget::TopToBottom);
    mpBandSelect->setUniformItemSizes(true);
    mpBandSelect->setSelectionMode(QListWidget::ExtendedSelection);
    if (pElement != NULL)
    {
        const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(pElement->getDataDescriptor());
        VERIFYNRV(pDescriptor != NULL);
        const std::vector<DimensionDescriptor>& bands = pDescriptor->getBands();
        for (std::vector<DimensionDescriptor>::const_iterator bandIter = bands.begin();
                bandIter != bands.end();
                ++bandIter)
        {
            mpBandSelect->addItem(QString::fromStdString(RasterUtilities::getBandName(pDescriptor, *bandIter)));
        }
    }
    mpBandSelect->setWrapping(true);
    if (mpBandSelect->count() > 0)
    {
        mpBandSelect->item(0)->setSelected(true);
    }
    QDialogButtonBox* pButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
            Qt::Horizontal, this);

    QGridLayout* pLayout = new QGridLayout(this);
    pLayout->addWidget(new QLabel("Select spatial subset:", this), 1, 0);
    pLayout->addWidget(mpAoiSelect, 1, 1);
    pLayout->addWidget(new QLabel("Select band subset:", this), 2, 0);
    pLayout->addWidget(mpBandSelect, 3, 0, 1, 2);
    pLayout->setRowStretch(3, 1);
    pLayout->setColumnStretch(1, 1);
    pLayout->addWidget(pButtons, 4, 0, 1, 2);

    VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(accept())));
    VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(reject())));
}
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);
      }
   }
}