Exemplo n.º 1
0
// SCWP_Activate
XCALL_ (int) SCWP_Activate( long version, GlobalFunc *global,
                            void *local, void *serverData ) {
  if ( version != LWMODCOMMAND_VERSION )
    return AFUNC_BADVERSION;

  LWModCommand * command = (LWModCommand *)local;
  if( command == NULL )
    return AFUNC_BADLOCAL;

  // Build a list of parts for the selected polygons
  MeshEditOp *op = (command->editBegin)( 0, 0, OPSEL_DIRECT | OPSEL_MODIFY );
  parts.Flush();

  EDError err = op->polyScan( op->state, SCWP_PolyScan_FindParts, (void *)op, OPLYR_FG );
  if( err != EDERR_NONE ) {
    op->done( op->state, err, 0 );
  } else {
    // Select polygons belonging to the selected parts
    err = op->polyScan( op->state, SCWP_PolyScan_Select, (void *)op, OPLYR_FG );
    op->done( op->state, err, 0 );
  }

  // Clean up
  parts.Flush();

  return CSERR_NONE;
}
Exemplo n.º 2
0
// HandleLoad():
void HandleLoad( LWControl *con, void *data ) {
  char path[ MAX_PATH_LENGTH ];
  GET_STR( rint->load, path, MAX_PATH_LENGTH );

  if( path[0] == '\0' )
    return;

  if( !DirInfo::Exists( path ) ) {
    rint->message->error( "Replace Objects Error:  Settings file doesn't exist:", path );
    return;
  }

  pifstream in( path );
  if( !in ) {
    (*rint->message->error)( "Replace Objects Error:  File I/O error occured opening settings file", path );
    return;
  }

  // Read in the header
  in.GuessEOLType();

  char buffer[ 2048 ];
  in >> buffer;
  if( stricmp( buffer, "TMP_RPS" ) != 0 ) {
    (*rint->message->error)( "Replace Objects Error:  File isn't a Replace Objects settings file", path );
    return;
  }

  int version;
  in >>version;
  if( version != 1 ) {
    (*rint->message->error)( "Replace Objects Error:  Replace Objects settings file is an unsupported version", path );
    return;
  }

  // Loop through and load the settings
  DynArray< ReplaceObjects_SwapObject * > swaps;
  ReplaceObjects_SwapObject *new_swap = NULL;
  bool store_original_name = false;

  while( true ) {
    in >> buffer;
    if( in.eof() )
      break;

    if( in.bad() || in.fail() ) {
      swaps.Flush();
      (*rint->message->error)( "Replace Objects Error:  File I/O error occured reading settings file", path );
      return;
    }

    if( new_swap == NULL ) {
      if( stricmp( "Swap", buffer ) == 0 ) {
        new_swap = new ReplaceObjects_SwapObject;
        new_swap->SetUse( false );
        swaps.Add( new_swap );
        in >> buffer;  // Skip the {
      } else if( stricmp( "StoreOriginalNames", buffer ) == 0 ) {
        store_original_name = true;
      }
    } else {
Exemplo n.º 3
0
// SCWSS_Activate
XCALL_ (int) SCWSS_Activate( long version, GlobalFunc *global,
                             void *local, void *serverData ) {
  if ( version != LWMODCOMMAND_VERSION )
    return AFUNC_BADVERSION;

  LWModCommand * command = (LWModCommand *)local;
  if( command == NULL )
    return AFUNC_BADLOCAL;

  // Setup
  object_funcs   = (LWObjectFuncs *)global( LWOBJECTFUNCS_GLOBAL, GFUSE_TRANSIENT );
  vmap_count = object_funcs->numVMaps( LWVMAP_PICK );

  // Build a list of selection_set_ids for the selected polygons
  MeshEditOp *op = (command->editBegin)( 0, 0, OPSEL_DIRECT | OPSEL_MODIFY );
  selection_set_ids.Flush();

  EDError err = op->pointScan( op->state, SCWSS_PointScan_FindSets, (void *)op, OPLYR_FG );
  if( err != EDERR_NONE ) {
    op->done( op->state, err, 0 );
  } else {
    // If there are multiple selection sets, ask the user which one(s) they want
    bool do_select = true;
    if( selection_set_ids.NumElements() > 1 ) {
      // Get some globals
      ContextMenuFuncs *context_funcs = (ContextMenuFuncs *)global( LWCONTEXTMENU_GLOBAL, GFUSE_TRANSIENT );
      LWPanelFuncs     *panel_funcs   = (LWPanelFuncs     *)global( LWPANELFUNCS_GLOBAL,  GFUSE_TRANSIENT );

      // Set up te context menu
      LWPanPopupDesc menu_desc;
      menu_desc.type    = LWT_POPUP;
      menu_desc.width   = 200;
      menu_desc.countFn = SelSetCount;
      menu_desc.nameFn  = SelSetName;

      // Set up the panel, open the menu and clean up
      LWPanelID panel = panel_funcs->create( "Selection Sets", panel_funcs );

      LWContextMenuID menu = context_funcs->cmenuCreate( &menu_desc, NULL );
      int index = context_funcs->cmenuDeploy( menu, panel, 0 );
      context_funcs->cmenuDestroy( menu );

      panel_funcs->destroy( panel );

      // Limit to a single selection set or abort, if applicable
      if( index == -1 ) {
        do_select = false;
      } else if( index != (int)selection_set_names.NumElements() ) {
        void *id = selection_set_ids[ index ];
        selection_set_ids.Reset();
        selection_set_ids.Add( id );
      }
    }

    if( do_select ) {
      // Select points belonging to the selected selection sets
      err = op->pointScan( op->state, SCWSS_PointScan_Select, (void *)op, OPLYR_FG );
      op->done( op->state, err, 0 );
    }
  }

  // Clean up
  selection_set_ids.Reset();
  selection_set_names.Flush();

  return CSERR_NONE;
}