Esempio n. 1
0
Adesk::Boolean TunnelDragJig::update()
{
    AcGePlane plane;
    AcGeVector3d v = ept - spt;
    v.normalize();

    v.rotateBy( 0.5 * PI, AcGeVector3d::kZAxis );

    AcGeVector3d offset = curPt - basePt;
    double L = offset.dotProduct( v );
    if( L == 0 ) return false;

    if( L < 0 )
    {
        v.negate();
        L = -1 * L;
    }

    AcGePoint3d newSpt = spt + v * L, newEpt = ept + v * L;

    // 更新工作面坐标
    m_pWS->setSEPoint( newSpt, newEpt );
    m_pWS->updateDraw();

    return Adesk::kTrue;
}
Esempio n. 2
0
// This function is called to update the entity based on the
// input values
//
Adesk::Boolean AcRectJig::update()
{
    AcGeVector3d diaVec = mWcsPt2 - mWcsPt1;
    AcGePoint3d cenPt = mWcsPt1 + 0.5 * diaVec;
    double width = fabs(diaVec.dotProduct(mHorizDir));
    double height = fabs(diaVec.dotProduct(mVertDir));

    if (!(mLockWidth || mLockHeight))
        mpRect->setCenter(cenPt);

    if (!mLockWidth)
        mpRect->setWidth(width);

    if (!mLockHeight)
        mpRect->setHeight(height);

    updateDimData();

    return Adesk::kTrue;
}
Esempio n. 3
0
AcGeVector3d  
AcRectangle::setDimValueCbackFunc(AcDbDimData* pThis, 
                                  AcDbEntity* pEnt, 
                                  double value,
								  const AcGeVector3d& offset)
{
    if ((pThis == NULL) || (pEnt == NULL))
        return offset;
	
    pEnt->assertWriteEnabled();

    AppData *pDimAppData = (AppData*)pThis->appData();
    if (pDimAppData == NULL)
        return offset;

    int dimId = pDimAppData->index();
    if ((dimId < 1) || (dimId > 10))
        return offset;

    AcRectangle *pRect = AcRectangle::cast(pEnt);
    if (pRect == NULL)
        return offset;

    AcGePoint3d pt1, pt2, pt3, pt4, dimPt;
    AcGeVector3d diaVec;
    AcGeVector3d mHorizDir = pRect->horizDir();
    AcGeVector3d mNormal = pRect->normal();
    AcGeVector3d vertDir = mNormal.crossProduct(mHorizDir);
    AcGePoint3d mCenter = pRect->center();
    double mWidth = pRect->width();
    double mHeight = pRect->height();
    pt1 = mCenter + 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt2 = mCenter - 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
    pt3 = mCenter - 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
    pt4 = mCenter + 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;

    switch (dimId) {
    case 1:
        mCenter = mCenter + value * mHorizDir;
        pRect->setCenter(mCenter);
        break;

    case 2:
        mCenter = mCenter + value * vertDir;
        pRect->setCenter(mCenter);
        break;
        
    case 3:
        pt1 = pt2 + value * mHorizDir;
        diaVec = pt1 - pt3;
        mCenter = pt3 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 4:
        pt1 = pt4 + value * vertDir;
        diaVec = pt1 - pt3;
        mCenter = pt3 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 5:
        pt2 = pt1 - value * mHorizDir;
        diaVec = pt2 - pt4;
        mCenter = pt4 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 6:
        pt2 = pt3 + value * vertDir;
        diaVec = pt2 - pt4;
        mCenter = pt4 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 7:
        pt3 = pt2 - value * vertDir;
        diaVec = pt3 - pt1;
        mCenter = pt1 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 8:
        pt3 = pt4 - value * mHorizDir;
        diaVec = pt3 - pt1;
        mCenter = pt1 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 9:
        pt4 = pt3 + value * mHorizDir;
        diaVec = pt4 - pt2;
        mCenter = pt2 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;

    case 10:
        pt4 = pt1 - value * vertDir;
        diaVec = pt4 - pt2;
        mCenter = pt2 + 0.5 * diaVec;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        pRect->setCenter(mCenter);
        pRect->setWidth(mWidth);
        pRect->setHeight(mHeight);
        break;
	}

    return offset;
}
Esempio n. 4
0
Acad::ErrorStatus
AcRectangle::moveGripPointsAt(const AcDbVoidPtrArray& appData,
                              const AcGeVector3d& offset,
                              const int bitflags)
{
    assertWriteEnabled();
	if (!appData.length())
		return Acad::eInvalidInput;

    AcGePoint3d pt1, pt2;
    AcGeVector3d diaVec;

    AppData *pAppData = (AppData*)appData[0];
    int gripID = pAppData->index();
    AcGeVector3d vertDir = mNormal.crossProduct(mHorizDir);
	
    switch(gripID) {
    case 0:
        mCenter += offset;
        break;

    case 1:
        pt1 = mCenter + 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
        pt2 = mCenter - 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
        pt1 += offset;
        diaVec = pt1 - pt2;
        mCenter += 0.5 * offset;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        break;

    case 2:
        pt1 = mCenter - 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
        pt2 = mCenter + 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
        pt1 += offset;
        diaVec = pt1 - pt2;
        mCenter += 0.5 * offset;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        break;

    case 3:
        pt1 = mCenter - 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
        pt2 = mCenter + 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
        pt1 += offset;
        diaVec = pt1 - pt2;
        mCenter += 0.5 * offset;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        break;
	
    case 4:
        pt1 = mCenter + 0.5 * mWidth * mHorizDir - 0.5 * mHeight * vertDir;
        pt2 = mCenter - 0.5 * mWidth * mHorizDir + 0.5 * mHeight * vertDir;
        pt1 += offset;
        diaVec = pt1 - pt2;
        mCenter += 0.5 * offset;
        mWidth = fabs(diaVec.dotProduct(mHorizDir));
        mHeight = fabs(diaVec.dotProduct(vertDir));
        break;
	}

    // Update dynamic dimensions
    //
    AcDbDimDataPtrArray *pDimDataArr = NULL;
    if (pAppData)
        pDimDataArr = pAppData->dimData();

    updateDimensions(pDimDataArr);

    return Acad::eOk;

}
Esempio n. 5
0
//-----------------------------------------------------------------------------
// This function is called to update the entity based on the
// input values
//
Adesk::Boolean AsdkRectangleJig::update()
{
    AcGePoint2d adjustedPoint;
    AcGePoint3d tmpPoint;       // Used by MAKEUCSCOORD macro.

    // We'll use the AcGeLine::intersectWith() function to infer the
    // remaining points.
    //
    AcGeLine3d lineX, lineY;
    lineX.set(m_TopLeftCorner, m_vecUnitX);
    lineY.set(m_BottomRightCorner, m_vecUnitY);
    // Top right corner is intersection of lineX and lineY.
    //
    lineX.intersectWith(lineY, m_TopRightCorner);

    lineX.set(m_BottomRightCorner, m_vecUnitX);
    lineY.set(m_TopLeftCorner, m_vecUnitY);
    // Bottom left corner is intersection of lineX and lineY.
    //
    lineX.intersectWith(lineY, m_BottomLeftCorner);

    AcGeVector3d tmpXVec, tmpYVec;
    // Check to see if we have flipped around the X or Y axis.
    //
    bool bXFlip = m_vecUnitX.dotProduct(m_TopLeftCorner - m_TopRightCorner)  >0;
    bool bYFlip = m_vecUnitY.dotProduct(m_TopLeftCorner - m_BottomLeftCorner)<0; 

    // If the rectangle is dragged into the first or third quadrant,
    // we need to reverse the sign of the bulge as well as reverse
    // the x and y direction vectors.
    //
    tmpXVec = bXFlip ? -1 * m_vecUnitX : m_vecUnitX;
    tmpYVec = bYFlip ? -1 * m_vecUnitY : m_vecUnitY;
   
    // Now update the polyline with the latest setting
    //
    if (plineInfo.m_cornerTreatment) {
        // We are going to fillet of chamfer this polyline rectangle. As such,
        // the constructor has added the extra points at the corners to allow
        // for there placement and bulge values to be updated on the fly.
        // If, during the dragging, the rectangle is still too small to show the
        // given radius or chamfer edges, the we will put the extra points in the 
        // corners and set the bulges to 0.0, so the rectangle retains its 
        // square corners until the user stretches the rectangle to a size large
        // enough to have the corner treatment displayed.
        //

        // Use temporaries to see if we're too small to show fillet/chamfer, so
        // we don't need to convert back to world.
        // 
        AcGePoint2d point_TL, point_TR, point_BL;
        MAKEUCSCOORD(point_TL, m_TopLeftCorner);
        MAKEUCSCOORD(point_TR, m_TopRightCorner);
        MAKEUCSCOORD(point_BL, m_BottomLeftCorner);

        bool tooSmall = (point_TL.distanceTo(point_TR)
            < plineInfo.m_first + plineInfo.m_second)
            || (point_TL.distanceTo(point_BL)
            < plineInfo.m_first + plineInfo.m_second);
        if (tooSmall) {
            // Still to small to show the corner treatment.
            //
            m_pLWPoly->setBulgeAt(0, 0.0);
            MAKEUCSCOORD(adjustedPoint, m_TopLeftCorner);
            m_pLWPoly->setPointAt(0, adjustedPoint);
            m_pLWPoly->setPointAt(1, adjustedPoint);

            m_pLWPoly->setBulgeAt(2, 0.0);  
            MAKEUCSCOORD(adjustedPoint, m_TopRightCorner);
            m_pLWPoly->setPointAt(2, adjustedPoint);
            m_pLWPoly->setPointAt(3, adjustedPoint);

            m_pLWPoly->setBulgeAt(4, 0.0);  
            MAKEUCSCOORD(adjustedPoint, m_BottomRightCorner);
            m_pLWPoly->setPointAt(4, adjustedPoint);
            m_pLWPoly->setPointAt(5, adjustedPoint);

            m_pLWPoly->setBulgeAt(6, 0.0);  
            MAKEUCSCOORD(adjustedPoint, m_BottomLeftCorner);
            m_pLWPoly->setPointAt(6, adjustedPoint);
            m_pLWPoly->setPointAt(7, adjustedPoint);
        } else {
            double tmpBulge;

            tmpBulge = ((!bXFlip && !bYFlip) || (bXFlip && bYFlip))
                ? plineInfo.m_bulge : -plineInfo.m_bulge;

            // Now we will set adjustedPoint to the intersection of the rectangle
            // sides with the place where the new end points will be.
            //
            m_pLWPoly->setBulgeAt(0, tmpBulge);
            MAKEUCSCOORD(adjustedPoint,
                m_TopLeftCorner + (-plineInfo.m_first * tmpYVec));
            m_pLWPoly->setPointAt(0, adjustedPoint);
                   
            MAKEUCSCOORD(adjustedPoint,
                m_TopLeftCorner + plineInfo.m_second * tmpXVec);
            m_pLWPoly->setPointAt(1, adjustedPoint);
    
            m_pLWPoly->setBulgeAt(2, tmpBulge); 
            MAKEUCSCOORD(adjustedPoint,
                m_TopRightCorner + (-plineInfo.m_first * tmpXVec));
            m_pLWPoly->setPointAt(2, adjustedPoint);

            MAKEUCSCOORD(adjustedPoint,
                m_TopRightCorner + (-plineInfo.m_second * tmpYVec));
            m_pLWPoly->setPointAt(3, adjustedPoint);
    
            m_pLWPoly->setBulgeAt(4, tmpBulge);
            MAKEUCSCOORD(adjustedPoint,
                m_BottomRightCorner + plineInfo.m_first * tmpYVec);
            m_pLWPoly->setPointAt(4, adjustedPoint);
            
            MAKEUCSCOORD(adjustedPoint,
                m_BottomRightCorner + (-plineInfo.m_second * tmpXVec));
            m_pLWPoly->setPointAt(5, adjustedPoint);

            m_pLWPoly->setBulgeAt(6, tmpBulge);
            MAKEUCSCOORD(adjustedPoint,
                m_BottomLeftCorner + plineInfo.m_first * tmpXVec);
            m_pLWPoly->setPointAt(6, adjustedPoint);
            
            MAKEUCSCOORD(adjustedPoint,
                m_BottomLeftCorner + plineInfo.m_second * tmpYVec);
            m_pLWPoly->setPointAt(7, AcGePoint2d(adjustedPoint[X],
                adjustedPoint[Y]));
        }
    } else {
        // If this polyline is not having its corners treated, ie chamfered, or 
        // filleted then simply update the corners. Since we knew this ahead of 
        // time, the constructor did not add any extra verticies at the corners.
        //
        MAKEUCSCOORD(adjustedPoint, m_TopLeftCorner);
        m_pLWPoly->setPointAt(0, adjustedPoint);

        MAKEUCSCOORD(adjustedPoint, m_TopRightCorner);
        m_pLWPoly->setPointAt(1, adjustedPoint);

        MAKEUCSCOORD(adjustedPoint, m_BottomRightCorner);
        m_pLWPoly->setPointAt(2, adjustedPoint);

        MAKEUCSCOORD(adjustedPoint, m_BottomLeftCorner);
        m_pLWPoly->setPointAt(3, adjustedPoint);
    } 
    return Adesk::kTrue;
}