コード例 #1
0
// SCWSS_PointScan_FindSets():
EDError SCWSS_PointScan_FindSets( void *_op, const EDPointInfo *point ) {
  MeshEditOp *op = (MeshEditOp *)_op;

  float val;
  if( point->flags & EDDF_SELECT ) {
    for( int v=0; v < vmap_count; v++ ) {
      const char *set_name = object_funcs->vmapName( LWVMAP_PICK, v );
      void       *set_id   = op->pointVSet( op->state, NULL, LWVMAP_PICK, set_name );

      if( op->pointVGet( op->state, point->pnt, &val) != 0 ) {
        unsigned long i;
        for( i=0; i < selection_set_ids.NumElements(); i++ ) {
          if( selection_set_ids[i] == set_id )
            break;
        }

        if( i == selection_set_ids.NumElements() ) {
          selection_set_ids.Add( set_id );
          selection_set_names.Add( StringTools::strdup( set_name ) );
        }
      }
    }
  }

  return EDERR_NONE;
}
コード例 #2
0
ファイル: WinApp.cpp プロジェクト: krang4d/code
INT_PTR CALLBACK SquerProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	TCHAR szText[80];

	wsprintf(szText, _T("HELLO WORLD!"));
	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDOK:
		{
					 int x1 = GetDlgItemInt(hDlg, IDC_X1, 0, 0);
					 int y1 = GetDlgItemInt(hDlg, IDC_Y1, 0, 0);
					 int x2 = GetDlgItemInt(hDlg, IDC_X2, 0, 0);
					 int y2 = GetDlgItemInt(hDlg, IDC_Y2, 0, 0);
					pic.Add(new Squer(Point(x1, y1), Point(x2, y2)));
		}
		case IDCANCEL:
			EndDialog(hDlg, wmId);
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
コード例 #3
0
ファイル: WinApp.cpp プロジェクト: krang4d/code
INT_PTR CALLBACK CircleProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;

	UNREFERENCED_PARAMETER(lParam);
	switch (message)
	{
	case WM_INITDIALOG:
		return (INT_PTR)TRUE;

	case WM_COMMAND:
		wmId = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDOK:
		{
					 int x = GetDlgItemInt(hDlg, IDC_X, 0, 0);
					 int y = GetDlgItemInt(hDlg, IDC_Y, 0, 0);
					 int r = GetDlgItemInt(hDlg, IDC_RADIUS, 0, 0);
					 pic.Add(new Circle(Point(x,y), r));
		}
		case IDCANCEL:
			EndDialog(hDlg, wmId);
			return (INT_PTR)TRUE;
		}
		break;
	}
	return (INT_PTR)FALSE;
}
コード例 #4
0
// FindAllItems():
//  Find all items, but not groups
void SelectOMatic_Item::FindAllItems( DynArray< SelectOMatic_Item * > &array ) {
  if( id == SOM_GROUP ) {
    for( unsigned long i=0; i < children.NumElements(); i++ )
      children[i]->FindAllItems( array );
  } else {
    array.Add( this );
  }
}
コード例 #5
0
// FindSelectedGroups():
//  Adds groups id they are selected, and adds parent groups of selected items.
void SelectOMatic_Item::FindSelectedGroups( DynArray< SelectOMatic_Item * > &array ) {
  if( id == SOM_GROUP ) {
    if( is_selected ) {
      if( array.FindIndexOf( this ) == DA_NO_MATCH )
        array.Add( this );
    }

    for( unsigned long i=0; i < children.NumElements(); i++ )
      children[i]->FindSelectedGroups( array );

  } else {
    if( is_selected ) {
      if( array.FindIndexOf( parent ) == DA_NO_MATCH )
        array.Add( parent );
    }
  }
}
コード例 #6
0
// BuildDragDropList():
//  Only adds items who's ancestors aren't selected.  Removes items from parent's list.
//   Returns true if the item was added to the list.
bool SelectOMatic_Item::BuildDragDropList( DynArray< SelectOMatic_Item * > &array, bool root ) {
  if( is_selected ) {
    if( id == SOM_GROUP ) {
      array.Add( this );
      return true;

    } else if( !root ) {
      array.Add( this );
      return true;
    }
  }

  if( id == SOM_GROUP ) {
    for( long i=0; i < (long)children.NumElements(); i++ ) {  // long handles i-- later on.  unsigned long would probably work, but hey
      if( children[i]->BuildDragDropList( array, root ) )
        children.Remove( i-- );
    }
  }

  return false;
}
コード例 #7
0
// SCWP_PolyScan_FindParts():
EDError SCWP_PolyScan_FindParts( void *_op, const EDPolygonInfo *poly ) {
  MeshEditOp *op = (MeshEditOp *)_op;

  if( poly->flags & EDDF_SELECT ) {
    const char *part = op->polyTag( op->state, poly->pol, LWPTAG_PART );
    if( part != NULL ) {
      unsigned long i;
      for( i=0; i < parts.NumElements(); i++ ) {
        if( strcmp( parts[i], part ) == 0 )
          break;
      }

      if( i == parts.NumElements() )
        parts.Add( StringTools::strdup( part ) );
    }
  }

  return EDERR_NONE;
}
コード例 #8
0
ファイル: WinApp.cpp プロジェクト: krang4d/code
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;
	TCHAR szTimerID[20];

	switch (message)
	{
	case WM_CREATE:
		OutTimeDate(hWnd);									//Первый вывод текущего времени
		SetTimer(hWnd, TIMER_01, 1000, (TIMERPROC)NULL);	//функция создает системный таймер c периодом 1с
		SetTimer(hWnd, TIMER_02, 5000, (TIMERPROC)NULL);
		pic.Add(new Circle(Point(250, 250), 150));
		pic.Add(new Circle(Point(400, 200), 50));
		pic.Add(new Circle(Point(500, 150), 100));
		pic.Add(new Line(Point(100, 100), Point(200, 200)));
		pic.Add(new Squer(Point(250, 250), Point(300, 300)));
		return TRUE;
	case WM_TIMER:
		switch (wParam)
		{
		case TIMER_01:
			OutTimeDate(hWnd);
			//MessageBox(NULL, _T("Первый таймер"), _T("wParam"), MB_ICONINFORMATION);
			break;
		case TIMER_02:
			//MessageBox(NULL, _T("Второй таймер"), _T("wParam"), MB_ICONINFORMATION);
			break;
		default:
			wsprintf((LPWSTR)szTimerID, _T("Неизвестный сигнал таймера %X"), wParam);
			MessageBox(NULL, (LPTSTR)szTimerID, _T("wParam"), MB_ICONINFORMATION);
			break;
		}
		/*
		wsprintf((LPWSTR)szTimerID, _T("%X"), wParam);
		MessageBox(NULL, (LPTSTR)szTimerID, _T("wParam"), MB_ICONINFORMATION);
		*/
		break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_LINE:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_LINE), hWnd, LineProc);
			InvalidateRect(hWnd, 0, 1);
			break;
		case IDM_CIRCLE:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_CIRCLE), hWnd, CircleProc);
			InvalidateRect(hWnd, 0, 1);
			break;
		case IDM_SQUER:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_SQUER), hWnd, SquerProc);
			InvalidateRect(hWnd, 0, 1);
			break;
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		{
			// TODO: Add any drawing code here...
			//использование функций GDI
			//перо

			HPEN hNewPen = CreatePen(PS_SOLID, 3, RGB(255, 0, 0));
			HPEN hOldPen = (HPEN)SelectObject(hdc, hNewPen);

			HBRUSH hOldBrush = (HBRUSH)SelectObject(hdc, GetStockObject(GRAY_BRUSH));
		
			for (size_t i = 0; i < pic.Size(); ++i)
				pic[i]->Draw(hdc);

			HBRUSH hNewBrush = CreateSolidBrush(RGB(255, 255, 0));
			SelectObject(hdc, hNewBrush);
			
			HBRUSH hNewBrush2 = CreateHatchBrush(HS_DIAGCROSS, RGB(0, 255, 0));
			SelectObject(hdc, hNewBrush2);

			RECT rect = {0, 0, 200, 50};
			//LPRECT lpRect = &rect;
			//GetClientRect(hWnd, lpRect);
			SetTextColor(hdc, RGB(0, 250, 0));
			//SetBkColor(hdc, RGB(250, 0, 0));
			DrawText(hdc, szCurrentTime, -1, &rect, (DT_SINGLELINE | DT_CENTER | DT_VCENTER));
			
			SelectObject(hdc, hOldBrush);
			SelectObject(hdc, hOldPen);
			DeleteObject(hNewBrush);
			DeleteObject(hNewBrush2);
			DeleteObject(hNewPen);
		}
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		for (size_t i = 0; i < pic.Size(); ++i)
			delete pic[i];
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
コード例 #9
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 {
コード例 #10
0
// SimplifyCreate()
XCALL_ (LWInstance) SimplifyCreate( LWError	*err, LWItemID item ) {
  SimplifyInstance *inst = new SimplifyInstance;

  // Make sure the instance was allocated OK
  if( inst == NULL ) {
    const char *string = "Simplify Error:  Unable to create instance!";
    err = &string;
    return NULL;
  }

  // Get the Object Info Functions so we can get the object's filename
  CLWObjectInfo * obj_info = CLWObjectInfo::New( (LWObjectInfo *) (*SimplifyInstance::GetGlobal())("LW Object Info", GFUSE_TRANSIENT ) );
  CMessage * message = CMessage::New( (MessageFuncs *) (*SimplifyInstance::GetGlobal())("Info Messages", GFUSE_TRANSIENT) );

  if( !obj_info ) {
    message->Error( "Simplify Error:  Unable to get LW Object Info!" );
    return false;
  }

  // Set the Defauit Nominal Camera Zoom, in case the auto-load fails
  LWItemInfo *iteminfo = (LWItemInfo *)(*SimplifyInstance::GetGlobal())( "LW Item Info", GFUSE_TRANSIENT );
  LWItemID cam_id = (*iteminfo->first)( LWI_CAMERA, NULL );
  LWCameraInfo *camerainfo = (LWCameraInfo *)(*SimplifyInstance::GetGlobal())( "LW Camera Info", GFUSE_TRANSIENT );

  double default_zoom_factor = (*camerainfo->zoomFactor)( cam_id, 0 );
  inst->SetLODNominalCameraZoom( (float)default_zoom_factor );

  // See if an Auto-Load SDF exists
  char def_sdf[ MAX_PATH_LENGTH ];
  if( simp_global.autoload ) {
    // Get DirFuncs so we can get the Content Dir
    DirInfoFunc * dir_func = (DirInfoFunc *) (*SimplifyInstance::GetGlobal())("Directory Info", GFUSE_TRANSIENT );
    strcpy( def_sdf, obj_info->Filename( item ) );
    DirStrings::ChangeExtension( def_sdf, ".SDF" );
    inst->SetSDF( def_sdf );

    strcpy( def_sdf, (*dir_func)( "Content" ) );
    DirStrings::AddPathPart( def_sdf, inst->GetSDF() );

    if( DirInfo::Exists( def_sdf ) ) {
      char * error;
      if( !inst->LoadFromFile( def_sdf, error ) ) {
        // Error loading default instance; create a clean one
        delete inst;
        inst = new SimplifyInstance;
        message->Error( error_buffer );
        message->Error( "Simplify Error: Unable to auto-load default instance data for ", obj_info->Filename( inst->GetItemID() ) );
      }

      delete message;
    } else if( simp_config.GetDefaultSDF() != NULL ) {
      // Default SDF not found; load the default one from the user config, if it exists
      if( DirInfo::Exists( simp_config.GetDefaultSDF() ) ) {
        char * error;
        if( !inst->LoadFromFile( simp_config.GetDefaultSDF(), error ) ) {
          // Error loading default instance; create a clean one
          delete inst;
          inst = new SimplifyInstance;
          message->Error( error_buffer );
          message->Error( "Simplify Error: Unable to auto-load deafult instance data from",
                          simp_config.GetDefaultSDF() );
        }

        delete message;
      }
    }
  }

  // Set the item used by the instance
  inst->SetItemID( item );

  // Set the Render Filename to the object's filename, if needed
  if( inst->GetRender()[0] == '\0' )
    inst->SetRender( obj_info->Filename( inst->GetItemID() ) );

  // Free obj_info
  delete obj_info;

  // Instance OK; return it
  instances.Add( inst );
  err = NULL;
  return inst;
}
コード例 #11
0
// ParticleCloud_Create():
LWInstance ParticleCloud_Create( void *data, void *context, LWError *error ) {
  ParticleCloud_Instance *inst = new ParticleCloud_Instance( context );
  instances.Add( inst );
  return inst;
}
コード例 #12
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;
}