void QwtPlot::setAxisScaleDraw(int axisId, QwtScaleDraw *scaleDraw)
{
    if (axisValid(axisId))
    {
        axisWidget(axisId)->setScaleDraw(scaleDraw);
        autoRefresh();
    }
}
/*!
  \brief Transform a value into a coordinate in the plotting region
  \param axisId axis index
  \param value value
  \return X or y coordinate in the plotting region corresponding
          to the value.
*/
int QwtPlot::transform(int axisId, double value) const
{
    if (axisValid(axisId))
       return(canvasMap(axisId).transform(value));
    else
       return 0;
    
}
/*!
  \brief Enable autoscaling for a specified axis

  This member function is used to switch back to autoscaling mode
  after a fixed scale has been set. Autoscaling is enabled by default.

  \param axisId axis index
  \sa QwtPlot::setAxisScale(), QwtPlot::setAxisScaleDiv()
*/
void QwtPlot::setAxisAutoScale(int axisId)
{
    if (axisValid(axisId) && !d_axisData[axisId]->doAutoScale )
    {
        d_axisData[axisId]->doAutoScale = true;
        autoRefresh();
    }
}
/*!
  \return the font of the scale labels for a specified axis
  \param axisId axis index
*/
QFont QwtPlot::axisFont(int axisId) const
{
    if (axisValid(axisId))
        return axisWidget(axisId)->font();
    else
        return QFont();
    
}
/*!
  \brief Enable or disable a specified axis

  When an axis is disabled, this only means that it is not
  visible on the screen. Curves, markers and can be attached
  to disabled axes, and transformation of screen coordinates
  into values works as normal.

  Only xBottom and yLeft are enabled by default.
  \param axisId axis index
  \param tf \c true (enabled) or \c false (disabled)
*/
void QwtPlot::enableAxis(int axisId, bool tf)
{
    if (axisValid(axisId) && tf != d_axisData[axisId]->isEnabled)
    {
        d_axisData[axisId]->isEnabled = tf;
        updateLayout();
    }
}
/*!
  \return \c true if autoscaling is enabled
  \param axisId axis index
*/
bool QwtPlot::axisAutoScale(int axisId) const
{
    if (axisValid(axisId))
        return d_axisData[axisId]->doAutoScale;
    else
        return false;
    
}
Beispiel #7
0
/*!
  \brief Enable autoscaling for a specified axis

  This member function is used to switch back to autoscaling mode
  after a fixed scale has been set. Autoscaling is enabled by default.

  \param axisId axis index
  \param on On/Off
  \sa setAxisScale(), setAxisScaleDiv(), updateAxes()

  \note The autoscaling flag has no effect until updateAxes() is executed
        ( called by replot() ).
*/
void QwtPlot::setAxisAutoScale( int axisId, bool on )
{
    if ( axisValid( axisId ) && ( d_axisData[axisId]->doAutoScale != on ) )
    {
        d_axisData[axisId]->doAutoScale = on;
        autoRefresh();
    }
}
Beispiel #8
0
/*!
  Change the number format for the major scale of a selected axis
  \param axis axis index
  \param f format
  \param prec precision
*/
void Plot::setAxisLabelFormat(int axis, char f, int prec)
{
    if (axisValid(axis))
    {
        ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
        sd->setLabelFormat(f, prec);
    }
}
Beispiel #9
0
/**
  @return the number format for the major scale labels of a specified axis
  @param axis :: axis index
  @retval f format character
  @retval prec precision
  */
void Plot::axisLabelFormat(int axis, char &f, int &prec) const
{
	if (axisValid(axis)){
		const ScaleDraw *sd = (const ScaleDraw *)axisScaleDraw (axis);
		sd->labelFormat(f, prec);
	} else {//for a bad call we return the default values
		f = 'g';
		prec = 4;
	}
}
//TL added
QwtScaleEngine * QwtPlot::takeAxisScaleEngine(int axisId)
{
    if (axisValid(axisId)) {
	AxisData &d = *d_axisData[axisId];
	QwtScaleEngine * r = d.scaleEngine;
	d.scaleEngine = NULL;
	return r;
    }
    return NULL;
}
Beispiel #11
0
int Plot::axisLabelPrecision(int axis)
{
if (axisValid(axis))
	{
	ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
    return sd->labelNumericPrecision();
	}

//for a bad call we return the default values
return 4;
}
/*!
  \brief Disable autoscaling and specify a fixed scale for a selected axis.
  \param axisId axis index
  \param scaleDiv Scale division
  \sa QwtPlot::setAxisScale(), QwtPlot::setAxisAutoScale()
*/
void QwtPlot::setAxisScaleDiv(int axisId, const QwtScaleDiv &scaleDiv)
{
    if (axisValid(axisId))
    {
        AxisData &d = *d_axisData[axisId];

        d.doAutoScale = false;
        d.scaleDiv = scaleDiv;

        autoRefresh();
    }
}
void QwtPlot::setAxisScaleEngine(int axisId, QwtScaleEngine *scaleEngine)
{
    if (axisValid(axisId) && scaleEngine != NULL )
    {
        AxisData &d = *d_axisData[axisId];

        delete d.scaleEngine;
        d.scaleEngine = scaleEngine;

        d.scaleDiv.invalidate();

        autoRefresh();
    }
}
Beispiel #14
0
/*!
  Set the maximum number of major scale intervals for a specified axis

  \param axisId axis index
  \param maxMajor maximum number of major steps
  \sa axisMaxMajor()
*/
void QwtPlot::setAxisMaxMajor( int axisId, int maxMajor )
{
    if ( axisValid( axisId ) )
    {
        maxMajor = qBound( 1, maxMajor, 10000 );

        AxisData &d = *d_axisData[axisId];
        if ( maxMajor != d.maxMajor )
        {
            d.maxMajor = maxMajor;
            d.isValid = false;
            autoRefresh();
        }
    }
}
/*!
  \brief Disable autoscaling and specify a fixed scale for a selected axis.
  \param axisId axis index
  \param min
  \param max minimum and maximum of the scale
  \param stepSize Major step size. If <code>step == 0</code>, the step size is
            calculated automatically using the maxMajor setting.
  \sa QwtPlot::setAxisMaxMajor(), QwtPlot::setAxisAutoScale()
*/
void QwtPlot::setAxisScale(int axisId, double min, double max, double stepSize)
{
    if (axisValid(axisId))
    {
        AxisData &d = *d_axisData[axisId];

        d.doAutoScale = false;
        d.scaleDiv.invalidate();

        d.minValue = min;
        d.maxValue = max;
        d.stepSize = stepSize;
            
        autoRefresh();
    }
}
Beispiel #16
0
/*!
   Change the scale engine for an axis

  \param axisId axis index
  \param scaleEngine Scale engine

  \sa axisScaleEngine()
*/
void QwtPlot::setAxisScaleEngine( int axisId, QwtScaleEngine *scaleEngine )
{
    if ( axisValid( axisId ) && scaleEngine != NULL )
    {
        AxisData &d = *d_axisData[axisId];

        delete d.scaleEngine;
        d.scaleEngine = scaleEngine;

        d_axisData[axisId]->scaleWidget->setTransformation( 
            scaleEngine->transformation() );

        d.isValid = false;

        autoRefresh();
    }
}
/*!
  \brief Set the maximum number of major scale intervals for a specified axis
  \param axisId axis index
  \param maxMajor maximum number of major steps
  \sa QwtAutoScale::setMaxMajor
*/
void QwtPlot::setAxisMaxMajor(int axisId, int maxMajor)
{
    if (axisValid(axisId))
    {
        if ( maxMajor < 1 )
            maxMajor = 1;
        if ( maxMajor > 1000 )
            maxMajor = 10000;
            
        AxisData &d = *d_axisData[axisId];
        if ( maxMajor != d.maxMinor )
        {
            d.maxMajor = maxMajor;
            d.scaleDiv.invalidate();
            autoRefresh();
        }
    }
}
Beispiel #18
0
int Plot::axisLabelFormat(int axis)
{
if (axisValid(axis))
	{
	int prec;
	char format;

	ScaleDraw *sd = (ScaleDraw *)axisScaleDraw (axis);
    sd->labelFormat(format, prec);

	if (format == 'g')
		return Automatic;
	else if (format == 'e')
		return Scientific;
	else if (format == 'f')
		return Decimal;
	else
		return Superscripts;
	}

return 0; 
}
Beispiel #19
0
/**
 * \brief Callback for joystick messages
 *
 * @param joy
 */
void TeleopNaoJoy::joyCallback(const Joy::ConstPtr& joy) {
    initializePreviousJoystick(joy);

    // Buttons:
    // TODO: make buttons generally configurable by mapping btn_id => pose_string

    if (m_enabled && buttonTriggered(m_crouchBtn, joy) && m_bodyPoseClient.isServerConnected()) {
        if (callBodyPoseClient("crouch")) {
            std_srvs::Empty e;
            m_stiffnessDisableClient.call(e);
        }
    }

    if (m_enabled && buttonTriggered(m_initPoseBtn, joy) && m_bodyPoseClient.isServerConnected()) {
        callBodyPoseClient("init");
        ROS_INFO("going to init pose");
    }

    /*if(m_enabled && buttonTriggered(m_stopWalkBtn, joy)){
      // not yet inhibited: publish zero walk command before inhibiting joystick
      m_motion.linear.x = 0.0;
      m_motion.linear.y = 0.0;
      m_motion.linear.z = 0.0;
      m_motion.angular.x = 0.0;
      m_motion.angular.y = 0.0;
      m_motion.angular.z = 0.0;
      naoqi_bridge_msgs::CmdVelService service_call;
      service_call.request.twist = m_motion;
      m_cmdVelClient.call(service_call);
      ROS_INFO("-- stop walk asked");
    }*/

    if (buttonTriggered(m_enableBtn, joy)) {
        std_msgs::String string;
        if (m_enabled) {
            m_enabled = false;
            string.data = "Gamepad control disabled";

        } else {
            m_enabled = true;
            string.data = "Gamepad control enabled";
            std_srvs::Empty e;
            m_stiffnessEnableClient.call(e);
        }
        m_speechPub.publish(string);
        ROS_INFO("%s", (string.data).c_str());

    }

    // directional commands
    // walking velocities and head movements
    if (!axisValid(m_xAxis, joy) ||  !axisValid(m_yAxis, joy) || !axisValid(m_turnAxis, joy)) {
        m_motion.linear.x = m_motion.linear.y = m_motion.angular.z = 0.0f;
        m_headAngles.joint_angles[0] = m_headAngles.joint_angles[1] = 0.0f;
        ROS_WARN("Joystick message too short for Move or Turn axis!\n");
    } else {
        if (buttonPressed(m_modifyHeadBtn, joy)) {
            ROS_INFO_STREAM("moving the head");
            // move head
            m_headAngles.header.stamp = ros::Time::now();
            m_headAngles.relative = 1;
            m_headAngles.joint_angles[0] = joy->axes[m_turnAxis];
            m_headAngles.joint_angles[1] = joy->axes[m_xAxis];

        } else {
            // stop head:
            //m_headAngles.joint_angles[0] = m_headAngles.joint_angles[1] = 0.0f;
            // move base:
            m_motion.linear.x = m_maxVx * std::max(std::min(joy->axes[m_xAxis], 1.0f), -1.0f);
            m_motion.linear.y = m_maxVy * std::max(std::min(joy->axes[m_yAxis], 1.0f), -1.0f);
            m_motion.angular.z = m_maxVw * std::max(std::min(joy->axes[m_turnAxis], 1.0f), -1.0f);

        }
    }

    /*
        // Head pos:
        if (!axisValid(m_headPitchAxis, joy) || !axisValid(m_headYawAxis, joy)){
        m_headAngles.absolute = 0;
        m_headAngles.yaw = 0.0;
        m_headAngles.pitch = 0.0;
        } else {
        m_headAngles.absolute = 0;
        m_headAngles.yaw = joy->axes[m_headYawAxis];
        m_headAngles.pitch = joy->axes[m_headPitchAxis];
        }
     */

    setPreviousJoystick(joy);

}
/*!
  \brief Change the title of a specified axis
  \param axisId axis index
  \param title axis title
*/
void QwtPlot::setAxisTitle(int axisId, const QwtText &title)
{
    if (axisValid(axisId))
        axisWidget(axisId)->setTitle(title);
}
/*!
  Rotate all tick labels
  \param axisId axis index
  \param rotation Angle in degrees. When changing the label rotation,
                  the label alignment might be adjusted too.
  \sa QwtScaleDraw::setLabelRotation(), QwtPlot::setAxisLabelAlignment
*/
void QwtPlot::setAxisLabelRotation(int axisId, double rotation)
{
    if (axisValid(axisId))
        axisWidget(axisId)->setLabelRotation(rotation);
}
void QwtPlot::setAxisLabelAlignment(int axisId, Qt::Alignment alignment)
#endif
{
    if (axisValid(axisId))
        axisWidget(axisId)->setLabelAlignment(alignment);
}
/*!
  \brief Change the font of an axis
  \param axisId axis index
  \param f font
  \warning This function changes the font of the tick labels,
           not of the axis title.
*/
void QwtPlot::setAxisFont(int axisId, const QFont &f)
{
    if (axisValid(axisId))
        axisWidget(axisId)->setFont(f);
}