I am building a surface with 2 viewports and then trying to update both with 
real-time data. The problem I am having is that only the last viewport built 
gets data added to it. The data is correct and the plot looks good, except that 
only one chart has it. Here is a snippet of the code:

// In Cairo window constructor
{
...
// Initialize the surface and build the viewports
      mPLS = new plstream();

      // Re-size the device view surface to the size of the cairo window
      std::string geom(ATMLabUtils::Strings::ToString(this->w()) + "x" +
                                        
ATMLabUtils::Strings::ToString(this->h()));
      mPLS->setopt("-geometry", geom.c_str());

      mPLS->sdev("extcairo");
      //mPLS->star(2, 1);
      mPLS->init();

      mPLS->cmd(PLESC_DEVINIT, fltk::cr);

      mPLS->adv(0);

       // Create the viewports (see below for details of the UFMPlot class
      mPLS->vpor(0.1, 0.45, 0.15, 0.9);
      mPlots.push_back(UFMPlot(mPLS));

      mPLS->vpor(0.55, 0.9, 0.15, 0.9);
      mPlots.push_back(UFMPlot(mPLS));
...
}

// In Cairo window real-time update data capture call
{
...

      for(unsigned int i = 0; i < mPlots.size(); ++i)
      {
         //The values t and y2 are computed elsewhere and passed to this call
         mPlots[i].AddPoint(t, y2, 0);
      }
      //if ( n % 2 )
      //   mPLS->stripa( id1, 0, t, y1 );
      //if ( n % 3 )
      //    mPLS->stripa( id1, 1, t, y2 );
      //if ( n % 4 )
      //    mPLS->stripa( id1, 2, t, y3 );
      //if ( n % 5 )
      //    mPLS->stripa( id1, 3, t, y4 );
...
}


///// UFMPlot class snippet
         UFMPlot(plstream *pls) : mPLS(pls)
         {
            if(pls == NULL)
            {
               throw(std::string("UFMPlot() : You need a valid plstream 
reference."));
            }

            mPLS->col0(1);
            // scale the window to the data world coordinates and build the 
bounding box
            mPLS->wind(0.0, 100.0, -1.0, 1.0);
            mPLS->box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);

            mPLS->col0(2);
            mPLS->lab("time (sec)", "Signal", "Test plot");

            // Build a grid
            mPLS->box("g", 10.0, 0, "g", 0.1, 0);
            pX = pY = 0;
         }

         void AddPoint(PLFLT x, PLFLT y, PLINT pen)
         {
               mPLS->col0(4);

               // Store the data into stl vectors
               mData.Add(x, y, pen);

               unsigned int xc, yc;
               // These 2 calls return the pointer to the top of the x and y 
data vectors which is what plplot needs.
               PLFLT *X = mData.GetArray(UFMPlotDataSet::X, 0, pen, xc);
               PLFLT *Y = mData.GetArray(UFMPlotDataSet::Y, 0, pen, yc);
               unsigned int count = xc < yc ? xc : yc;
               mPLS->line(count, X, Y);
         }



-Marco
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Plplot-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-general

Reply via email to