void AxisPlot::DrawAxesArray(wxDC &dc, wxRect rc, AxisArray *axes, bool vertical)
{
	wxRect rcAxis(rc);

	for (size_t nAxis = 0; nAxis < axes->Count(); nAxis++) {
		Axis *axis = (*axes)[nAxis];
		wxCoord ext = axis->GetExtent(dc);

		if (vertical) {
			rcAxis.width = ext;
		}
		else {
			rcAxis.height = ext;
		}

		axis->Draw(dc, rcAxis);

		if (vertical) {
			rcAxis.x += ext;
		}
		else {
			rcAxis.y += ext;
		}
	}
}
/** Set up the output workspace in a Workspace2D
  * @param numentries :: number of log entries to output
  * @param times :: vector of Kernel::DateAndTime
  * @param values :: vector of log value in double
  */
void ExportTimeSeriesLog::setupWorkspace2D(int numentries,
                                           vector<DateAndTime> &times,
                                           vector<double> values) {
  Kernel::DateAndTime runstart(
      m_dataWS->run().getProperty("run_start")->value());

  size_t size = static_cast<size_t>(numentries);
  m_outWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
      WorkspaceFactory::Instance().create("Workspace2D", 1, size, size));
  if (!m_outWS)
    throw runtime_error(
        "Unable to create a Workspace2D casted to MatrixWorkspace.");

  MantidVec &vecX = m_outWS->dataX(0);
  MantidVec &vecY = m_outWS->dataY(0);
  MantidVec &vecE = m_outWS->dataE(0);

  for (size_t i = 0; i < size; ++i) {
    int64_t dtns = times[i].totalNanoseconds() - runstart.totalNanoseconds();
    vecX[i] = static_cast<double>(dtns) * 1.0E-9;
    vecY[i] = values[i];
    vecE[i] = 0.0;
  }

  Axis *xaxis = m_outWS->getAxis(0);
  xaxis->setUnit("Time");

  return;
}
Beispiel #3
0
TH2* RootWriter::CreateTH2(Histogram2D* h)
{
    const Axis& xax = h->GetAxisX(), yax = h->GetAxisY();
    const int xchannels = xax.GetBinCount();
    const int ychannels = yax.GetBinCount();
    TH2* mat = new TH2F( h->GetName().c_str(), h->GetTitle().c_str(),
                         xchannels, xax.GetLeft(), xax.GetRight(),
                         ychannels, yax.GetLeft(), yax.GetRight() );
    mat->SetOption( "colz" );
    mat->SetContour( 64 );

    TAxis* rxax = mat->GetXaxis();
    rxax->SetTitle(xax.GetTitle().c_str());
    rxax->SetTitleSize(0.03);
    rxax->SetLabelSize(0.03);

    TAxis* ryax = mat->GetYaxis();
    ryax->SetTitle(yax.GetTitle().c_str());
    ryax->SetTitleSize(0.03);
    ryax->SetLabelSize(0.03);
    ryax->SetTitleOffset(1.3);

    TAxis* zax = mat->GetZaxis();
    zax->SetLabelSize(0.025);

    for(int iy=0; iy<ychannels+2; ++iy)
        for(int ix=0; ix<xchannels+2; ++ix)
            mat->SetBinContent(ix, iy, h->GetBinContent(ix, iy));
    mat->SetEntries( h->GetEntries() );

    return mat;
}
Beispiel #4
0
void Pulsar::ComponentModel::evaluate (float *vals,
				       unsigned nvals, int icomp_selected) 
{
  //Construct the summed model
  SumRule< Univariate<Scalar> > m; 
  if (icomp_selected >= 0)
  {
    check ("evaluate", icomp_selected);
    m += components[icomp_selected];
  }
  else
  {
    for (unsigned icomp=0; icomp < components.size(); icomp++)
      m += components[icomp];
  }

  // evaluate
  Axis<double> argument;  
  m.set_argument (0, &argument);

  for (unsigned i=0; i < nvals; i++)
  { 
    argument.set_value( (i+0.5)/nvals * 2*M_PI );
    vals[i] = m.evaluate();
  }
}
Beispiel #5
0
  void update(float delta)
  {
    x_axis->update(delta);
    y_axis->update(delta);
    if (speed_button) speed_button->update(delta);

    Vector2f new_pos = pos;
    float c_speed = speed;
    
    if (speed_button && speed_button->get_state() == BUTTON_PRESSED)
    {
      c_speed *= 5.0f;
    }

    new_pos.x += x_axis->get_pos() * c_speed * delta;
    new_pos.y += y_axis->get_pos() * c_speed * delta;

    // FIXME: shouldn't depend on Display
    new_pos.x = Math::clamp(0.0f, new_pos.x, static_cast<float>(Display::get_width()));
    new_pos.y = Math::clamp(0.0f, new_pos.y, static_cast<float>(Display::get_height()));

    if (new_pos != pos)
    {
      pos = new_pos;
      notify_parent();
    }
  }
Beispiel #6
0
int Graph::createAxis(int objc, Tcl_Obj* const objv[])
{
  char *string = Tcl_GetString(objv[3]);
  if (string[0] == '-') {
    Tcl_AppendResult(interp_, "name of axis \"", string, 
		     "\" can't start with a '-'", NULL);
    return TCL_ERROR;
  }

  int isNew;
  Tcl_HashEntry* hPtr = Tcl_CreateHashEntry(&axes_.table, string, &isNew);
  if (!isNew) {
    Tcl_AppendResult(interp_, "axis \"", string, "\" already exists in \"",
		     Tcl_GetString(objv[0]), "\"", NULL);
    return TCL_ERROR;
  }

  Axis* axisPtr = new Axis(this, Tcl_GetString(objv[3]), MARGIN_NONE, hPtr);
  if (!axisPtr)
    return TCL_ERROR;

  Tcl_SetHashValue(hPtr, axisPtr);

  if ((Tk_InitOptions(interp_, (char*)axisPtr->ops(), axisPtr->optionTable(), tkwin_) != TCL_OK) || (AxisObjConfigure(axisPtr, interp_, objc-4, objv+4) != TCL_OK)) {
    delete axisPtr;
    return TCL_ERROR;
  }

  return TCL_OK;
}
void Pulsar::ComponentModel::evaluate (float *vals,
				       unsigned nvals, int icomp_selected) 
{
  double phase_offset = 0;
  if (report_absolute_phases)
    phase_offset = phase->get_value().val;

  if (verbose)
    cerr << "Pulsar::ComponentModel::evaluate"
      " phase_offset=" << phase_offset/(2*M_PI) << " turns" << endl;
  
  //Construct the summed model
  SumRule< Univariate<Scalar> > m; 
  if (icomp_selected >= 0)
  {
    check ("evaluate", icomp_selected);
    m += components[icomp_selected];
  }
  else
  {
    for (unsigned icomp=0; icomp < components.size(); icomp++)
      m += components[icomp];
  }

  // evaluate
  Axis<double> argument;  
  m.set_argument (0, &argument);

  for (unsigned i=0; i < nvals; i++)
  { 
    argument.set_value( (i+0.5)/nvals * 2*M_PI + phase_offset );
    vals[i] = m.evaluate();
  }
}
Beispiel #8
0
void wxChartPanel::OnScrollWin(wxScrollWinEvent &ev)
{
    if (m_chart == NULL) {
        return ;
    }

    Axis *axis = NULL;

    switch (ev.GetOrientation()) {
    case wxHORIZONTAL:
        axis = m_chart->GetHorizScrolledAxis();
        break;
    case wxVERTICAL:
        axis = m_chart->GetVertScrolledAxis();
        break;
    default: // BUG
        return ;
    }

    if (axis != NULL) {
        double winPos = (double) ev.GetPosition() / (double) stepMult;
        double minValue, maxValue;

        axis->GetDataBounds(minValue, maxValue);
        winPos += minValue;

        axis->SetWindowPosition(winPos);
    }
    ev.Skip();
}
Beispiel #9
0
Axis* Graph::nearestAxis(int x, int y)
{
  Tcl_HashSearch cursor;
  for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor); 
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    AxisOptions* ops = (AxisOptions*)axisPtr->ops();
    if (ops->hide || !axisPtr->use_)
      continue;

    if (ops->showTicks) {
      for (ChainLink* link = Chain_FirstLink(axisPtr->tickLabels_); link;
	   link = Chain_NextLink(link)) {	
	TickLabel *labelPtr = (TickLabel*)Chain_GetValue(link);
	double rw, rh;
	Point2d bbox[5];
	getBoundingBox(labelPtr->width, labelPtr->height, ops->tickAngle,
		       &rw, &rh, bbox);
	Point2d t;
	t = anchorPoint(labelPtr->anchorPos.x, labelPtr->anchorPos.y,
			rw, rh, axisPtr->tickAnchor_);
	t.x = x - t.x - (rw * 0.5);
	t.y = y - t.y - (rh * 0.5);

	bbox[4] = bbox[0];
	if (pointInPolygon(&t, bbox, 5)) {
	  return axisPtr;
	}
      }
    }

    if (ops->title) {
      int w, h;
      double rw, rh;
      Point2d bbox[5];
      getTextExtents(ops->titleFont, ops->title, -1, &w, &h);
      getBoundingBox(w, h, axisPtr->titleAngle_, &rw, &rh, bbox);
      Point2d t = anchorPoint(axisPtr->titlePos_.x, axisPtr->titlePos_.y, 
			      rw, rh, axisPtr->titleAnchor_);
      // Translate the point so that the 0,0 is the upper left 
      // corner of the bounding box
      t.x = x - t.x - (rw * 0.5);
      t.y = y - t.y - (rh * 0.5);
	    
      bbox[4] = bbox[0];
      if (pointInPolygon(&t, bbox, 5)) {
	return axisPtr;
      }
    }
    if (ops->lineWidth > 0) {
      if ((x <= axisPtr->right_) && (x >= axisPtr->left_) && 
	  (y <= axisPtr->bottom_) && (y >= axisPtr->top_)) {
	return axisPtr;
      }
    }
  }

  return NULL;
}
Beispiel #10
0
ClientData Graph::pickEntry(int xx, int yy, ClassId* classIdPtr)
{
  if (flags & (LAYOUT | MAP_MARKERS)) {
    *classIdPtr = CID_NONE;
    return NULL;
  }

  // Sample coordinate is in one of the graph margins. Can only pick an axis.
  Region2d exts;
  extents(&exts);
  if (xx>=exts.right || xx<exts.left || yy>=exts.bottom || yy<exts.top) {
    Axis* axisPtr = nearestAxis(xx, yy);
    if (axisPtr) {
      *classIdPtr = axisPtr->classId();
      return axisPtr;
    }
  }

  // From top-to-bottom check:
  // 1. markers drawn on top (-under false).
  // 2. elements using its display list back to front.
  // 3. markers drawn under element (-under true).
  Marker* markerPtr = nearestMarker(xx, yy, 0);
  if (markerPtr) {
    *classIdPtr = markerPtr->classId();
    return markerPtr;
  }

  GraphOptions* ops = (GraphOptions*)ops_;
  ClosestSearch* searchPtr = &ops->search;
  searchPtr->index = -1;
  searchPtr->x = xx;
  searchPtr->y = yy;
  searchPtr->dist = (double)(searchPtr->halo + 1);
	
  for (ChainLink* link = Chain_LastLink(elements_.displayList); link;
       link = Chain_PrevLink(link)) {
    Element* elemPtr = (Element*)Chain_GetValue(link);
    ElementOptions* eops = (ElementOptions*)elemPtr->ops();
    if (eops->hide)
      continue;
    elemPtr->closest();
  }

  // Found an element within the minimum halo distance.
  if (searchPtr->dist <= (double)searchPtr->halo) {
    *classIdPtr = searchPtr->elemPtr->classId();
    return searchPtr->elemPtr;
  }

  markerPtr = nearestMarker(xx, yy, 1);
  if (markerPtr) {
    *classIdPtr = markerPtr->classId();
    return markerPtr;
  }

  *classIdPtr = CID_NONE;
  return NULL;
}
Beispiel #11
0
void Graph::configureAxes()
{
  Tcl_HashSearch cursor;
  for (Tcl_HashEntry *hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    axisPtr->configure();
  }
}
Beispiel #12
0
void Graph::printAxesLimits(PSOutput* psPtr)
{
  Tcl_HashSearch cursor;
  for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    axisPtr->printLimits(psPtr);
  }
}
Beispiel #13
0
/** Creates the output workspace, setting the X vector to the bins boundaries in
 * Qx.
 *  @return A pointer to the newly-created workspace
 */
API::MatrixWorkspace_sptr
Qxy::setUpOutputWorkspace(API::MatrixWorkspace_const_sptr inputWorkspace) {
  const double max = getProperty("MaxQxy");
  const double delta = getProperty("DeltaQ");

  int bins = static_cast<int>(max / delta);
  if (bins * delta != max)
    ++bins; // Stop at first boundary past MaxQxy if max is not a multiple of
            // delta
  const double startVal = -1.0 * delta * bins;
  bins *= 2; // go from -max to +max
  bins += 1; // Add 1 - this is a histogram

  // Create an output workspace with the same meta-data as the input
  MatrixWorkspace_sptr outputWorkspace = WorkspaceFactory::Instance().create(
      inputWorkspace, bins - 1, bins, bins - 1);
  // ... but clear the masking from the parameter map as we don't want to carry
  // that over since this is essentially
  // a 2D rebin
  ParameterMap &pmap = outputWorkspace->instrumentParameters();
  pmap.clearParametersByName("masked");

  // Create a numeric axis to replace the vertical one
  Axis *verticalAxis = new BinEdgeAxis(bins);
  outputWorkspace->replaceAxis(1, verticalAxis);

  // Build up the X values
  Kernel::cow_ptr<MantidVec> axis;
  MantidVec &horizontalAxisRef = axis.access();
  horizontalAxisRef.resize(bins);
  for (int i = 0; i < bins; ++i) {
    const double currentVal = startVal + i * delta;
    // Set the X value
    horizontalAxisRef[i] = currentVal;
    // Set the Y value on the axis
    verticalAxis->setValue(i, currentVal);
  }

  // Fill the X vectors in the output workspace
  for (int i = 0; i < bins - 1; ++i) {
    outputWorkspace->setX(i, axis);
    for (int j = 0; j < bins - j; ++j) {
      outputWorkspace->dataY(i)[j] = std::numeric_limits<double>::quiet_NaN();
      outputWorkspace->dataE(i)[j] = std::numeric_limits<double>::quiet_NaN();
    }
  }

  // Set the axis units
  outputWorkspace->getAxis(1)->unit() = outputWorkspace->getAxis(0)->unit() =
      UnitFactory::Instance().create("MomentumTransfer");
  // Set the 'Y' unit (gets confusing here...this is probably a Z axis in this
  // case)
  outputWorkspace->setYUnitLabel("Cross Section (1/cm)");

  setProperty("OutputWorkspace", outputWorkspace);
  return outputWorkspace;
}
Beispiel #14
0
void Graph::drawAxesLimits(Drawable drawable)
{
  Tcl_HashSearch cursor;
  for (Tcl_HashEntry* hPtr=Tcl_FirstHashEntry(&axes_.table, &cursor);
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    axisPtr->drawLimits(drawable);
  }
}
Beispiel #15
0
void RegionLoad::UpdateRegions()
{
	//Define all regions actors

	//Reset axis (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
	int xAxisAnt, yAxisAnt;
	double scaleAnt;
	Axis *pAxis = GameControl::Get()->GetAxis();

	scaleAnt = pAxis->getScale();	
	xAxisAnt = pAxis->getImage()->X();
	yAxisAnt = pAxis->getImage()->Y();

	pAxis->SetScale(1.0);
	pAxis->SetPos(0, 0);
	pAxis->getImage()->Invalidate();

	//Define actors
	MapRegionsIterator it(regions);
	RegionLoad *pRegion;
	for( it.Begin(); !it.Done(); it.Next() )
	{
		pRegion = *it.Key();
		pRegion->DefineActors();
	}

	SetDefaultRegionView();

	//Restore axis (Solve the bug "Game behavior differ based on editor grid position when uses regions", ALPHA_1_1_4.ged)
	pAxis->SetScale(scaleAnt);
	pAxis->SetPos(xAxisAnt, yAxisAnt);	
	pAxis->getImage()->Invalidate();
	
}
Beispiel #16
0
  // ************************************************ Window::recompute_axis_y
  void recompute_axis_y( int key )
  {
	// Re-compute Y-Axis
	_axis_y = Axis{ "Y", {0.0, 1.0, 5, 2} };
	  
	for( auto& pt: _c_sim_convol.get_samples()) {
	  _axis_y.get_range().update( pt.y );
	}

	std::cout << "New AxisY: " << _axis_y.get_range()._min << ", " << _axis_y.get_range()._max << std::endl;
  }
Beispiel #17
0
void Graph::printAxes(PSOutput* psPtr) 
{
  GraphOptions* ops = (GraphOptions*)ops_;

  for (Margin *mp = ops->margins, *mend = mp + 4; mp < mend; mp++) {
    for (ChainLink* link = Chain_FirstLink(mp->axes); link; 
	 link = Chain_NextLink(link)) {
      Axis *axisPtr = (Axis*)Chain_GetValue(link);
      axisPtr->print(psPtr);
    }
  }
}
Beispiel #18
0
void Graph::drawAxes(Drawable drawable)
{
  GraphOptions* ops = (GraphOptions*)ops_;

  for (int ii=0; ii<4; ii++) {
    for (ChainLink* link = Chain_LastLink(ops->margins[ii].axes); link;
	 link = Chain_PrevLink(link)) {
      Axis *axisPtr = (Axis*)Chain_GetValue(link);
      axisPtr->draw(drawable);
    }
  }
}
Beispiel #19
0
void Graph::printAxesGrids(PSOutput* psPtr) 
{
  GraphOptions* ops = (GraphOptions*)ops_;

  for (int ii=0; ii<4; ii++) {
    for (ChainLink* link = Chain_FirstLink(ops->margins[ii].axes); link;
	 link = Chain_NextLink(link)) {
      Axis *axisPtr = (Axis*)Chain_GetValue(link);
      axisPtr->printGrids(psPtr);
    }
  }
}
Beispiel #20
0
/** Set up the output workspace in a Workspace2D
 * @brief ExportTimeSeriesLog::setupWorkspace2D
 * @param start_index :: array index for the first log entry
 * @param stop_index :: array index for the last log entry
 * @param numentries :: number of log entries to output
 * @param times :: vector of Kernel::DateAndTime
 * @param values :: vector of log value in double
 * @param epochtime :: flag to output time in epoch time/absolute time
 * @param timeunitfactor :: conversion factor for various unit of time for
 * output
 */
void ExportTimeSeriesLog::setupWorkspace2D(
    const size_t &start_index, const size_t &stop_index, int numentries,
    vector<DateAndTime> &times, vector<double> values, const bool &epochtime,
    const double &timeunitfactor) {
  // Determine time shift
  int64_t timeshift(0);
  if (!epochtime) {
    // relative time
    Kernel::DateAndTime runstart(
        m_inputWS->run().getProperty("run_start")->value());
    timeshift = runstart.totalNanoseconds();
  }

  // Determine the size
  size_t outsize = stop_index - start_index + 1;
  if (outsize > static_cast<size_t>(numentries))
    outsize = static_cast<size_t>(numentries);

  // Create 2D workspace
  m_outWS = boost::dynamic_pointer_cast<MatrixWorkspace>(
      WorkspaceFactory::Instance().create("Workspace2D", 1, outsize, outsize));
  if (!m_outWS)
    throw runtime_error(
        "Unable to create a Workspace2D casted to MatrixWorkspace.");

  MantidVec &vecX = m_outWS->dataX(0);
  MantidVec &vecY = m_outWS->dataY(0);
  MantidVec &vecE = m_outWS->dataE(0);

  for (size_t index = 0; index < outsize; ++index) {
    size_t i_time = index + start_index;
    // safety check
    if (i_time >= times.size()) {
      std::stringstream errss;
      errss << "It shouldn't happen that the index is out of boundary."
            << "start index = " << start_index << ", output size = " << outsize
            << ", index = " << index << "\n";
      throw std::runtime_error(errss.str());
    }

    int64_t dtns = times[i_time].totalNanoseconds() - timeshift;
    vecX[index] = static_cast<double>(dtns) * timeunitfactor;
    vecY[index] = values[i_time];
    vecE[index] = 0.0;
  }

  Axis *xaxis = m_outWS->getAxis(0);
  xaxis->setUnit("Time");

  return;
}
Beispiel #21
0
void SpaceND::ProceedPanAt(double rx, double ry)
{
	DPRINTF("SpaceND::ProceedPanAt\n");

	Axis *xaxis;
	Axis *yaxis;
	xaxis = m_axes[AXIS_X];//let x be 1st dimension
	yaxis = m_axes[AXIS_Y];//let y be 2nd dimension


//TO DO: need to review this code
	if (xaxis != NULL)
	{
		xaxis->SetOffset(m_pan_start_at_vx - xaxis->GetRange() * (rx - m_pan_start_at_rx));
		xaxis->PropagateToCommonScale();
	}


	if (yaxis != NULL)
	{
		yaxis->SetOffset(m_pan_start_at_vy - yaxis->GetRange() * (ry - m_pan_start_at_ry));
		yaxis->PropagateToCommonScale();
	}

}
/**
  * Checks that X axis is in the right direction.
  *
  * @param value The workspace to check
  * @return "" if is valid, otherwise a user level description of a problem
  */
std::string IncreasingAxisValidator::checkValidity(
    const MatrixWorkspace_sptr &value) const {
  // 0 for X axis
  Axis *xAxis = value->getAxis(0);

  // Left-most axis value should be less than the right-most, if ws has
  // more than one X axis value
  if (xAxis->length() > 1 &&
      xAxis->getValue(0) >= xAxis->getValue(xAxis->length() - 1))
    return "X axis of the workspace should be increasing from left to "
           "right";
  else
    return "";
}
Beispiel #23
0
void Graph::resetAxes()
{
  // Step 1:  Reset all axes. Initialize the data limits of the axis to
  // impossible values.
  Tcl_HashSearch cursor;
  for (Tcl_HashEntry* hPtr = Tcl_FirstHashEntry(&axes_.table, &cursor);
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    axisPtr->min_ = axisPtr->valueRange_.min = DBL_MAX;
    axisPtr->max_ = axisPtr->valueRange_.max = -DBL_MAX;
  }

  // Step 2:  For each element that's to be displayed, get the smallest
  // and largest data values mapped to each X and Y-axis.  This
  // will be the axis limits if the user doesn't override them 
  // with -min and -max options.
  for (ChainLink* link = Chain_FirstLink(elements_.displayList); link;
       link = Chain_NextLink(link)) {
    Region2d exts;

    Element* elemPtr = (Element*)Chain_GetValue(link);
    ElementOptions* elemops = (ElementOptions*)elemPtr->ops();
    elemPtr->extents(&exts);
    elemops->xAxis->getDataLimits(exts.left, exts.right);
    elemops->yAxis->getDataLimits(exts.top, exts.bottom);
  }

  // Step 3:  Now that we know the range of data values for each axis,
  // set axis limits and compute a sweep to generate tick values.
  for (Tcl_HashEntry* hPtr = Tcl_FirstHashEntry(&axes_.table, &cursor);
       hPtr; hPtr = Tcl_NextHashEntry(&cursor)) {
    Axis *axisPtr = (Axis*)Tcl_GetHashValue(hPtr);
    AxisOptions* ops = (AxisOptions*)axisPtr->ops();
    axisPtr->fixRange();

    double min = axisPtr->min_;
    double max = axisPtr->max_;
    if ((!isnan(axisPtr->scrollMin_)) && (min < axisPtr->scrollMin_))
      min = axisPtr->scrollMin_;

    if ((!isnan(axisPtr->scrollMax_)) && (max > axisPtr->scrollMax_))
      max = axisPtr->scrollMax_;

    if (ops->logScale)
      axisPtr->logScale(min, max);
    else
      axisPtr->linearScale(min, max);
  }
}
Beispiel #24
0
void UpdateAxisActionJob::updateAxis(LogicalDevice *device)
{
    const auto axisIds = device->axes();
    for (const Qt3DCore::QNodeId axisId : axisIds) {
        Axis *axis = m_handler->axisManager()->lookupResource(axisId);
        float axisValue = 0.0f;

        const auto axisInputIds = axis->inputs();
        for (const Qt3DCore::QNodeId axisInputId : axisInputIds)
            axisValue += processAxisInput(axisInputId);

        // Clamp the axisValue -1/1
        axisValue = qMin(1.0f, qMax(axisValue, -1.0f));
        axis->setAxisValue(axisValue);
    }
}
Beispiel #25
0
bool
AndroidFlingAnimation::CheckBounds(Axis& aAxis, float aValue, float aDirection, float* aClamped)
{
  if ((aDirection < 0.0f) && (aValue <= aAxis.GetPageStart().value)) {
    if (aClamped) {
      *aClamped = aAxis.GetPageStart().value;
    }
    return true;
  } else if ((aDirection > 0.0f) && (aValue >= aAxis.GetScrollRangeEnd().value)) {
    if (aClamped) {
      *aClamped = aAxis.GetScrollRangeEnd().value;
    }
    return true;
  }
  return false;
}
Beispiel #26
0
void GraphPane::PickScale(QPainter *g, float scaleFactor)
{

    int maxTics = 0;

    _xAxis->scale()->PickScale( this, g, scaleFactor );
    _x2Axis->scale()->PickScale( this, g, scaleFactor );


    for(unsigned int i = 0; i < _yAxisList->length(); i++)
    {
        Axis* axis = _yAxisList->at(i);
        axis->scale()->PickScale(this,g,scaleFactor);
    }

    //        foreach ( Axis axis in _yAxisList )
    //        {
    //            axis._scale.PickScale( this, g, scaleFactor );
    //            if ( axis._scale.MaxAuto )
    //            {
    //                int nTics = axis._scale.CalcNumTics();
    //                maxTics = nTics > maxTics ? nTics : maxTics;
    //            }
    //        }
    //        foreach ( Axis axis in _y2AxisList )
    //        {
    //            axis._scale.PickScale( this, g, scaleFactor );
    //            if ( axis._scale.MaxAuto )
    //            {
    //                int nTics = axis._scale.CalcNumTics();
    //                maxTics = nTics > maxTics ? nTics : maxTics;
    //            }
    //        }

    //        if ( _isAlignGrids )
    //        {
    //            foreach ( Axis axis in _yAxisList )
    //                ForceNumTics( axis, maxTics );

    //            foreach ( Axis axis in _y2AxisList )
    //                ForceNumTics( axis, maxTics );
    //        }


}
Beispiel #27
0
/** Check if two axis defined as spectra or numeric axis are equivalent
 *  @param axis2 :: Reference to the axis to compare to
 *  @return true is self and second axis are equal
 */
bool RefAxis::operator==(const Axis &axis2) const {
  if (length() != axis2.length()) {
    return false;
  }
  const RefAxis *ra2 = dynamic_cast<const RefAxis *>(&axis2);
  if (!ra2) {
    return false;
  }
  return true;
}
/**
*  @brief
*    Test: Controller
*/
void Application30::TestController()
{
	// Start
	System::GetInstance()->GetConsole().Print("Controller 'GameBoy'\n");
	System::GetInstance()->GetConsole().Print('\n');

	// Create test controller
	GameBoyController cController;

	// List all controls
	System::GetInstance()->GetConsole().Print("Controls:\n");
	const List<Control*> &lstControls = cController.GetControls();
	for (uint32 i=0; i<lstControls.GetNumOfElements(); i++) {
		// Get control
		Control *pControl = lstControls[i];
		if (pControl->GetType() == ControlButton)
			System::GetInstance()->GetConsole().Print("- Button '" + pControl->GetName() + "' [" + pControl->GetDescription() + "]\n");
		else if (pControl->GetType() == ControlAxis)
			System::GetInstance()->GetConsole().Print("- Axis   '" + pControl->GetName() + "' [" + pControl->GetDescription() + "]\n");
	}
	System::GetInstance()->GetConsole().Print('\n');

	// List buttons
	System::GetInstance()->GetConsole().Print("Buttons:\n");
	const List<Button*> &lstButtons = cController.GetButtons();
	for (uint32 i=0; i<lstButtons.GetNumOfElements(); i++) {
		Button *pButton = lstButtons[i];
		System::GetInstance()->GetConsole().Print("- Button   '" + pButton->GetName() + "' [" + pButton->GetDescription() + "]\n");
	}
	System::GetInstance()->GetConsole().Print('\n');

	// List axes
	System::GetInstance()->GetConsole().Print("Axes:\n");
	const List<Axis*> &lstAxes = cController.GetAxes();
	for (uint32 i=0; i<lstAxes.GetNumOfElements(); i++) {
		Axis *pAxis = lstAxes[i];
		System::GetInstance()->GetConsole().Print("- Axis '" + pAxis->GetName() + "' [" + pAxis->GetDescription() + "]\n");
	}
	System::GetInstance()->GetConsole().Print('\n');

	// Done
	System::GetInstance()->GetConsole().Print('\n');
}
Beispiel #29
0
void PlotArea::Private::initAxes()
{
    // The category data region is anchored to an axis and will be set on addAxis if the
    // axis defines the Axis::categoryDataRegion(). So, clear it now.
    q->proxyModel()->setCategoryDataRegion(CellRegion());
    // Remove all old axes
    while(!axes.isEmpty()) {
        Axis *axis = axes.takeLast();
        Q_ASSERT(axis);
        if (axis->title())
            automaticallyHiddenAxisTitles.removeAll(axis->title());
        delete axis;
    }
    // There need to be at least these two axes. Their constructor will
    // automatically add them to the plot area as child shape.
    new Axis(q, XAxisDimension);
    Axis *yAxis = new Axis(q, YAxisDimension);
    yAxis->setShowMajorGrid(true);
}
Beispiel #30
0
  void update(float delta_)
  {
    x_axis->update(delta_);
    y_axis->update(delta_);

    if (speed_button) speed_button->update(delta_);

    float    c_speed = speed;
    
    if (speed_button && speed_button->get_state() == BUTTON_PRESSED)
    {
      c_speed *= 5.0f;
    }

    this->delta.x = -x_axis->get_pos() * c_speed * delta_;
    this->delta.y = y_axis->get_pos() * c_speed * delta_;

    notify_parent();
  }