Beispiel #1
0
vec3 mat3::transformVector(const vec3 &v) const {
	vec3 temp;
	
	temp.x = v.dot(getAxisX());
	temp.y = v.dot(getAxisY());
	temp.z = v.dot(getAxisZ());
	
	return temp;
}
Transform OrientedBox::getTransform_l2p ( void ) const
{
	Transform temp;

	temp.setLocalFrameIJK_p( getAxisX(), getAxisY(), getAxisZ() );
	temp.move_p( m_center );

	return temp;
}
Vector OrientedBox::rotateToWorld ( Vector const & V ) const
{
    Vector temp = Vector::zero;

	temp += getAxisX() * V.x;
	temp += getAxisY() * V.y;
	temp += getAxisZ() * V.z;

	return temp;
}
Vector OrientedBox::rotateToLocal ( Vector const & V ) const
{
	Vector temp;

	temp.x = V.dot(getAxisX());
	temp.y = V.dot(getAxisY());
	temp.z = V.dot(getAxisZ());

	return temp;
}
void Matr4::translateLocal(AxisType dir, Real trans, bool preTransform)
{
   Vect4 axis;
   switch (dir) {
      case Axis_X:
         axis = getAxisX();
   	   break;
      case Axis_Y:
         axis = getAxisY();
         break;
      case Axis_Z:
         axis = getAxisZ();
         break;
   }
   axis.scale(trans);
   translate(axis, preTransform);

   return;
}
Beispiel #6
0
bool PSV_ChartItem::addCurveItem(PSV_CurveInfo &curveInfo)
{
    if(curveInfo.m_isHidden)
    {
        return true;
    }
    setCurrentAxisType(curveInfo.m_axisType);
    PSV::CURVETYPE curveType = curveInfo.m_curveType;
    QMap<double, double> curve_data = curveInfo.m_curveDataMap;
    QPen pen(curveInfo.m_lineColor);
    pen.setWidth(curveInfo.m_lineWidth);
    QMapIterator<double, double> iter(curve_data);
    QLineF lineF;
    QLineF lineF_V;
    QLineF lineF_H;
    bool is_first = true;
    QMap<double, QGraphicsLineItem *> line_item_map;
    QMap<double, QGraphicsLineItem *> line_V_item_map;
    QMap<double, QGraphicsLineItem *> line_H_item_map;

    while(iter.hasNext())
    {
        iter.next();
        double x = getAxisX(iter.key());//不调整
        double y = getAxisY(iter.value());//不调整
        QPointF point(x,y);
        if(is_first)
        {
            is_first = false;
            if(curveType == PSV::E_CURVE_PARELLEL)
            {
                lineF_H.setP1(point);
            }
            else
            {
                lineF.setP1(point);
            }
        }
        else
        {
            if(curveType == PSV::E_CURVE_PARELLEL)
            {
                QGraphicsLineItem *line_item_H = new QGraphicsLineItem(this);
                line_item_H->setZValue(m_curveZValue);
                lineF_H.setP2(QPointF(x,lineF_H.p1().y()));
                line_item_H->setLine(lineF_H);
                line_item_H->setPen(pen);
                line_H_item_map.insert(iter.key(),line_item_H);
                lineF_V.setP1(QPointF(x,lineF_H.p1().y()));
                lineF_V.setP2(point);
                QGraphicsLineItem *line_item_V = new QGraphicsLineItem(this);
                line_item_V->setZValue(m_curveZValue);
                line_item_V->setLine(lineF_V);
                line_item_V->setPen(pen);
                line_V_item_map.insert(iter.key(),line_item_V);
                lineF_H.setP1(point);
            }
            else
            {
                QGraphicsLineItem *line_item;
                line_item = new QGraphicsLineItem(this);
                line_item->setZValue(m_curveZValue);
                lineF.setP2(point);
                line_item->setLine(lineF);
                line_item->setPen(pen);
                line_item_map.insert(iter.key(),line_item);
                lineF.setP1(lineF.p2());
            }
        }
    }
    m_curveZValue++;
    return true;
}
Beispiel #7
0
bool PSV_ChartItem::addEllipseItem(PSV_CurveInfo &curveInfo)
{
    if(curveInfo.m_isHidden)
    {
        return true;
    }
    setCurrentAxisType(curveInfo.m_axisType);
    QMap<double, double> curveData = curveInfo.m_curveDataMap;
    QMapIterator<double, double> iter(curveData);
    QPolygonF polygon;
    int m_radius = curveInfo.m_pointSize;
    double pointY0 = getAxisY(*m_min_y_curP,m_radius);;
    QPointF fisrtPoint(0,pointY0);
    QString curveName = curveInfo.m_curveName;
    QPen pen(curveInfo.m_pointColor);
    QBrush brush(curveInfo.m_pointColor);
    int count =1;
    double previous_time = 1.0 * qrand();
    QGraphicsEllipseItem* preItem = NULL;
    int index = 1;
    while(iter.hasNext())
    {
        iter.next();
        double x = getAxisX(iter.key(),m_radius);
        double y = getAxisY(iter.value(),m_radius);
        QPointF point(x, y);
        if(index == 1)
        {
            fisrtPoint = QPointF(x + m_radius,pointY0 + m_radius);
            polygon.append(fisrtPoint);
        }
        polygon.append(QPointF(x+m_radius,y+m_radius));
        if(index == curveData.count())
        {
            polygon.append(QPointF(x + m_radius,pointY0 + m_radius));
            polygon.append(fisrtPoint);
        }
        index++;
        QGraphicsEllipseItem *ellipse_item = new QGraphicsEllipseItem(this);
        ellipse_item->setZValue(m_curveZValue);
        ellipse_item->setRect(0,0,2*m_radius,2*m_radius);
        ellipse_item->setPos(point);
        ellipse_item->setFlag(QGraphicsItem::ItemIsSelectable);
        ellipse_item->setPen(pen);
        ellipse_item->setBrush(brush);
        ellipse_item->setData(E_CURVE_NAME,curveName);  //设置属于哪条曲线
        ellipse_item->setData(E_AXIS_X,iter.key());  //设置对应的X坐标轴值
        ellipse_item->setData(E_PREVIOUS_TIME,previous_time);
        ellipse_item->setData(E_NEXT_TIME,previous_time);
        ellipse_item->setData(E_POINT_TYPE,EV_FIRST);
        ellipse_item->setData(E_ITEM_TYPE,PSV::ellipseItem);
        ellipse_item->setToolTip(getToolTipText(iter.key(),iter.value()));
        ellipse_item->installSceneEventFilter(this);
        if(ellipse_item != NULL)
        {
            preItem->setData(E_NEXT_TIME,iter.key());
            if(count == curveData.count() - 1)
            {
                ellipse_item->setData(E_POINT_TYPE,EV_LAST);
            }
            else if(count != 1)
            {
                ellipse_item->setData(E_POINT_TYPE,EV_MID);
            }
        }
        preItem = ellipse_item;
        previous_time = iter.key();
    }
    curveInfo.m_polygon = polygon;
    m_curveZValue++;
    return true;
}