Quantcast
Channel: MicroStation Programming - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 1677

Re: MDL Locate Filter not always being called for mdlState_startModifyCommand()

$
0
0

I have added the mdlLocate_noElemAllowLocked() and  mdlLocate_setElemSearchMask()
to my command and also removed the restart of the locate in the accept and I
make a call to mdlState_restartCurrentCommand() instead.

What happens now is the element search mask only allows lines which is fine.
My filter is only called when I move over a line element which is ok.
When I accept the element it calls the accept function then the reset.


vHybd_testAccept() IN
hitpath is 6E600E8 ulFilePos=4000038
Element is a line
vHybd_testReset IN
vHybd_testReset OUT
vHybd_testAccept() OUT
iHybd_testFilter() IN
iHybd_testFilter() OUT

Then clicking on the same element straight after I get this. I seem to be unable to
get the accept to trigger again:

vHybd_testReset IN
vHybd_testReset OUT
vHybd_testReset IN
vHybd_testReset OUT
iHybd_testFilter() IN
iHybd_testFilter() OUT
vHybd_testReset IN
vHybd_testReset OUT
iHybd_testFilter() IN


The help says that the mdlState_restartCurrentCommand() restarts the current primative command.
Since I'm using a mdlState_startModifyCommand() I doubt it will be restarting it so I put the
mdlLocate_restart(TRUE) back in the accept.

This lets me select consecutive elements but eventually fails as before;

iHybd_testFilter() OUT
vHybd_testAccept() IN
hitpath is 6E5F178 ulFilePos=4000038
Element is a line
vHybd_testAccept() OUT
iHybd_testFilter() IN
iHybd_testFilter() OUT
vHybd_testAccept() IN
hitpath is 6E5F178 ulFilePos=4000038
Element is a line
vHybd_testReset IN
vHybd_testReset OUT
vHybd_testAccept() OUT
vHybd_testAccept() IN
hitpath is NULL
vHybd_testAccept() IN
hitpath is NULL
vHybd_testAccept() IN
hitpath is NULL
iHybd_testFilter() IN



/*
-vHybd_testCmdI()
*/
Public void vHybd_testCmdI
(
   char *pcUnparsed                    //  =>
)
cmdNumber CMD_BUILD_TEST
{
   static int  searchType[] = {LINE_ELM};

   printf ("vHybd_testCmdI IN\n");


   mdlState_startModifyCommand
   (
      vHybd_testReset,
      vHybd_testAccept,
      NULL,
      NULL,
      NULL,
      ID_MESSAGE_COMMAND_BUILD_HYBRID,
      ID_MESSAGE_PROMPT_SELECT_COMPONENT,
      FALSE,
      0
   );

   mdlState_setFunction (STATE_COMMAND_CLEANUP, vHybd_testCleanup); // Ignore return. */

   mdlLocate_init();
   mdlLocate_noElemAllowLocked ();
   mdlLocate_setElemSearchMask (sizeof(searchType)/sizeof(int), searchType);
   mdlLocate_setFunction (LOCATE_POSTLOCATE  , iHybd_testFilter);
   mdlAutoLocate_enable  (TRUE, TRUE, FALSE);

   mdlOutput_prompt ("Select component"); // Returns void.

   printf ("vHybd_testCmdI OUT\n");

   return;
}

/*
-vHybd_testReset()
*/
Private void vHybd_testReset
(
   void
)
{
   static char sFunc[] = "vHybd_testReset";

   printf ("vHybd_testReset IN\n");
   printf ("vHybd_testReset OUT\n");

   return;
}


/*
-vHybd_testCleanup()
*/
Private void vHybd_testCleanup
(
   void
)
{
   static char sFunc[] = "vHybd_testCleanup";

   printf ("vHybd_testCleanup IN\n");
   printf ("vHybd_testCleanup OUT\n");
   return;
}

/*
-vHybd_testAccept()
*/
Public void vHybd_testAccept
(
   Dpoint3d *pD3d,
   int       iView
)
{
   DgnModelRefP      dmrModelRef      = NULL;
   ULong             ulFilePos        = 0L;
   MSElementDescr   *pMsed            = NULL;
   DisplayPathP      hp               = NULL;

   printf ("vHybd_testAccept() IN\n");

//   ulFilePos = mdlLocate_getCurrHeaderFilePos  ();
//   if (ulFilePos == 0xffffffff)
//      {printf ("mdlElement_getFilePos() failed\n"); return;}

   hp = mdlLocate_getCurrPath ();
   if (NULL == hp)
      {printf ("hitpath is NULL\n"); return;}

   ulFilePos = mdlDisplayPath_getCursorFilePos (hp);
   printf ("hitpath is %p ulFilePos=%ld\n", hp, ulFilePos);

//   ulFilePos = mdlElement_getFilePos (FILEPOS_CURRENT, &dmrModelRef);
//   if (ulFilePos == 0xffffffff)
//      {printf ("mdlElement_getFilePos() failed\n"); return;}

   if (0L == mdlElmdscr_read (&pMsed, ulFilePos, dmrModelRef, FALSE, NULL))
      {printf ("mdlElmdscr_read() failed ulFilePos=%ld\n", ulFilePos); return;}

   if (LINE_ELM == mdlElement_getType (&pMsed->el))
   {
      printf ("Element is a line\n");
   }
   else
   {
      exit (printf ("Why? ulFilePos=%d type=%d\n", ulFilePos, mdlElement_getType (&pMsed->el)));
   }

   mdlElmdscr_freeAll(&pMsed);
   pMsed = NULL;

   // Restart the locate.

//   mdlLocate_clear();
//   mdlLocate_init();
//   mdlLocate_allowLocked();
//   mdlLocate_setFunction (LOCATE_POSTLOCATE, iHybd_testFilter);
//   mdlAutoLocate_enable  (TRUE, TRUE, FALSE);

   mdlLocate_restart (TRUE);

//   mdlState_restartCurrentCommand();

   printf ("vHybd_testAccept() OUT\n");

   return;
}


/*
-iHybd_testFilter()
*/
Public int iHybd_testFilter
(
   int               locAction   ,
   MSElement        *pMseu,
   DgnModelRefP      dmrModelRef ,
   ULong             ulFilePos,
   Point3d          *pP3,
   int               iViewNumber ,
   HitPathP          hpHitPath   ,
   char             *pcRejectReason
)
{
   static char sFunc[] = "iHybd_testFilter";

   int               iReturn      = 0;
   MSElementDescr   *pMsed        = NULL;


   printf ("iHybd_testFilter() IN\n");


   iReturn = LOCATE_FILTER_STATUS_Reject;
   if (NULL != pcRejectReason)
      strcpy (pcRejectReason, "Not a valid component");


   if (TRUE == mdlModelRef_isActiveModel (dmrModelRef))
   {
      if (0L == mdlElmdscr_read (&pMsed, ulFilePos, dmrModelRef, FALSE, NULL))
         {printf ("mdlElmdscr_read() failed ulFilePos=%ld\n", ulFilePos); return (LOCATE_FILTER_STATUS_Reject);}

      if (LINE_ELM == mdlElement_getType (&pMsed->el))
         iReturn = LOCATE_FILTER_STATUS_Accept;

      mdlElmdscr_freeAll (&pMsed);
      pMsed = NULL;
   }
   else
   {
      if (NULL != pcRejectReason)
         strcpy (pcRejectReason, "You can only select elements in the active DGN.");
      iReturn = LOCATE_FILTER_STATUS_Reject;
   }

   printf ("iHybd_testFilter() OUT\n");

   return (iReturn);
}



Viewing all articles
Browse latest Browse all 1677

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>