示例#1
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);
      }
   }
}
示例#2
0
PlotWidget* PlotSetImp::getPlot(const QString& strPlotName) const
{
   if (strPlotName.isEmpty() == true)
   {
      return NULL;
   }

   for (int i = 0; i < count(); i++)
   {
      PlotWidget* pPlotWidget = dynamic_cast<PlotWidget*>(widget(i));
      if (pPlotWidget != NULL)
      {
         QString strCurrentName = QString::fromStdString(pPlotWidget->getName());
         if (strCurrentName == strPlotName)
         {
            return pPlotWidget;
         }
      }
   }

   return NULL;
}