PlotWidget* HistogramWindowImp::getPlot(RasterLayer* pLayer, RasterChannelType channel, bool ignoreStatisticsPlots) const { if (pLayer == NULL) { return NULL; } // Iterate over all histogram plots on all plot sets to find the plot vector<PlotWidget*> plots = mpPlotSetGroup->getPlots(HISTOGRAM_PLOT); for (vector<PlotWidget*>::iterator iter = plots.begin(); iter != plots.end(); ++iter) { PlotWidget* pPlot = *iter; if (pPlot != NULL) { HistogramPlotImp* pHistogramPlot = dynamic_cast<HistogramPlotImp*>(pPlot->getPlot()); if (pHistogramPlot != NULL && (!ignoreStatisticsPlots || !pHistogramPlot->ownsStatistics())) { RasterLayer* pCurrentLayer = dynamic_cast<RasterLayer*>(pHistogramPlot->getLayer()); if (pCurrentLayer == pLayer) { RasterChannelType currentChannel = pHistogramPlot->getRasterChannelType(); if (currentChannel == channel) { return pPlot; } } } } } return NULL; }
PlotWidget* PlotSetImp::createPlot(const QString& strPlotName, const PlotType& plotType) { if (strPlotName.isEmpty() == true) { return NULL; } // Do not create the plot if a plot with the given name already exists PlotWidget* pPlot = getPlot(strPlotName); if (pPlot != NULL) { return NULL; } // Create the plot widget pPlot = new PlotWidgetAdapter(SessionItemImp::generateUniqueId(), strPlotName.toStdString(), plotType, dynamic_cast<PlotSet*>(this), this); if (pPlot != NULL) { // Block undo actions from being added to the plot view PlotViewImp* pPlotView = dynamic_cast<PlotViewImp*>(pPlot->getPlot()); if (pPlotView != NULL) { pPlotView->blockUndo(); } // Add the plot widget to the plot set addPlot(pPlot); } return pPlot; }
PlotWidget* HistogramWindowImp::getPlot(Layer* pLayer) const { if (pLayer == NULL) { return NULL; } RasterLayer* pRasterLayer = dynamic_cast<RasterLayer*>(pLayer); if (pRasterLayer != NULL) { RasterChannelType channel = GRAY; if (pRasterLayer->getDisplayMode() == RGB_MODE) { channel = RED; } return getPlot(pRasterLayer, channel); } // Iterate over all histogram plots on all plot sets to find the plot vector<PlotWidget*> plots = mpPlotSetGroup->getPlots(HISTOGRAM_PLOT); for (vector<PlotWidget*>::iterator iter = plots.begin(); iter != plots.end(); ++iter) { PlotWidget* pPlot = *iter; if (pPlot != NULL) { HistogramPlotImp* pHistogramPlot = dynamic_cast<HistogramPlotImp*>(pPlot->getPlot()); if (pHistogramPlot != NULL) { Layer* pCurrentLayer = pHistogramPlot->getLayer(); if (pCurrentLayer == pLayer) { return pPlot; } } } } return NULL; }
vector<PlotWidget*> PlotSetImp::getPlots(const PlotType& plotType) const { vector<PlotWidget*> plots; for (int i = 0; i < count(); i++) { PlotWidget* pPlot = dynamic_cast<PlotWidget*>(widget(i)); if (pPlot != NULL) { PlotView* pPlotView = pPlot->getPlot(); if (pPlotView != NULL) { PlotType currentType = pPlotView->getPlotType(); if (currentType == plotType) { plots.push_back(pPlot); } } } } return plots; }
void HistogramWindowImp::updateContextMenu(Subject& subject, const string& signal, const boost::any& value) { ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value); if (pMenu == NULL) { return; } bool bAddActions = false; bool bRemoveActions = false; PlotWidget* pActionWidget = NULL; if (dynamic_cast<SessionExplorer*>(&subject) != NULL) { // Make sure all of the selected session items for the menu are plot widgets vector<SessionItem*> items = pMenu->getSessionItems(); 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 (mpPlotSetGroup->containsPlot(pPlot) == true) { if (plots.size() == 1) { bAddActions = true; pActionWidget = pPlot; } HistogramPlotImp* pHistogramPlot = dynamic_cast<HistogramPlotImp*>(pPlot->getPlot()); if (pHistogramPlot != NULL) { if (pHistogramPlot->getLayer() != NULL) { bRemoveActions = true; } } } else { return; } } } } else if (dynamic_cast<HistogramWindowImp*>(&subject) == this) { if (mpPlotSetGroup->getNumPlotSets() > 0) { bRemoveActions = true; } } else { PlotWidget* pPlotWidget = dynamic_cast<PlotWidget*>(&subject); if ((pPlotWidget != NULL) && (mpPlotSetGroup->containsPlot(pPlotWidget) == true)) { bAddActions = true; pActionWidget = pPlotWidget; } } // Add the sync zoom action if ((bAddActions == true) && (pActionWidget != NULL)) { HistogramPlotImp* pHistogramPlot = dynamic_cast<HistogramPlotImp*>(pActionWidget->getPlot()); if (pHistogramPlot != NULL) { RasterLayer* pLayer = dynamic_cast<RasterLayer*>(pHistogramPlot->getLayer()); if ((pLayer != NULL) && (pHistogramPlot->getRasterChannelType() != GRAY)) { mpSyncAutoZoomAction->setData(QVariant::fromValue(dynamic_cast<SessionItem*>(pHistogramPlot))); pMenu->addActionBefore(mpSyncAutoZoomAction, APP_HISTOGRAMPLOT_SYNCHRONIZE_AUTO_ZOOM_ACTION, APP_HISTOGRAMPLOT_RASTER_MENUS_SEPARATOR_ACTION); } } } // Remove the delete action if (bRemoveActions == true) { pMenu->removeAction(APP_PLOTSET_DELETE_ACTION); } // Add statistics actions if (bAddActions) { pMenu->addActionBefore(mpStatisticsShowAction, APP_HISTOGRAMPLOT_STATISTICS_ACTION, APP_HISTOGRAMPLOT_REFRESH_STATISTICS_ACTION); } }
bool PropertiesPlotView::initialize(SessionItem* pSessionItem) { mpPlotView = dynamic_cast<PlotView*>(pSessionItem); if (mpPlotView == NULL) { PlotWidget* pPlotWidget = dynamic_cast<PlotWidget*>(pSessionItem); if (pPlotWidget != NULL) { mpPlotView = pPlotWidget->getPlot(); } if (mpPlotView == NULL) { return false; } } // Gridlines CartesianPlot* pCartesianPlot = dynamic_cast<CartesianPlot*>(mpPlotView); if (pCartesianPlot != NULL) { Gridlines* pHorizGridlines = pCartesianPlot->getGridlines(HORIZONTAL); Gridlines* pVertGridlines = pCartesianPlot->getGridlines(VERTICAL); if ((pHorizGridlines != NULL) && (pVertGridlines != NULL)) { LineStyle lineStyle = pHorizGridlines->getLineStyle(); if (pVertGridlines->getLineStyle() == lineStyle) { mpStyleCombo->setCurrentValue(lineStyle); } int lineWidth = pHorizGridlines->getLineWidth(); if (pVertGridlines->getLineWidth() == lineWidth) { mpWidthCombo->setCurrentValue(lineWidth); } ColorType gridlineColor = pHorizGridlines->getColor(); if (pVertGridlines->getColor() == gridlineColor) { mpColorButton->setColor(gridlineColor); } return true; } } PolarPlot* pPolarPlot = dynamic_cast<PolarPlot*>(mpPlotView); if (pPolarPlot != NULL) { Gridlines* pGridlines = pPolarPlot->getGridlines(); if (pGridlines != NULL) { mpStyleCombo->setCurrentValue(pGridlines->getLineStyle()); mpWidthCombo->setCurrentValue(pGridlines->getLineWidth()); mpColorButton->setColor(pGridlines->getColor()); return true; } } return false; }