bool appendOk = true; AcEdJig::DragStatus status = AcEdJig::kNull; for (mCurrentInputLevel = 0; mCurrentInputLevel < 2; mCurrentInputLevel++) { //- Add a new input point to the list of input points mInputPoints.append(AcGePoint3d()); //- Set the input prompt setDispPrompt(inputPrompts[mCurrentInputLevel]); //- Setup the keywords required setKeywordList(kwords[mCurrentInputLevel]);
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; } //- If to finish if (quit) break; }
//- If the input went well if (appendOk) //- Append to the database append(); else //- Clean up delete mpEntity; return (status); }
#pragma region Jig需要实现的三个虚函数 AcEdJig::DragStatus CustomEntity1Jig::sampler(){ //- Setup the user input controls for each input AcEdJig::UserInputControls userInputControls[2] = { /*AcEdJig::UserInputControls::*/(AcEdJig::UserInputControls)0, /*AcEdJig::UserInputControls::*/(AcEdJig::UserInputControls)0 }; //- Setup the cursor type for each input AcEdJig::CursorType cursorType[2] = { /*AcEdJig::CursorType::*/(AcEdJig::CursorType)0, /*AcEdJig::CursorType::*/(AcEdJig::CursorType)0 }; //- Setup the user input controls for each sample setUserInputControls(userInputControls[mCurrentInputLevel]); setSpecialCursorType(cursorType[mCurrentInputLevel]);
AcEdJig::DragStatus status = AcEdJig::kCancel; //- Check the current input number to see which input to do switch (mCurrentInputLevel + 1) { case1: // TODO : get an input here status = GetStartPoint(); break; case2: // TODO : get an input here status = GetNextPoint(); break;
default: break; } return (status); }
Adesk::Boolean CustomEntity1Jig::update(){ //- Check the current input number to see which update to do AcGePoint3d p; switch (mCurrentInputLevel + 1) { double deltaX, deltaY, r1; case1: // TODO : update your entity for this input mpEntity->setCenter(mInputPoints[mCurrentInputLevel]); break; case2: // TODO : update your entity for this input deltaX = mInputPoints[mCurrentInputLevel].x - mInputPoints[mCurrentInputLevel - 1].x; deltaY = mInputPoints[mCurrentInputLevel].y - mInputPoints[mCurrentInputLevel - 1].y; r1 = sqrt(deltaX * deltaX + deltaY * deltaY); mpEntity->setR1(r1); mpEntity->setR2(0.15 * r1); break;
AcEdJig::DragStatus CustomEntity1Jig::GetStartPoint(){ AcGePoint3d newPnt; //- Get the point AcEdJig::DragStatus status = acquirePoint(newPnt); //- If valid input if (status == AcEdJig::kNormal) { //- If there is no difference if (newPnt.isEqualTo(mInputPoints[mCurrentInputLevel])) return (AcEdJig::kNoChange); //- Otherwise update the point mInputPoints[mCurrentInputLevel] = newPnt; } return (status); }
AcEdJig::DragStatus CustomEntity1Jig::GetNextPoint(){ AcGePoint3d oldPnt = mInputPoints[mCurrentInputLevel - 1]; AcGePoint3d newPnt; //- Get the point AcEdJig::DragStatus status = acquirePoint(newPnt, oldPnt); //- If valid input if (status == AcEdJig::kNormal) { //- If there is no difference if (newPnt.isEqualTo(mInputPoints[mCurrentInputLevel])) return (AcEdJig::kNoChange); //- Otherwise update the point mInputPoints[mCurrentInputLevel] = newPnt; } return (status); }