ObjectARX学习笔记(二十三)---AcEdInputPointMonitor 反应器,用来重载CAD鼠标点处实体的提示信息

  1. <pre name= "code" class="cpp"><pre name="code" class="cpp">// Copyright (C) 1998-2007 by Autodesk, Inc.
  2.  
    //
  3.  
    // Permission to use, copy, modify, and distribute this software
  4.  
    // for any purpose is restricted by the VIP Subscription program
  5.  
    // license agreement. This application was developed exclusively
  6.  
    // for distribution by the VIP subscription program and may not
  7.  
    // be posted pubicly, modified, copied, or distributed by any other
  8.  
    // methods.
  9.  
    //
  10.  
    // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
  11.  
    // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
  12.  
    // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
  13.  
    // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
  14.  
    // UNINTERRUPTED OR ERROR FREE.
  15.  
    //
  16.  
    // Use, duplication, or disclosure by the U.S. Government is subject to
  17.  
    // restrictions set forth in FAR 52.227-19 (Commercial Computer
  18.  
    // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
  19.  
    // (Rights in Technical Data and Computer Software), as applicable.
  20.  
    //
  21.  
     
  22.  
    #include "acedinpt.h"
  23.  
     
  24.  
    class AsdkInputPointMonitor : public AcEdInputPointMonitor
  25.  
    {
  26.  
    public:
  27.  
    virtual Acad::ErrorStatus monitorInputPoint(const AcEdInputPoint& input, AcEdInputPointMonitorResult& output);
  28.  
    virtual bool excludeFromOsnapCalculation (const AcArray<AcDbObjectId>& nestedEntity, INT_PTR gsSelectionMark);
  29.  
    };
    1.  
      // Copyright (C) 1998-2007 by Autodesk, Inc.
    2.  
      //
    3.  
      // Permission to use, copy, modify, and distribute this software
    4.  
      // for any purpose is restricted by the VIP Subscription program
    5.  
      // license agreement. This application was developed exclusively
    6.  
      // for distribution by the VIP subscription program and may not
    7.  
      // be posted pubicly, modified, copied, or distributed by any other
    8.  
      // methods.
    9.  
      //
    10.  
      // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
    11.  
      // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
    12.  
      // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
    13.  
      // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
    14.  
      // UNINTERRUPTED OR ERROR FREE.
    15.  
      //
    16.  
      // Use, duplication, or disclosure by the U.S. Government is subject to
    17.  
      // restrictions set forth in FAR 52.227-19 (Commercial Computer
    18.  
      // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
    19.  
      // (Rights in Technical Data and Computer Software), as applicable.
    20.  
      //
    21.  
       
    22.  
      // AsdkInputPointMonitor methods
    23.  
      //
    24.  
       
    25.  
      #if defined(_DEBUG) && !defined(AC_FULL_DEBUG)
    26.  
      #error _DEBUG should not be defined except in internal Adesk debug builds
    27.  
      #endif
    28.  
       
    29.  
      #include "acdbabb.h"
    30.  
      #include "adeskabb.h"
    31.  
      #include "aced.h"
    32.  
      #include "dbents.h"
    33.  
      #include "dbosnap.h"
    34.  
      #include "tchar.h"
    35.  
       
    36.  
      #include "monitor.h"
    37.  
       
    38.  
       
    39.  
      Acad::ErrorStatus
    40.  
      AsdkInputPointMonitor::monitorInputPoint( const AcEdInputPoint& input, AcEdInputPointMonitorResult& output)
    41.  
      {
    42.  
      if ( !input.pointComputed() )
    43.  
      {
    44.  
      // Points cannot be computed in the Monitor
    45.  
      // Forced picking may be enabled
    46.  
       
    47.  
      if ( input.history() & Acad::eCyclingPt)
    48.  
      acutPrintf( _T( "\nNo point computed, but new cycling osnap: %.2f, %.2f, %.2f\n"),
    49.  
      input.osnappedPoint()[X], input.osnappedPoint()[Y], input.osnappedPoint()[Z] );
    50.  
       
    51.  
      return Acad::eOk;
    52.  
      }
    53.  
       
    54.  
      // Show historical point selection information
    55.  
      //
    56.  
      #define HISTORY_CHECK(x) if (input.history() & Acad:: ## x) acutPrintf(_T("%s "), _T(#x))
    57.  
       
    58.  
      acutPrintf( _T( "\nHistory: %d, "), input.history() );
    59.  
       
    60.  
      HISTORY_CHECK(eTablet);
    61.  
      HISTORY_CHECK(eNotDigitizer);
    62.  
      HISTORY_CHECK(eLastPt);
    63.  
      HISTORY_CHECK(eGripped);
    64.  
      HISTORY_CHECK(eCartSnapped);
    65.  
      HISTORY_CHECK(eOrtho);
    66.  
      HISTORY_CHECK(eCyclingPt);
    67.  
      HISTORY_CHECK(eOsnapped);
    68.  
      HISTORY_CHECK(ePolarAngle);
    69.  
      HISTORY_CHECK(eAligned);
    70.  
      HISTORY_CHECK(eAppFiltered);
    71.  
      HISTORY_CHECK(eForcedPick);
    72.  
      HISTORY_CHECK(ePickMask);
    73.  
      HISTORY_CHECK(eDidNotPick);
    74.  
      HISTORY_CHECK(eUsedPickBox);
    75.  
      HISTORY_CHECK(eUsedOsnapBox);
    76.  
      HISTORY_CHECK(ePickAborted);
    77.  
      HISTORY_CHECK(eXPending);
    78.  
      HISTORY_CHECK(eYPending);
    79.  
      HISTORY_CHECK(eZPending);
    80.  
      HISTORY_CHECK(eCoordPending);
    81.  
       
    82.  
      #undef HISTORY_CHECK
    83.  
       
    84.  
      acutPrintf( _T( "\n") );
    85.  
       
    86.  
      // Show more point input information
    87.  
      //
    88.  
      if ( input.history() & Acad::eLastPt )
    89.  
      acutPrintf( _T( "Last point: %.2f, %.2f, %.2f\n"), input.lastPoint()[X], input.lastPoint()[Y], input.lastPoint()[Z] );
    90.  
       
    91.  
      acutPrintf( _T( "Raw point: %.2f, %.2f, %.2f\n"), input.rawPoint()[X], input.rawPoint()[Y], input.rawPoint()[Z] );
    92.  
      acutPrintf( _T( "Computed point: %.2f, %.2f, %.2f\n"), input.computedPoint()[X], input.computedPoint()[Y], input.computedPoint()[Z] );
    93.  
       
    94.  
      if ( input.history() & Acad::eGripped )
    95.  
      acutPrintf( _T( "Gripped point: %.2f, %.2f, %.2f\n"), input.grippedPoint()[X], input.grippedPoint()[Y], input.grippedPoint()[Z] );
    96.  
       
    97.  
      if ( input.history() & Acad::eCartSnapped )
    98.  
      acutPrintf( _T( "Cartesian snapped point: %.2f, %.2f, %.2f\n"), input.cartesianSnappedPoint()[X], input.cartesianSnappedPoint()[Y], input.cartesianSnappedPoint()[Z] );
    99.  
       
    100.  
      if ( input.history() & Acad::eOsnapped )
    101.  
      {
    102.  
      acutPrintf( _T( "Osnapped point: %.2f, %.2f, %.2f\n"), input.osnappedPoint()[X], input.osnappedPoint()[Y], input.osnappedPoint()[Z] );
    103.  
       
    104.  
      acutPrintf( _T( "Object snap masks: ") );
    105.  
       
    106.  
      #define OSMASK_CHECK(x) if (input.osnapMask() & AcDb:: ## x) acutPrintf(_T("%s "), _T(#x))
    107.  
       
    108.  
      OSMASK_CHECK(kOsMaskEnd);
    109.  
      OSMASK_CHECK(kOsMaskMid);
    110.  
      OSMASK_CHECK(kOsMaskCen);
    111.  
      OSMASK_CHECK(kOsMaskNode);
    112.  
      OSMASK_CHECK(kOsMaskQuad);
    113.  
      OSMASK_CHECK(kOsMaskInt);
    114.  
      OSMASK_CHECK(kOsMaskIns);
    115.  
      OSMASK_CHECK(kOsMaskPerp);
    116.  
      OSMASK_CHECK(kOsMaskTan);
    117.  
      OSMASK_CHECK(kOsMaskNear);
    118.  
      OSMASK_CHECK(kOsMaskQuick);
    119.  
      OSMASK_CHECK(kOsMaskApint);
    120.  
      OSMASK_CHECK(kOsMaskImmediate);
    121.  
      OSMASK_CHECK(kOsMaskAllowTan);
    122.  
      OSMASK_CHECK(kOsMaskDisablePerp);
    123.  
      OSMASK_CHECK(kOsMaskRelCartesian);
    124.  
      OSMASK_CHECK(kOsMaskRelPolar);
    125.  
       
    126.  
      #undef OSMASK_CHECK
    127.  
       
    128.  
      if ( 0 == input.osnapMask() )
    129.  
      {
    130.  
      for ( int i = 0; i < input.customOsnapModes().length(); i++ )
    131.  
      acutPrintf( _T( "%s\n"), input.customOsnapModes()[i]->globalModeString() );
    132.  
      }
    133.  
      acutPrintf( _T( "\n") );
    134.  
      }
    135.  
       
    136.  
      // Show the object snap overrides
    137.  
      //
    138.  
      if ( 0 != input.osnapOverrides() )
    139.  
      {
    140.  
       
    141.  
      acutPrintf( _T( "Object snap overrides: ") );
    142.  
       
    143.  
      #define OSMASK_CHECK(x) if (input.osnapOverrides() & AcDb:: ## x) acutPrintf(_T("%s "), _T(#x))
    144.  
       
    145.  
      OSMASK_CHECK(kOsMaskEnd);
    146.  
      OSMASK_CHECK(kOsMaskMid);
    147.  
      OSMASK_CHECK(kOsMaskCen);
    148.  
      OSMASK_CHECK(kOsMaskNode);
    149.  
      OSMASK_CHECK(kOsMaskQuad);
    150.  
      OSMASK_CHECK(kOsMaskInt);
    151.  
      OSMASK_CHECK(kOsMaskIns);
    152.  
      OSMASK_CHECK(kOsMaskPerp);
    153.  
      OSMASK_CHECK(kOsMaskTan);
    154.  
      OSMASK_CHECK(kOsMaskNear);
    155.  
      OSMASK_CHECK(kOsMaskQuick);
    156.  
      OSMASK_CHECK(kOsMaskApint);
    157.  
      OSMASK_CHECK(kOsMaskImmediate);
    158.  
      OSMASK_CHECK(kOsMaskAllowTan);
    159.  
      OSMASK_CHECK(kOsMaskDisablePerp);
    160.  
      OSMASK_CHECK(kOsMaskRelCartesian);
    161.  
      OSMASK_CHECK(kOsMaskRelPolar);
    162.  
       
    163.  
      #undef OSMASK_CHECK
    164.  
       
    165.  
      acutPrintf(_T( "\n"));
    166.  
      }
    167.  
       
    168.  
      // Show custom object snap overrides
    169.  
      //
    170.  
      if ( 0 != input.customOsnapOverrides().length() )
    171.  
      {
    172.  
      acutPrintf( _T( "Custom object snap overrides: ") );
    173.  
      for ( int x = 0; x < input.customOsnapOverrides().length(); x++)
    174.  
      acutPrintf( _T( "%s "), input.customOsnapOverrides()[x]->globalModeString() );
    175.  
      acutPrintf( _T( "\n") );
    176.  
      }
    177.  
       
    178.  
      // Show object snap or forced pick information: the entities in the aperture
    179.  
      acutPrintf( _T( "%d apertured entities, "), input.pickedEntities().length() );
    180.  
      acutPrintf( _T( "%d nested apertured entities\n"), input.nestedPickedEntities().length() );
    181.  
       
    182.  
      // Show AutoSnap information
    183.  
      // Note: nestedKeyPointEntities.length() == keyPointGsSelectionMark.length()
    184.  
      //
    185.  
      acutPrintf( _T( "%d key point entities, "), input.keyPointEntities().length() );
    186.  
      acutPrintf( _T( "%d nested key point entities\n"), input.nestedKeyPointEntities().length() );
    187.  
      acutPrintf( _T( "%d alignment paths\n"), input.alignmentPaths().length() );
    188.  
       
    189.  
      // Add an additional comment to the tootip string
    190.  
      //
    191.  
      if ( NULL != input.tooltipString() )
    192.  
      {
    193.  
      output.setAdditionalTooltipString(_T( ", Additional comment!"));
    194.  
      acutPrintf( _T( "Appending \"%s\" to \"%s\"\n"), _T(", Additional comment!"), input.tooltipString() );
    195.  
      }
    196.  
      else
    197.  
      acutPrintf( _T( "Tooltip is NULL\n") );
    198.  
       
    199.  
      acedPostCommandPrompt();
    200.  
      return Acad::eOk;
    201.  
      }
    202.  
       
    203.  
      bool
    204.  
      AsdkInputPointMonitor::excludeFromOsnapCalculation ( const AcArray<AcDbObjectId>& nestedEntity, INT_PTR gsSelectionMark)
    205.  
      {
    206.  
      acutPrintf( _T( "\nExcludeFromOsnapCalculation called on monitor...\n") );
    207.  
      acutPrintf( _T( "%d nested entities under cursor\n"), nestedEntity.length() );
    208.  
      return false;
    209.  
      }

猜你喜欢

转载自www.cnblogs.com/mjgw/p/12392826.html