diff --git a/test/ios/RootBrowser/RootBrowser.xcodeproj/project.pbxproj b/test/ios/RootBrowser/RootBrowser.xcodeproj/project.pbxproj index 0c15bd6ec62c6bcd6c39652a6195d10c7f9026e0..eb2e533a53eb66c6d7f0e2a571418c5461d8fe56 100644 --- a/test/ios/RootBrowser/RootBrowser.xcodeproj/project.pbxproj +++ b/test/ios/RootBrowser/RootBrowser.xcodeproj/project.pbxproj @@ -488,7 +488,6 @@ 70E0B5D81414E2B50077E4A8 /* Top level view controllers */ = { isa = PBXGroup; children = ( - 70E0B5DF1414E41B0077E4A8 /* Standalone views */, 70E0B5DE1414E3FC0077E4A8 /* Views */, 70E0B5DB1414E2FD0077E4A8 /* Classes */, 70E0B5DA1414E2F00077E4A8 /* xibs */, @@ -535,6 +534,10 @@ 70E0B5DE1414E3FC0077E4A8 /* Views */ = { isa = PBXGroup; children = ( + 7077904113FE554E00C0FFA1 /* FileShortcut.h */, + 7077904213FE554E00C0FFA1 /* FileShortcut.mm */, + 7077906413FE87D000C0FFA1 /* ObjectShortcut.h */, + 7077906513FE87D000C0FFA1 /* ObjectShortcut.mm */, 7014410D140E18390070459F /* SelectionView.h */, 7014410E140E18390070459F /* SelectionView.mm */, 70249BDA1403D644006A19E6 /* PadView.mm */, @@ -551,17 +554,6 @@ name = Views; sourceTree = "<group>"; }; - 70E0B5DF1414E41B0077E4A8 /* Standalone views */ = { - isa = PBXGroup; - children = ( - 7077904113FE554E00C0FFA1 /* FileShortcut.h */, - 7077904213FE554E00C0FFA1 /* FileShortcut.mm */, - 7077906413FE87D000C0FFA1 /* ObjectShortcut.h */, - 7077906513FE87D000C0FFA1 /* ObjectShortcut.mm */, - ); - name = "Standalone views"; - sourceTree = "<group>"; - }; 70E0B5E11414E4710077E4A8 /* Views */ = { isa = PBXGroup; children = ( diff --git a/test/ios/Tutorials/DemoHelper.cxx b/test/ios/Tutorials/DemoHelper.cxx new file mode 100644 index 0000000000000000000000000000000000000000..75d883449e2ce889e5c353dca5f3935d31c39301 --- /dev/null +++ b/test/ios/Tutorials/DemoHelper.cxx @@ -0,0 +1,41 @@ +#include <stdexcept> +#include <memory> + +#include "ExclusionGraphDemo.h" +#include "PolarGraphDemo.h" +#include "HsimpleDemo.h" +#include "SurfaceDemo.h" +#include "H2PolyDemo.h" +#include "DemoHelper.h" +#include "LegoDemo.h" + +namespace ROOT { +namespace iOS { +namespace Demos { + +bool CreateTutorials(DemoBase **demos, const char *filePath) +{ + try { + std::auto_ptr<HsimpleDemo> demo0(new HsimpleDemo); + std::auto_ptr<SurfaceDemo> demo1(new SurfaceDemo); + std::auto_ptr<PolarGraphDemo> demo2(new PolarGraphDemo); + std::auto_ptr<LegoDemo> demo3(new LegoDemo); + std::auto_ptr<ExclusionGraphDemo> demo4(new ExclusionGraphDemo); + std::auto_ptr<H2PolyDemo> demo5(new H2PolyDemo(filePath)); + + demos[0] = demo0.release(); + demos[1] = demo1.release(); + demos[2] = demo2.release(); + demos[3] = demo3.release(); + demos[4] = demo4.release(); + demos[5] = demo5.release(); + } catch (const std::exception &e) { + return false; + } + + return false;//true; +} + +} +} +} diff --git a/test/ios/Tutorials/DemoHelper.h b/test/ios/Tutorials/DemoHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..5e50d7f77eb912fc248cce57a17fa2a042239f6b --- /dev/null +++ b/test/ios/Tutorials/DemoHelper.h @@ -0,0 +1,14 @@ +#ifndef ROOT_DemoHelper +#define ROOT_DemoHelper + +namespace ROOT { +namespace iOS { +namespace Demos { + +bool CreateTutorials(class DemoBase **demos, const char *filePath); + +} +} +} + +#endif diff --git a/test/ios/Tutorials/HsimpleDemo.cxx b/test/ios/Tutorials/HsimpleDemo.cxx index e16f48969c1f81ab3144b74536e0a685ddacc445..9b13bf68785bb6101ecc1bc4a155b776342a140e 100644 --- a/test/ios/Tutorials/HsimpleDemo.cxx +++ b/test/ios/Tutorials/HsimpleDemo.cxx @@ -1,3 +1,5 @@ +#include <stdexcept> + #include "TRandom.h" #include "TFrame.h" #include "IOSPad.h" @@ -14,6 +16,9 @@ namespace Demos { HsimpleDemo::HsimpleDemo() : fHist(new TH1F("hpx", "This is the px distribution", 100, -4.f, 4.f)) { + if (!gRandom) + throw std::runtime_error("gRandom is null"); + fHist->SetFillColor(48); } @@ -52,9 +57,6 @@ double HsimpleDemo::AnimationTime() const //______________________________________________________________________________ void HsimpleDemo::StartAnimation() { - if (!gRandom) - return; - fHist->Reset(); gRandom->SetSeed(); } @@ -63,9 +65,6 @@ void HsimpleDemo::StartAnimation() void HsimpleDemo::NextStep() { //Fill histograms randomly (2D Rannor is taken from original code sample). - if (!gRandom) - return; - Float_t x = 0.f, dummyY = 0.f; for (UInt_t i = 0; i < 1000; ++i) { diff --git a/test/ios/Tutorials/Tutorials.xcodeproj/project.pbxproj b/test/ios/Tutorials/Tutorials.xcodeproj/project.pbxproj index 3e74003b96122b58dcd1fbb81649d78686ba3259..cf2b74f0b857b4c002758987b490e16b19a08d77 100644 --- a/test/ios/Tutorials/Tutorials.xcodeproj/project.pbxproj +++ b/test/ios/Tutorials/Tutorials.xcodeproj/project.pbxproj @@ -47,6 +47,7 @@ 70BA9B5D13C5F89100102BC9 /* DetailView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 70BA9B5B13C5F89100102BC9 /* DetailView.xib */; }; 70BA9B6013C5F89100102BC9 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 70BA9B5F13C5F89100102BC9 /* RootViewController.mm */; }; 70C8237C13CF790E00F884FF /* HintView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 70C8237B13CF790E00F884FF /* HintView.mm */; }; + 70CC7E4A1456A7050036FF4C /* DemoHelper.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 70CC7E481456A7050036FF4C /* DemoHelper.cxx */; }; 70D3FB5213E7F605005BADA3 /* single_tap_icon_small.png in Resources */ = {isa = PBXBuildFile; fileRef = 70D3FB5013E7F605005BADA3 /* single_tap_icon_small.png */; }; 70D3FB5313E7F605005BADA3 /* single_tap_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 70D3FB5113E7F605005BADA3 /* single_tap_icon.png */; }; 70D4848013F057430043110B /* system.plugins-ios in Resources */ = {isa = PBXBuildFile; fileRef = 70D4847F13F057430043110B /* system.plugins-ios */; }; @@ -129,6 +130,8 @@ 70BA9B5F13C5F89100102BC9 /* RootViewController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = RootViewController.mm; path = Tutorials/RootViewController.mm; sourceTree = "<group>"; }; 70C8237A13CF790E00F884FF /* HintView.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = HintView.h; sourceTree = "<group>"; }; 70C8237B13CF790E00F884FF /* HintView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HintView.mm; sourceTree = "<group>"; }; + 70CC7E481456A7050036FF4C /* DemoHelper.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DemoHelper.cxx; sourceTree = "<group>"; }; + 70CC7E491456A7050036FF4C /* DemoHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DemoHelper.h; sourceTree = "<group>"; }; 70D3FB5013E7F605005BADA3 /* single_tap_icon_small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = single_tap_icon_small.png; path = Pictures/single_tap_icon_small.png; sourceTree = "<group>"; }; 70D3FB5113E7F605005BADA3 /* single_tap_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = single_tap_icon.png; path = Pictures/single_tap_icon.png; sourceTree = "<group>"; }; 70D4847F13F057430043110B /* system.plugins-ios */ = {isa = PBXFileReference; lastKnownFileType = text; name = "system.plugins-ios"; path = "../../../etc/system.plugins-ios"; sourceTree = "<group>"; }; @@ -318,6 +321,8 @@ 70ED86D913CB75FD00919971 /* Demos (C++ code) */ = { isa = PBXGroup; children = ( + 70CC7E481456A7050036FF4C /* DemoHelper.cxx */, + 70CC7E491456A7050036FF4C /* DemoHelper.h */, 70DF815A13DDBA6400AD2F4D /* DemoBase.cxx */, 70B059C413C9927700583EDB /* DemoBase.h */, 70DF815B13DDBA6400AD2F4D /* ExclusionGraphDemo.cxx */, @@ -450,6 +455,7 @@ 700B010F13F3D40A00F84650 /* PadOptionsController.mm in Sources */, 700B013013F3FD6700F84650 /* ColorCell.m in Sources */, 700B013313F4051000F84650 /* PatternCell.mm in Sources */, + 70CC7E4A1456A7050036FF4C /* DemoHelper.cxx in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/test/ios/Tutorials/Tutorials/RootViewController.mm b/test/ios/Tutorials/Tutorials/RootViewController.mm index 4a9ae8fe974f01906449f82743ed9082310aaaef..a8009f0521b0c1fe6aa84ab52847a7b3a3580b59 100644 --- a/test/ios/Tutorials/Tutorials/RootViewController.mm +++ b/test/ios/Tutorials/Tutorials/RootViewController.mm @@ -1,22 +1,25 @@ +#import <stdlib.h> + #import <Foundation/NSTimer.h> #import "DetailViewController.h" #import "RootViewController.h" -#import "ExclusionGraphDemo.h" -#import "PolarGraphDemo.h" -#import "HsimpleDemo.h" -#import "SurfaceDemo.h" -#import "H2PolyDemo.h" -#import "LegoDemo.h" +#import "DemoHelper.h" @implementation RootViewController - + @synthesize detailViewController; //_________________________________________________________________ - (void)viewDidLoad { + NSString *filePath = [[NSBundle mainBundle] pathForResource : @"h2poly" ofType : @"root"]; + if (!ROOT::iOS::Demos::CreateTutorials(demos, [filePath cStringUsingEncoding : [NSString defaultCStringEncoding]])) { + NSLog(@"Failed to create demos"); + exit(1); + } + tutorialNames = [[NSMutableArray alloc] init]; [tutorialNames addObject:@"Hsimple"]; [tutorialNames addObject:@"Surface"]; @@ -41,161 +44,106 @@ //This code was generated by ide. [super viewDidLoad]; + + self.clearsSelectionOnViewWillAppear = NO; self.contentSizeForViewInPopover = CGSizeMake(320.0, 500.0);//Default height was 600., I've changed it to 500. - - demos[0] = new ROOT::iOS::Demos::HsimpleDemo; - demos[1] = new ROOT::iOS::Demos::SurfaceDemo; - demos[2] = new ROOT::iOS::Demos::PolarGraphDemo; - demos[3] = new ROOT::iOS::Demos::LegoDemo; - demos[4] = new ROOT::iOS::Demos::ExclusionGraphDemo; - - NSString *filePath = [[NSBundle mainBundle] pathForResource:@"h2poly" ofType:@"root"]; - demos[5] = new ROOT::iOS::Demos::H2PolyDemo([filePath cStringUsingEncoding : [NSString defaultCStringEncoding]]); } //_________________________________________________________________ -- (void)viewWillAppear:(BOOL)animated +- (void) viewWillAppear : (BOOL)animated { - [super viewWillAppear:animated]; + [super viewWillAppear : animated]; } //_________________________________________________________________ -- (void)viewDidAppear:(BOOL)animated +- (void) viewDidAppear : (BOOL)animated { - [super viewDidAppear:animated]; + [super viewDidAppear : animated]; } //_________________________________________________________________ -- (void)viewWillDisappear:(BOOL)animated +- (void) viewWillDisappear : (BOOL)animated { - [super viewWillDisappear:animated]; + [super viewWillDisappear : animated]; } //_________________________________________________________________ -- (void)viewDidDisappear:(BOOL)animated +- (void) viewDidDisappear : (BOOL)animated { - [super viewDidDisappear:animated]; + [super viewDidDisappear : animated]; } //_________________________________________________________________ -- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +- (BOOL) shouldAutorotateToInterfaceOrientation : (UIInterfaceOrientation)interfaceOrientation { return YES; } //_________________________________________________________________ -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView +- (NSInteger) numberOfSectionsInTableView : (UITableView *)tableView { return 1; } //_________________________________________________________________ -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section +- (NSInteger) tableView : (UITableView *)tableView numberOfRowsInSection : (NSInteger)section { return [tutorialNames count]; } //_________________________________________________________________ -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath +- (UITableViewCell *) tableView : (UITableView *)tableView cellForRowAtIndexPath : (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; - UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier : CellIdentifier]; if (cell == nil) - cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; + cell = [[[UITableViewCell alloc] initWithStyle : UITableViewCellStyleDefault reuseIdentifier : CellIdentifier] autorelease]; // Configure the cell. const BOOL useDarkBackground = indexPath.row % 2; - NSString *backgroundImagePath = [[NSBundle mainBundle] pathForResource:useDarkBackground ? @"DarkBackground" : @"LightBackground" ofType:@"png"]; + NSString *backgroundImagePath = [[NSBundle mainBundle] pathForResource : useDarkBackground ? @"DarkBackground" : @"LightBackground" ofType : @"png"]; - UIImage *backgroundImage = [[UIImage imageWithContentsOfFile:backgroundImagePath] stretchableImageWithLeftCapWidth : 0.f topCapHeight : 1.f]; - cell.backgroundView = [[[UIImageView alloc] initWithImage:backgroundImage] autorelease]; + UIImage *backgroundImage = [[UIImage imageWithContentsOfFile : backgroundImagePath] stretchableImageWithLeftCapWidth : 0.f topCapHeight : 1.f]; + cell.backgroundView = [[[UIImageView alloc] initWithImage : backgroundImage] autorelease]; cell.backgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; cell.backgroundView.frame = cell.bounds; - cell.textLabel.text = [tutorialNames objectAtIndex:indexPath.row]; - cell.imageView.image = [UIImage imageNamed: [tutorialIcons objectAtIndex:indexPath.row]]; + cell.textLabel.text = [tutorialNames objectAtIndex : indexPath.row]; + cell.imageView.image = [UIImage imageNamed : [tutorialIcons objectAtIndex : indexPath.row]]; return cell; } -/* -// Override to support conditional editing of the table view. -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - // Return NO if you do not want the specified item to be editable. - return YES; -} -*/ - -/* -// Override to support editing the table view. -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath -{ - - if (editingStyle == UITableViewCellEditingStyleDelete) { - // Delete the row from the data source. - [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; - } - else if (editingStyle == UITableViewCellEditingStyleInsert) { - // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view. - } -} -*/ - -/* -// Override to support rearranging the table view. -- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath -{ -} -*/ - //_________________________________________________________________ -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath +- (void) tableView : (UITableView *)tableView didSelectRowAtIndexPath : (NSIndexPath *)indexPath { - // Navigation logic may go here -- for example, create and push another view controller. - /* - <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil]; - NSManagedObject *selectedObject = [[self fetchedResultsController] objectAtIndexPath:indexPath]; - // ... - // Pass the selected object to the new view controller. - [self.navigationController pushViewController:detailViewController animated:YES]; - [detailViewController release]; - */ - - //My code to be replaced. - detailViewController.detailItem = 0;//This will call setDetailItem and "dissolve" popover. - [detailViewController setActiveDemo:demos[indexPath.row]]; + // Navigation logic may go here -- for example, create and push another view controller. + self.detailViewController.detailItem = 0;//This will call setDetailItem and "dissolve" popover. + [self.detailViewController setActiveDemo : demos[indexPath.row]]; } //_________________________________________________________________ -- (void) onTimer -{ - demos[0]->NextStep(); -} - -//_________________________________________________________________ -- (void)didReceiveMemoryWarning +- (void) didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; - // Relinquish ownership any cached data, images, etc that aren't in use. } //_________________________________________________________________ -- (void)viewDidUnload +- (void) viewDidUnload { // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand. // For example: self.myOutlet = nil; } //_________________________________________________________________ -- (void)dealloc +- (void) dealloc { - [detailViewController release]; + self.detailViewController = nil; [tutorialNames release]; [tutorialIcons release]; @@ -206,10 +154,10 @@ } //_________________________________________________________________ -- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath +- (void) tableView : (UITableView *)tableView willDisplayCell : (UITableViewCell *)cell forRowAtIndexPath : (NSIndexPath *)indexPath { - [[cell textLabel] setBackgroundColor:[UIColor clearColor]]; - [[cell detailTextLabel] setBackgroundColor:[UIColor clearColor]]; + [[cell textLabel] setBackgroundColor : [UIColor clearColor]]; + [[cell detailTextLabel] setBackgroundColor : [UIColor clearColor]]; } @end diff --git a/test/ios/Tutorials/Tutorials/TutorialsAppDelegate.mm b/test/ios/Tutorials/Tutorials/TutorialsAppDelegate.mm index d728440b71c506f765588bea7b0c531ef583aa38..f803dea25be0d2f8ad3cd843c3649d91764d9a8c 100644 --- a/test/ios/Tutorials/Tutorials/TutorialsAppDelegate.mm +++ b/test/ios/Tutorials/Tutorials/TutorialsAppDelegate.mm @@ -72,6 +72,7 @@ [_splitViewController release]; [_rootViewController release]; [_detailViewController release]; + [super dealloc]; }