Interactor Action

This page doesn't focus on intercepting button clicks that drive the query interactors (i.e. lineout and pick). Instead, it describes how to do something once that interactor starts its action.

Hooking in

The interactors ultimately end up in the ViewerQueryManager.

  • For pick, the method is ComputePick
  • For lineout, the method is StartLineout


Figuring out what plots are active

You can figure out what the active plots are with code like this:

        // Window encoded in callback data.
        ViewerWindow *win = (ViewerWindow *)pd.callbackData;
        
        ViewerPlotList *plist = win->GetPlotList();
        intVector plotIDs;
        plist->GetActivePlotIDs(plotIDs);
        
        //
        // Is there an active non-hidden plot in the originating window?
        //
        if (plotIDs.size() == 0)
        {
            msg = "PICK requires an active non-hidden Plot.\n";
            msg += "Please select a plot and try again.\n";
            Error(msg.c_str());
            return retval ;
        }
        
        // Use the first plot.
        int plotId = plotIDs[0];
        ViewerPlot *plot = plist->GetPlot(plotId);

Doing something

You can do your action from inside ComputePick or StartLineout. (Note that this isn't very extensible, but rather how it is currently done ... some infrastructure here would be helpful.)

Here's some example code that creates a Histogram plot and uses the results of the Pick to set the HistogramAttributes.

Note that as of VisIt 1.10, the plugin managers are not singletons and cannot be called via an Instance() method. In the viewer, one would simply call the GetPlotPluginManager() method to obtain the pointer to the viewer's plot plugin manager.

 // Decide which window to put the plot into.
 int winId = win->GetWindowId();
 ViewerWindow *resWin = ViewerWindowManager::Instance()->GetTimeQueryWindow(-1);
 if (resWin == NULL)
 {
    Error("Please choose a different window to place the histogram"
          " of the array variable into.");
    return retval;
 }
   
 // See if the plugin is available.
 if (!PlotPluginManager::Instance()->PluginAvailable("Histogram_1.0"))
 {
      static bool issuedWarning = false;
      Error("Could not create a histogram of the array variable, "
            "because the Histogram plugin is not available.");
      issuedWarning = true;
      return retval;
 }
 
 // Skipping subtleties with the time slider (for this example) and just adding the plot.
 int pid = plotList->AddPlot(plotType,arrayname,replacePlots,false);
 ViewerPlot *resultsPlot = plotList->GetPlot(pid);
  
 // This is a bit subtle.  We are sending the pick attributes in
 // as the plot attributes.  Normally, plot plugins blindly copy
 // the attributes from this method.  But the histogram plot is
 // smart enough to check to see if the atts are histogram atts.
 // If they are not histogram atts, and they *are* pick atts, then
 // it will pull out the zone and domain.  Note that this is a very
 // similar game plan to what lineout does for the curve plot.
 resultsPlot->SetPlotAtts(pickAtts);
 
 if (resultsPlot == NULL)
 {
     // There was an error somewhere else ... arrayname not valid?
     return retval;
 }
 TRY
 {
     plotList->RealizePlots();
     //
     // If there was an error, the bad curve plot should not be left
     // around muddying up the waters.
     //
     if (resultsPlot->GetErrorFlag())
          plotList->DeletePlot(resultsPlot, false);
 }
 CATCH2(VisItException, e)
 {
    plotList->DeletePlot(resultsPlot, false);
 }
 ENDTRY