//-----------------------------------------------------------------------------
//- AttMove.cpp
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "utils.h"
#include "AttMove.h"
//-----------------------------------------------------------------------------
AttMove::AttMove () : AcEdJig (), mCurrentInputLevel(0), mpEntity(NULL)
{
}
AttMove::~AttMove () {
}
//-----------------------------------------------------------------------------
AcEdJig::DragStatus AttMove::startJig (AcDbAttribute *pEntity) {
//- Store the new entity pointer
mpEntity = AcDbAttribute::cast(pEntity->clone());
//- Setup each input prompt
AcString inputPrompts = L"\nУкажите новое положение атрибута (ENTER - оставить на месте): ";
//- Setup kwords for each input
AcString kwords = L"";
bool appendOk = true ;
AcEdJig::DragStatus status = AcEdJig::kNull ;
//- Loop the number of inputs
//- Add a new input point to the list of input points
mpEntity->adjustAlignment(acdbCurDwg());
if (mpEntity->position() != mpEntity->alignmentPoint()) {
if (mpEntity->setAlignmentPoint(mpEntity->position()) == Acad::eOk) {
mInputPoints.append (mpEntity->alignmentPoint()) ;
mInputPoints.append (mpEntity->alignmentPoint()) ;
} else {
mInputPoints.append (mpEntity->position()) ;
mInputPoints.append (mpEntity->position()) ;
}
} else {
mInputPoints.append (mpEntity->alignmentPoint()) ;
mInputPoints.append (mpEntity->alignmentPoint()) ;
}
//- Set the input prompt
setDispPrompt (inputPrompts) ;
//- Setup the keywords required
setKeywordList (kwords) ;
bool quit =false ;
//- Lets now do the input
status = drag () ;
if ( status != kNormal ) {
//- If it's a keyword
switch ( status ) {
case kCancel:
case kNull:
quit =true ;
break ;
case kKW1:
case kKW2:
case kKW3:
case kKW4:
case kKW5:
case kKW6:
case kKW7:
case kKW8:
case kKW9:
//- Do something
break ;
}
} else {
appendOk =true ;
}
delete mpEntity;
return (status) ;
}
//-----------------------------------------------------------------------------
//- Input sampler
AcEdJig::DragStatus AttMove::sampler () {
//- Setup the user input controls for each input
AcEdJig::UserInputControls userInputControls = AcEdJig::UserInputControls(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted);
//- Setup the cursor type for each input
AcEdJig::CursorType cursorType = AcEdJig::kRubberBand;
//- Setup the user input controls for each sample
setUserInputControls (userInputControls) ;
setSpecialCursorType (cursorType) ;
AcEdJig::DragStatus status = GetNextPoint();
//- Check the current input number to see which input to do
return (status) ;
}
//-----------------------------------------------------------------------------
//- Jigged entity update
Adesk::Boolean AttMove::update () {
mpEntity->setPosition(mInputPoints[1]) ;
mpEntity->setAlignmentPoint(mInputPoints[1]) ;
mpEntity->adjustAlignment(acdbCurDwg());
return true;
}
//-----------------------------------------------------------------------------
//- Jigged entity pointer return
AcDbEntity *AttMove::entity () const {
return (mpEntity) ;
}
//-----------------------------------------------------------------------------
//- Std input to get a point with rubber band from point
AcEdJig::DragStatus AttMove::GetNextPoint () {
AcGePoint3d oldPnt = mInputPoints [0];
AcGePoint3d newPnt = mInputPoints [1];
//- Get the point
AcEdJig::DragStatus status = acquirePoint (newPnt, oldPnt) ;
//- If valid input
if ( status == AcEdJig::kNormal ) {
//- If there is no difference
if ( newPnt.distanceTo (mInputPoints [1]) < 1e-3)
return (AcEdJig::kNoChange) ;
//- Otherwise update the point
mInputPoints [1] = newPnt ;
}
return (status) ;
}