Commit 3c53d0fa authored by Sean McBride's avatar Sean McBride

Updated SimpleCocoaVTK example to build with CMake, thanks to Mike Jackson

parent ef698455
# this needs lots of work! Doesn't include NIBs, plist, etc etc etc
#--////////////////////////////////////////////////////////////////////////////
#-- Copyright (c) 2010, Michael A. Jackson. BlueQuartz Software
#-- All rights reserved.
#-- BSD License: http://www.opensource.org/licenses/bsd-license.html
#--////////////////////////////////////////////////////////////////////////////
project(SimpleCocoaVTK)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
PROJECT(SimpleCocoa)
if(NOT VTK_BINARY_DIR)
find_package(VTK)
if(NOT VTK_DIR)
message(FATAL_ERROR "Please set VTK_DIR.")
endif(NOT VTK_DIR)
include(${VTK_USE_FILE})
endif(NOT VTK_BINARY_DIR)
FIND_PACKAGE(VTK REQUIRED)
INCLUDE(${VTK_USE_FILE})
# This is needed in case we are building this project separate from the VTK build
if (NOT EXECUTABLE_OUTPUT_PATH)
set (EXECUTABLE_OUTPUT_PATH ${SimpleCocoaVTK_BINARY_DIR})
endif()
SET(MACOSX_BUNDLE_INFO_STRING "Simple Cocoa VTK")
ADD_EXECUTABLE(SimpleCocoaVTK MACOSX_BUNDLE main.m BasicVTKView.mm MyDocument.mm)
TARGET_LINK_LIBRARIES(SimpleCocoaVTK vtkRendering)
# The source files - Note because the files have both C++ and Objective-C in them
# the file extension is .mm
set (SimpleCocoaVTK_SRCS
${SimpleCocoaVTK_SOURCE_DIR}/main.mm
${SimpleCocoaVTK_SOURCE_DIR}/BasicVTKView.mm
${SimpleCocoaVTK_SOURCE_DIR}/MyDocument.mm
)
# The Headers
set (SimpleCocoaVTK_HDRS
${SimpleCocoaVTK_SOURCE_DIR}/BasicVTKView.h
${SimpleCocoaVTK_SOURCE_DIR}/MyDocument.h
)
# these are the OS X Interface Builder Files
set (SimpleCocoaVTK_XIBS
MainMenu
MyDocument
)
# Set the OS X Bundle specific CMake variables which will be used to populate the plist for
# the application bundle
set(MACOSX_BUNDLE_GUI_IDENTIFIER "org.vtk.SimpleCocoaVTK")
set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
# These variables are specific to our plist and are NOT standard CMake variables
set(MACOSX_BUNDLE_NSMAIN_NIB_FILE "MainMenu")
set(MACOSX_BUNDLE_NSPRINCIPAL_CLASS "NSApplication")
# Add our Executable
add_executable(SimpleCocoaVTK MACOSX_BUNDLE ${SimpleCocoaVTK_SRCS} ${SimpleCocoaVTK_HDRS})
# Probably a better way to set the framework link libraries.
target_link_libraries(SimpleCocoaVTK vtkRendering "-framework Cocoa -framework OpenGL -framework IOKit")
# Set a custom plist file for the app bundle
set_target_properties(SimpleCocoaVTK PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${SimpleCocoaVTK_SOURCE_DIR}/Info-CMake.plist)
# Make sure we can find the 'ibtool' program. If we can NOT find it we
# skip generation of this project
find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin")
if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND")
message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. It should have been installed with the Apple developer tools. The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin")
endif()
# Make sure the 'Resources' Directory is correctly created before we build
add_custom_command (TARGET SimpleCocoaVTK PRE_BUILD
COMMAND mkdir -p ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/SimpleCocoaVTK.app/Contents/Resources)
# Compile the .xib files using the 'ibtool' program with the destination being the app package
foreach(xib ${SimpleCocoaVTK_XIBS})
add_custom_command (TARGET SimpleCocoaVTK POST_BUILD
COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${EXECUTABLE_OUTPUT_PATH}/\${CONFIGURATION}/SimpleCocoaVTK.app/Contents/Resources/${xib}.nib ${SimpleCocoaVTK_SOURCE_DIR}/${xib}.xib
COMMENT "Compiling ${SimpleCocoaVTK_SOURCE_DIR}/${xib}.xib")
endforeach()
\ No newline at end of file
......@@ -4,8 +4,8 @@
\margl1440\margr1440\vieww21440\viewh21360\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx7380\tx7940\tx8520\ql\qnatural\pardirnatural
\f0\fs38 \cf0 SimpleCocoaVTK 1.6\
2010-05-14\
\f0\fs38 \cf0 SimpleCocoaVTK 1.7\
2010-06-17\
by: Sean McBride and Mike Jackson\
\fs34 This project is public domain.\
......@@ -60,6 +60,13 @@ If you have any problems, please post to the vtk mailing list.\
\ulnone \
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx7380\tx7940\tx8520\ql\qnatural\pardirnatural
\i \cf0 Changes in 1.7 (since 1.6)\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx7380\tx7940\tx8520\ql\qnatural\pardirnatural
\i0 \cf0 - this example can now be built by CMake.\
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx7380\tx7940\tx8520\ql\qnatural\pardirnatural
\i \cf0 Changes in 1.6 (since 1.5)\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\tx7380\tx7940\tx8520\ql\qnatural\pardirnatural
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
<key>CFBundleName</key>
<string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
<key>NSMainNibFile</key>
<string>${MACOSX_BUNDLE_NSMAIN_NIB_FILE}</string>
<key>NSPrincipalClass</key>
<string>${MACOSX_BUNDLE_NSPRINCIPAL_CLASS}</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeIconFile</key>
<string></string>
<key>CFBundleTypeName</key>
<string>DocumentType</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>MyDocument</string>
</dict>
</array>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.vtk.SimpleCocoaVTK</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeIconFile</key>
<string></string>
<key>CFBundleTypeName</key>
<string>DocumentType</string>
<key>CFBundleTypeOSTypes</key>
<array>
<string>????</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>NSDocumentClass</key>
<string>MyDocument</string>
</dict>
</array>
</dict>
</plist>
......@@ -33,7 +33,7 @@
vtkSmartPointer<vtkActor> coneActor = vtkSmartPointer<vtkActor>::New();
coneActor->SetMapper(coneMapper);
[leftVTKView getRenderer]->AddActor(coneActor);
// Tell the system that the view needs to be redrawn
[leftVTKView setNeedsDisplay:YES];
}
......@@ -74,41 +74,41 @@
return self;
}
- (void)applicationWillTerminate:(NSNotification *)aNotification
- (void)close
{
[super close];
// Releases memory allocated in initializeVTKSupport.
// In a way, calling these is pointless since the application is quitting anyway.
[leftVTKView cleanUpVTKSupport];
[rightVTKView cleanUpVTKSupport];
// If you have built vtk with VTK_DEBUG_LEAKS on then this method will print out any leaks
// that exist. The sample has been careful to cleanup after itself, so there should be no leaks.
vtkDebugLeaks::PrintCurrentLeaks();
}
- (NSString *)windowNibName
- (NSString *)windowNibName
{
// Override returning the nib file name of the document
// If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
return @"MyDocument";
}
- (void)windowControllerDidLoadNib:(NSWindowController *)windowController
- (void)windowControllerDidLoadNib:(NSWindowController *)windowController
{
[super windowControllerDidLoadNib:windowController];
// vtk stuff
[self setupLeftVTKView];
[self setupRightVTKView];
[NSApp setDelegate:self];
}
- (NSData *)dataRepresentationOfType:(NSString *)aType
{
// Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
// For applications targeted for Tiger or later systems, you should use the new Tiger API -dataOfType:error:. In this case you can also choose to override -writeToURL:ofType:error:, -fileWrapperOfType:error:, or -writeToURL:ofType:forSaveOperation:originalContentsURL:error: instead.
return nil;
......@@ -119,7 +119,7 @@
// Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
// For applications targeted for Tiger or later systems, you should use the new Tiger API readFromData:ofType:error:. In this case you can also choose to override -readFromURL:ofType:error: or -readFromFileWrapper:ofType:error: instead.
return YES;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment