diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index 3a434e3356b7ed8a82c7b71ea449daec203e3ff1..cfe5073a10a00295e7a1acd3f219f66787addd86 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -86,7 +86,7 @@ void drawContext::load(std::string filename) // run getdp witout parameter onelab_cb("check"); - // to allow the firs run + // to allow the first run onelab::server::instance()->setChanged(true, "Gmsh"); onelab::server::instance()->setChanged(true, "GetDP"); } @@ -487,7 +487,7 @@ void drawContext::drawGeom() //glLineWidth((GLfloat)CTX::instance()->geom.lineWidth); OpenGL Error -> GL_INVALID_VALUE​, 0x0501 for(GModel::eiter it = GModel::current()->firstEdge(); it != GModel::current()->lastEdge(); it++){ GEdge *e = *it; - int N = e->minimumDrawSegments() + 1; + int N = e->minimumDrawSegments() + 1; // e is sometime incorrect (e.g. 0x0000004f) when compute Range<double> t_bounds = e->parBounds(0); double t_min = t_bounds.low(); double t_max = t_bounds.high(); @@ -591,8 +591,6 @@ void drawContext::drawView() glTranslatef(_translate[0], _translate[1], _translate[2]); this->buildRotationMatrix(); glMultMatrixf(_rotatef); - //glTranslatef(this->_translate[0]/this->_height,this->_translate[1]/this->_width,0); - //glScalef(this->_scale[0], this->_scale[1], this->_scale[2]); checkGlError("Initialize position"); // diff --git a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj index c8a0972ed3340dd258b387c219f491e510122722..5c08e192d4cb027aeee6a4498b122445e2767e1d 100644 --- a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj +++ b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj @@ -8,7 +8,7 @@ /* Begin PBXBuildFile section */ 9C6A645817A7C3DB00DEDAFC /* drawString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9C6A645617A7C3DB00DEDAFC /* drawString.cpp */; }; - 9C95B7F61726C88E00C0CCE2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C95B7F51726C88E00C0CCE2 /* main.m */; }; + 9C95B7F61726C88E00C0CCE2 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C95B7F51726C88E00C0CCE2 /* main.mm */; }; 9C96083B1712C16300E1D4A0 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C96083A1712C16300E1D4A0 /* UIKit.framework */; }; 9C96083D1712C16300E1D4A0 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C96083C1712C16300E1D4A0 /* Foundation.framework */; }; 9C96083F1712C16300E1D4A0 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C96083E1712C16300E1D4A0 /* CoreGraphics.framework */; }; @@ -33,12 +33,20 @@ 9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0E178AEB1600A83B4B /* Gmsh.framework */; }; 9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0F178AEB1600A83B4B /* petsc.framework */; }; 9CE08E13178AEC5F00A83B4B /* drawContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E01178AE6BE00A83B4B /* drawContext.cpp */; }; - 9CE08E14178AEC5F00A83B4B /* drawContext.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E02178AE6BE00A83B4B /* drawContext.h */; }; - 9CE08E15178AEC5F00A83B4B /* iosGModel.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C99754C17390DEE0036EC24 /* iosGModel.h */; }; 9CE08E16178AEC5F00A83B4B /* movePosition.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E03178AE6BE00A83B4B /* movePosition.h */; }; 9CE08E17178AEC5F00A83B4B /* Trackball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E04178AE6BE00A83B4B /* Trackball.cpp */; }; - 9CE08E18178AEC5F00A83B4B /* Trackball.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E05178AE6BE00A83B4B /* Trackball.h */; }; + 9CE1A65717B0F39D00E5152F /* Utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CE1A65617B0F39D00E5152F /* Utils.mm */; }; 9CEAE86E17AF824B00813524 /* iosGModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAE86D17AF824B00813524 /* iosGModel.cpp */; }; + 9CEAE86F17AFCFCB00813524 /* AppDelegate.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C9608491712C16300E1D4A0 /* AppDelegate.h */; }; + 9CEAE87017AFCFCB00813524 /* iosGModel.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C99754C17390DEE0036EC24 /* iosGModel.h */; }; + 9CEAE87117AFCFCB00813524 /* drawContext.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E02178AE6BE00A83B4B /* drawContext.h */; }; + 9CEAE87217AFCFCB00813524 /* drawString.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C6A645717A7C3DB00DEDAFC /* drawString.h */; }; + 9CEAE87317AFCFCB00813524 /* Trackball.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E05178AE6BE00A83B4B /* Trackball.h */; }; + 9CEAE87417AFCFCB00813524 /* MasterViewController.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C96084F1712C16400E1D4A0 /* MasterViewController.h */; }; + 9CEAE87517AFCFCB00813524 /* DetailViewController.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C9608521712C16400E1D4A0 /* DetailViewController.h */; }; + 9CEAE87617AFCFCB00813524 /* EAGLView.h in Sources */ = {isa = PBXBuildFile; fileRef = 9C9608721712C47200E1D4A0 /* EAGLView.h */; }; + 9CEAE87717AFCFCB00813524 /* ModelListController.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAECC517A91CD20014D229 /* ModelListController.h */; }; + 9CEAE87D17AFD5BB00813524 /* SplitViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAE87C17AFD5BB00813524 /* SplitViewController.mm */; }; 9CEAECC717A91CD20014D229 /* ModelListController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAECC617A91CD20014D229 /* ModelListController.mm */; }; 9CF1C1ED17AA6E7E002CD2E3 /* iPhoneStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9CF1C1EB17AA6E7E002CD2E3 /* iPhoneStoryboard.storyboard */; }; 9CF1C1EF17AA8997002CD2E3 /* Onelab-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9CF1C1EE17AA8997002CD2E3 /* Onelab-Info.plist */; }; @@ -57,7 +65,7 @@ /* Begin PBXFileReference section */ 9C6A645617A7C3DB00DEDAFC /* drawString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drawString.cpp; sourceTree = "<group>"; }; 9C6A645717A7C3DB00DEDAFC /* drawString.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drawString.h; sourceTree = "<group>"; }; - 9C95B7F51726C88E00C0CCE2 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; }; + 9C95B7F51726C88E00C0CCE2 /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; }; 9C9608361712C16300E1D4A0 /* Onelab.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Onelab.app; sourceTree = BUILT_PRODUCTS_DIR; }; 9C96083A1712C16300E1D4A0 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 9C96083C1712C16300E1D4A0 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -93,7 +101,11 @@ 9CE08E0D178AEB1600A83B4B /* GetDP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GetDP.framework; path = Onelab/frameworks/GetDP.framework; sourceTree = "<group>"; }; 9CE08E0E178AEB1600A83B4B /* Gmsh.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gmsh.framework; path = Onelab/frameworks/Gmsh.framework; sourceTree = "<group>"; }; 9CE08E0F178AEB1600A83B4B /* petsc.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = petsc.framework; path = Onelab/frameworks/petsc.framework; sourceTree = "<group>"; }; + 9CE1A65517B0F39C00E5152F /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; }; + 9CE1A65617B0F39D00E5152F /* Utils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Utils.mm; sourceTree = "<group>"; }; 9CEAE86D17AF824B00813524 /* iosGModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = iosGModel.cpp; sourceTree = "<group>"; }; + 9CEAE87B17AFD5BB00813524 /* SplitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitViewController.h; sourceTree = "<group>"; }; + 9CEAE87C17AFD5BB00813524 /* SplitViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SplitViewController.mm; sourceTree = "<group>"; }; 9CEAECC517A91CD20014D229 /* ModelListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelListController.h; sourceTree = "<group>"; }; 9CEAECC617A91CD20014D229 /* ModelListController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModelListController.mm; sourceTree = "<group>"; }; 9CF1C1EC17AA6E7E002CD2E3 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/iPhoneStoryboard.storyboard; sourceTree = "<group>"; }; @@ -186,6 +198,8 @@ 9CE08E03178AE6BE00A83B4B /* movePosition.h */, 9CE08E05178AE6BE00A83B4B /* Trackball.h */, 9CE08E04178AE6BE00A83B4B /* Trackball.cpp */, + 9CE1A65517B0F39C00E5152F /* Utils.h */, + 9CE1A65617B0F39D00E5152F /* Utils.mm */, 9C96084F1712C16400E1D4A0 /* MasterViewController.h */, 9C9608501712C16400E1D4A0 /* MasterViewController.mm */, 9C9608521712C16400E1D4A0 /* DetailViewController.h */, @@ -195,6 +209,8 @@ 9C96089E1712C8EB00E1D4A0 /* emulatorFix.c */, 9CEAECC517A91CD20014D229 /* ModelListController.h */, 9CEAECC617A91CD20014D229 /* ModelListController.mm */, + 9CEAE87B17AFD5BB00813524 /* SplitViewController.h */, + 9CEAE87C17AFD5BB00813524 /* SplitViewController.mm */, 9CF1C1F017AA8A46002CD2E3 /* Supporting Files */, ); path = Onelab; @@ -223,7 +239,7 @@ isa = PBXGroup; children = ( 9CF1C1F117AA8A7D002CD2E3 /* Onelab-Prefix.pch */, - 9C95B7F51726C88E00C0CCE2 /* main.m */, + 9C95B7F51726C88E00C0CCE2 /* main.mm */, 9CF1C1EE17AA8997002CD2E3 /* Onelab-Info.plist */, ); name = "Supporting Files"; @@ -340,21 +356,29 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 9CEAE86F17AFCFCB00813524 /* AppDelegate.h in Sources */, + 9CEAE87017AFCFCB00813524 /* iosGModel.h in Sources */, + 9CEAE87117AFCFCB00813524 /* drawContext.h in Sources */, + 9CEAE87217AFCFCB00813524 /* drawString.h in Sources */, + 9CEAE87317AFCFCB00813524 /* Trackball.h in Sources */, + 9CEAE87417AFCFCB00813524 /* MasterViewController.h in Sources */, + 9CEAE87517AFCFCB00813524 /* DetailViewController.h in Sources */, + 9CEAE87617AFCFCB00813524 /* EAGLView.h in Sources */, + 9CEAE87717AFCFCB00813524 /* ModelListController.h in Sources */, 9CE08E13178AEC5F00A83B4B /* drawContext.cpp in Sources */, - 9CE08E14178AEC5F00A83B4B /* drawContext.h in Sources */, - 9CE08E15178AEC5F00A83B4B /* iosGModel.h in Sources */, 9CE08E16178AEC5F00A83B4B /* movePosition.h in Sources */, 9CE08E17178AEC5F00A83B4B /* Trackball.cpp in Sources */, - 9CE08E18178AEC5F00A83B4B /* Trackball.h in Sources */, 9C96084B1712C16400E1D4A0 /* AppDelegate.mm in Sources */, 9C9608511712C16400E1D4A0 /* MasterViewController.mm in Sources */, 9C9608541712C16400E1D4A0 /* DetailViewController.mm in Sources */, 9C9608741712C47200E1D4A0 /* EAGLView.mm in Sources */, 9C96089F1712C8EB00E1D4A0 /* emulatorFix.c in Sources */, - 9C95B7F61726C88E00C0CCE2 /* main.m in Sources */, + 9C95B7F61726C88E00C0CCE2 /* main.mm in Sources */, 9C6A645817A7C3DB00DEDAFC /* drawString.cpp in Sources */, 9CEAECC717A91CD20014D229 /* ModelListController.mm in Sources */, 9CEAE86E17AF824B00813524 /* iosGModel.cpp in Sources */, + 9CEAE87D17AFD5BB00813524 /* SplitViewController.mm in Sources */, + 9CE1A65717B0F39D00E5152F /* Utils.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/contrib/mobile/iOS/Onelab/AppDelegate.h b/contrib/mobile/iOS/Onelab/AppDelegate.h index 80823f71ad9a7580deeb3ac03c894e98afebc43f..60182856ba2ea8cb325a03f97f66731c2d198a41 100644 --- a/contrib/mobile/iOS/Onelab/AppDelegate.h +++ b/contrib/mobile/iOS/Onelab/AppDelegate.h @@ -8,11 +8,15 @@ #import <UIKit/UIKit.h> +#include "SplitViewController.h" + @interface AppDelegate : UIResponder <UIApplicationDelegate>{ @public } @property (strong, nonatomic) UIWindow *window; +@property (strong, nonatomic) UITableViewController *modelListController; +@property (strong, nonatomic) SplitViewController *splitViewController; @end diff --git a/contrib/mobile/iOS/Onelab/AppDelegate.mm b/contrib/mobile/iOS/Onelab/AppDelegate.mm index 62eed5fa5303fd1b5fe54f374f84ebe292c68e0e..d984b6497034220f294bf00e65553bca874354f3 100644 --- a/contrib/mobile/iOS/Onelab/AppDelegate.mm +++ b/contrib/mobile/iOS/Onelab/AppDelegate.mm @@ -7,16 +7,17 @@ // #import "AppDelegate.h" +#import "ModelListController.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. + self.modelListController = (ModelListController *)self.window.rootViewController; if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ - UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; - UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; - splitViewController.delegate = (id)navigationController.topViewController; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"iPadStoryboard" bundle:nil]; + self.splitViewController = [storyboard instantiateViewControllerWithIdentifier:@"SplitViewController"]; } return YES; } diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.h b/contrib/mobile/iOS/Onelab/DetailViewController.h index ea576fab23af44d28428d9738ba08aae056049e0..2c6721f19bab490fb5896f05bdb4cae0de3129c3 100644 --- a/contrib/mobile/iOS/Onelab/DetailViewController.h +++ b/contrib/mobile/iOS/Onelab/DetailViewController.h @@ -8,7 +8,6 @@ #import <UIKit/UIKit.h> #import "EAGLView.h" -#import "AppDelegate.h" #include <gmsh/PView.h> #include <gmsh/PViewData.h> diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.mm b/contrib/mobile/iOS/Onelab/DetailViewController.mm index 43d8125db35d7f8434c8e8d4805eda51797b340e..ab97d6b339a4eb1d5c8f4ee3d2757f34017b5785 100644 --- a/contrib/mobile/iOS/Onelab/DetailViewController.mm +++ b/contrib/mobile/iOS/Onelab/DetailViewController.mm @@ -10,8 +10,7 @@ #import "DetailViewController.h" #import "iosGModel.h" -#import "ModelListController.h" -#import "MasterViewController.h" +#import "AppDelegate.h" @interface DetailViewController () @property (strong, nonatomic) UIPopoverController *masterPopoverController; @@ -60,8 +59,16 @@ UIBarButtonItem *more = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showMore:)]; UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Load model" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; NSArray *btns = [[NSArray alloc] initWithObjects:settings, postpro, more, nil]; - [self.navigationItem setLeftBarButtonItems:btns]; - [self.navigationItem setRightBarButtonItem:model]; + [self.navigationController.navigationItem setLeftBarButtonItems:btns]; + [self.navigationController.navigationItem setRightBarButtonItem:model]; + } + else { + UIBarButtonItem *postpro = [[UIBarButtonItem alloc] initWithTitle:@"Post processing" style:UIBarButtonItemStyleBordered target:self action:@selector(showPostpro)]; + UIBarButtonItem *more = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showMore:)]; + UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Load model" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; + NSArray *btns = [[NSArray alloc] initWithObjects:postpro, more, nil]; + self.navigationItem.rightBarButtonItem = model; + self.navigationItem.leftBarButtonItems = btns; } } @@ -115,9 +122,15 @@ - (void) showModelsList { - ModelListController *modelListController = [[ModelListController alloc] init]; - modelListController.glView = glView; - [self.navigationController pushViewController:modelListController animated:true]; + if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ + AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; + [UIView transitionWithView:appDelegate.window + duration:0.5 + options:UIViewAnimationOptionTransitionFlipFromRight + animations:^{ appDelegate.window.rootViewController = appDelegate.modelListController; } + completion:nil]; + } + [self.navigationController popToRootViewControllerAnimated:YES]; } - (void) showSettings @@ -264,8 +277,8 @@ UIBarButtonItem *more = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(showMore:)]; UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Load model" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; NSArray *btns = [[NSArray alloc] initWithObjects:barButtonItem, postpro, more, nil]; - [self.navigationItem setLeftBarButtonItems:btns]; - [self.navigationItem setRightBarButtonItem:model]; + [self.navigationController.navigationItem setLeftBarButtonItems:btns]; + [self.navigationController.navigationItem setRightBarButtonItem:model]; self.masterPopoverController = popoverController; } diff --git a/contrib/mobile/iOS/Onelab/EAGLView.h b/contrib/mobile/iOS/Onelab/EAGLView.h index db9872cafc8f9f73f996bd3c2f6810af8982e7aa..1abbfe9bbc1070ea9f54d01284e2aecf079a0bf9 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.h +++ b/contrib/mobile/iOS/Onelab/EAGLView.h @@ -26,6 +26,7 @@ GLuint depthRenderbuffer; NSString *docPath; + BOOL rendering; @public /* our GModel drawing class */ drawContext *mContext; @@ -33,6 +34,6 @@ - (void)drawView; -- (void)loadMsh:(NSString*) file; +- (void)load:(NSString*) file; @end diff --git a/contrib/mobile/iOS/Onelab/EAGLView.mm b/contrib/mobile/iOS/Onelab/EAGLView.mm index 07c2ee68d95a5740725a5bc0039516b6839f0036..40856b830cb5fe07b8bb93f0af4a18165213e368 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.mm +++ b/contrib/mobile/iOS/Onelab/EAGLView.mm @@ -42,32 +42,16 @@ //[self release]; return nil; } - [self copyRes]; - NSString *startupModel = [docPath stringByAppendingPathComponent:@"pmsm/pmsm.geo"]; - mContext = new drawContext(); - mContext->load(*new std::string([startupModel fileSystemRepresentation])); } + rendering = NO; return self; } -- (void) copyRes -{ - NSString *resPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"files"]; - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - docPath = [paths objectAtIndex:0]; //Get the docs directory - - NSArray *resContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resPath error:NULL]; - - for (NSString* obj in resContents){ - NSError* error; - if (![[NSFileManager defaultManager] copyItemAtPath:[resPath stringByAppendingPathComponent:obj] toPath:[docPath stringByAppendingPathComponent:obj] error:&error]) - NSLog(@"Error: %@", error);; - } -} - - (void)drawView { + if(rendering) return; + rendering = YES; [EAGLContext setCurrentContext:context]; glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); @@ -77,11 +61,13 @@ glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; + rendering = NO; } -- (void)loadMsh:(NSString*) file +- (void)load:(NSString*) file { mContext->load(*new std::string([file fileSystemRepresentation])); [self drawView]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; } - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { diff --git a/contrib/mobile/iOS/Onelab/MasterViewController.h b/contrib/mobile/iOS/Onelab/MasterViewController.h index 267356007c732de6ad60c3873419757be3624ce3..c6be3b25335cbe75fa55285c94c95058d3ccb2de 100644 --- a/contrib/mobile/iOS/Onelab/MasterViewController.h +++ b/contrib/mobile/iOS/Onelab/MasterViewController.h @@ -9,8 +9,6 @@ #import <UIKit/UIKit.h> #import <Gmsh/onelab.h> -#import "AppDelegate.h" - @class DetailViewController; @interface MasterViewController : UITableViewController <UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate> diff --git a/contrib/mobile/iOS/Onelab/ModelListController.h b/contrib/mobile/iOS/Onelab/ModelListController.h index 8d76d7c75a7bf4161dfa96aa73e58f1c72a2a36b..b7732fc9fc26275a5168d3715d2a9fc9c6f275bd 100644 --- a/contrib/mobile/iOS/Onelab/ModelListController.h +++ b/contrib/mobile/iOS/Onelab/ModelListController.h @@ -8,7 +8,6 @@ #import <UIKit/UIKit.h> -#import "AppDelegate.h" #import "EAGLView.h" @interface ModelListController : UITableViewController <NSXMLParserDelegate> diff --git a/contrib/mobile/iOS/Onelab/ModelListController.mm b/contrib/mobile/iOS/Onelab/ModelListController.mm index 8e0860949fd167de29e167da4e8de35900f26044..25cb9d247d195819069ba5588854a6ce272dea6c 100644 --- a/contrib/mobile/iOS/Onelab/ModelListController.mm +++ b/contrib/mobile/iOS/Onelab/ModelListController.mm @@ -6,8 +6,11 @@ // Copyright (c) 2013 Maxime Graulich. All rights reserved. // +#import "AppDelegate.h" #import "ModelListController.h" +#import "Utils.h" + @interface ModelListController () { } @@ -19,9 +22,9 @@ models = [[NSMutableArray alloc] init]; modelsName = [[NSMutableArray alloc] init]; modelsDescription = [[NSMutableArray alloc] init]; - NSString *docsPath = [ModelListController getApplicationDocumentsDirectory]; - + NSString *docsPath = [Utils getApplicationDocumentsDirectory]; + [Utils copyRes]; NSArray *docs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docsPath error:NULL]; for(NSString* doc in docs){ NSString *docPath = [NSString stringWithFormat:@"%@/%@/", docsPath, doc]; @@ -72,16 +75,21 @@ } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { - NSString *modelName = [models objectAtIndex:indexPath.row]; - [_glView loadMsh:[NSString stringWithFormat:@"%@/%@/%@.geo",[ModelListController getApplicationDocumentsDirectory],modelName,modelName]]; - [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; - [self.navigationController popViewControllerAnimated:YES]; -} -+ (NSString *) getApplicationDocumentsDirectory -{ - NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); - NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; - return basePath; + if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ + AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; + appDelegate.splitViewController.initialModel = [NSString stringWithFormat:@"%@/%@/%@.geo",[Utils getApplicationDocumentsDirectory],[models objectAtIndex:indexPath.row], [models objectAtIndex:indexPath.row]]; + [UIView transitionWithView:appDelegate.window + duration:0.5 + options:UIViewAnimationOptionTransitionFlipFromLeft + animations:^{ appDelegate.window.rootViewController = appDelegate.splitViewController; } + completion:nil]; + } + else + { + DetailViewController *detailVIewController = [[DetailViewController alloc] init]; + [detailVIewController.glView load:[NSString stringWithFormat:@"%@/%@/%@.geo",[Utils getApplicationDocumentsDirectory],[modelsName objectAtIndex:indexPath.row], [modelsName objectAtIndex:indexPath.row]]]; + [self.navigationController pushViewController:detailVIewController animated:YES]; + } } - (BOOL) parseInfosFile:(NSString *)file { diff --git a/contrib/mobile/iOS/Onelab/Onelab-Info.plist b/contrib/mobile/iOS/Onelab/Onelab-Info.plist index 42169d20dc47fe86dbb858535e3751efa5f02ed4..fb76d80fd55af7d7c5d2614acb4ba765557583e3 100644 --- a/contrib/mobile/iOS/Onelab/Onelab-Info.plist +++ b/contrib/mobile/iOS/Onelab/Onelab-Info.plist @@ -8,6 +8,17 @@ <string>${PRODUCT_NAME}</string> <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> + <key>CFBundleIcons</key> + <dict> + <key>CFBundlePrimaryIcon</key> + <dict> + <key>CFBundleIconFiles</key> + <array> + <string>ic_launcher.png</string> + <string>ic_launcher_retina.png</string> + </array> + </dict> + </dict> <key>CFBundleIdentifier</key> <string>org.geuz.${PRODUCT_NAME:rfc1034identifier}</string> <key>CFBundleInfoDictionaryVersion</key> diff --git a/contrib/mobile/iOS/Onelab/SplitViewController.h b/contrib/mobile/iOS/Onelab/SplitViewController.h new file mode 100644 index 0000000000000000000000000000000000000000..9a02c18e09849ce66331227ce9d0ce3f1c0de0a4 --- /dev/null +++ b/contrib/mobile/iOS/Onelab/SplitViewController.h @@ -0,0 +1,21 @@ +// +// SplitViewController.h +// Onelab +// +// Created by Maxime Graulich on 05/08/13. +// Copyright (c) 2013 Maxime Graulich. All rights reserved. +// + +#import <UIKit/UIKit.h> + +#import "MasterViewController.h" +#import "DetailViewController.h" + +@interface SplitViewController : UISplitViewController{ + DetailViewController *detailViewController; + MasterViewController *masterViewController; +} + +@property (nonatomic, retain) NSString *initialModel; + +@end diff --git a/contrib/mobile/iOS/Onelab/SplitViewController.mm b/contrib/mobile/iOS/Onelab/SplitViewController.mm new file mode 100644 index 0000000000000000000000000000000000000000..aabcd3f33bf2b04ec30d3184a5d48217d0dcffdd --- /dev/null +++ b/contrib/mobile/iOS/Onelab/SplitViewController.mm @@ -0,0 +1,50 @@ +// +// SplitViewController.m +// Onelab +// +// Created by Maxime Graulich on 05/08/13. +// Copyright (c) 2013 Maxime Graulich. All rights reserved. +// + +#import "SplitViewController.h" + +@interface SplitViewController () + +@end + +@implementation SplitViewController + +-(void)viewDidAppear:(BOOL)animated +{ + //UINavigationController *left = [self.viewControllers objectAtIndex:0]; // left UINavigationController (Master) + UINavigationController *right = [self.viewControllers objectAtIndex:1]; // right UINavigationController (Detail) + for(UIViewController *v in right.viewControllers){ + if ([v isKindOfClass:[DetailViewController class]]) { + detailViewController = (DetailViewController *)v; + } + } + if(self.initialModel != nil) [detailViewController.glView load:self.initialModel]; +} + +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; + if (self) { + // Custom initialization + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + // Do any additional setup after loading the view. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +@end diff --git a/contrib/mobile/iOS/Onelab/Utils.h b/contrib/mobile/iOS/Onelab/Utils.h new file mode 100644 index 0000000000000000000000000000000000000000..5dab5ad53afaf562d6a578b0a4f5e71caa7fe3d8 --- /dev/null +++ b/contrib/mobile/iOS/Onelab/Utils.h @@ -0,0 +1,16 @@ +// +// Utils.h +// Onelab +// +// Created by Maxime Graulich on 06/08/13. +// Copyright (c) 2013 Maxime Graulich. All rights reserved. +// + +#import <Foundation/Foundation.h> + +@interface Utils : NSObject + ++ (NSString *) getApplicationDocumentsDirectory; ++ (void) copyRes; + +@end diff --git a/contrib/mobile/iOS/Onelab/Utils.mm b/contrib/mobile/iOS/Onelab/Utils.mm new file mode 100644 index 0000000000000000000000000000000000000000..62f97789b890c3dd9cf43de8fc113ed501c7d6ac --- /dev/null +++ b/contrib/mobile/iOS/Onelab/Utils.mm @@ -0,0 +1,35 @@ +// +// Utils.m +// Onelab +// +// Created by Maxime Graulich on 06/08/13. +// Copyright (c) 2013 Maxime Graulich. All rights reserved. +// + +#import "Utils.h" + +@implementation Utils + ++ (NSString *) getApplicationDocumentsDirectory +{ + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *basePath = ([paths count] > 0) ? [paths objectAtIndex:0] : nil; + return basePath; +} + ++ (void) copyRes +{ + NSString *resPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"files"]; + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *docPath = [paths objectAtIndex:0]; //Get the docs directory + + NSArray *resContents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:resPath error:NULL]; + + for (NSString* obj in resContents){ + NSError* error; + if (![[NSFileManager defaultManager] copyItemAtPath:[resPath stringByAppendingPathComponent:obj] toPath:[docPath stringByAppendingPathComponent:obj] error:&error]) + NSLog(@"Error: %@", error);; + } +} + +@end diff --git a/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard b/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard index 22f7e1e20f94a1867663914a8e41b8169604eaa0..a3fb5e30768533ed28096566c9e4e1eec179fd4d 100644 --- a/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard +++ b/contrib/mobile/iOS/Onelab/en.lproj/iPadStoryboard.storyboard @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12E55" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="5"> +<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12E55" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" initialViewController="dwa-Pq-2vA"> <dependencies> <deployment defaultVersion="1552" identifier="iOS"/> <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/> @@ -23,8 +23,8 @@ <!--Detail View Controller - Detail--> <scene sceneID="16"> <objects> - <viewController storyboardIdentifier="" title="Detail" id="4" customClass="DetailViewController" sceneMemberID="viewController"> - <view key="view" contentMode="scaleToFill" id="26" customClass="EAGLView"> + <viewController storyboardIdentifier="DetailViewController" title="Detail" id="4" customClass="DetailViewController" sceneMemberID="viewController"> + <view key="view" multipleTouchEnabled="YES" contentMode="scaleToFill" id="26" customClass="EAGLView"> <rect key="frame" x="0.0" y="64" width="703" height="660"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/> @@ -39,7 +39,6 @@ <simulatedToolbarMetrics key="simulatedBottomBarMetrics"/> <connections> <outlet property="glView" destination="26" id="i7d-I7-Zhz"/> - <segue destination="E9F-81-Qlc" kind="push" id="NvT-Dc-KH4"/> </connections> </viewController> <placeholder placeholderIdentifier="IBFirstResponder" id="15" sceneMemberID="firstResponder"/> @@ -56,53 +55,66 @@ </objects> <point key="canvasLocation" x="1144" y="330"/> </scene> - <!--Model List Controller - Load a new model--> - <scene sceneID="ggP-yy-g12"> + <!--Split View Controller--> + <scene sceneID="18"> <objects> - <tableViewController id="E9F-81-Qlc" customClass="ModelListController" sceneMemberID="viewController"> - <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="tal-df-VsP"> - <rect key="frame" x="0.0" y="64" width="703" height="660"/> + <splitViewController storyboardIdentifier="SplitViewController" id="5" customClass="SplitViewController" sceneMemberID="viewController"> + <toolbarItems/> + <navigationItem key="navigationItem" id="Pnc-za-KDo"/> + <simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackTranslucent"/> + <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> + <connections> + <segue destination="3" kind="relationship" relationship="masterViewController" id="9"/> + <segue destination="42" kind="relationship" relationship="detailViewController" id="51"/> + </connections> + </splitViewController> + <placeholder placeholderIdentifier="IBFirstResponder" id="17" sceneMemberID="firstResponder"/> + </objects> + <point key="canvasLocation" x="-879" y="-806"/> + </scene> + <!--Model List Controller - Models list--> + <scene sceneID="af3-vl-hzw"> + <objects> + <tableViewController id="dVI-Oo-Sq4" customClass="ModelListController" sceneMemberID="viewController"> + <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="OmH-vi-qhj"> + <rect key="frame" x="0.0" y="64" width="768" height="960"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/> - <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> <prototypes> - <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="ozg-kT-Ijz"> - <rect key="frame" x="0.0" y="22" width="703" height="44"/> + <tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" id="dad-rm-zwY"> + <rect key="frame" x="0.0" y="22" width="768" height="44"/> <autoresizingMask key="autoresizingMask"/> <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> - <rect key="frame" x="0.0" y="0.0" width="703" height="43"/> + <rect key="frame" x="0.0" y="0.0" width="768" height="43"/> <autoresizingMask key="autoresizingMask"/> <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/> </view> </tableViewCell> </prototypes> - <connections> - <outlet property="dataSource" destination="E9F-81-Qlc" id="2Za-8v-z7o"/> - <outlet property="delegate" destination="E9F-81-Qlc" id="88m-bV-0PG"/> - </connections> </tableView> - <navigationItem key="navigationItem" title="Load a new model" id="Z27-wO-c1E"/> + <navigationItem key="navigationItem" title="Models list" id="sdX-f6-lSz"/> + <connections> + <segue destination="5" kind="push" id="bSD-X0-f0E"/> + </connections> </tableViewController> - <placeholder placeholderIdentifier="IBFirstResponder" id="JFe-Hg-fSu" userLabel="First Responder" sceneMemberID="firstResponder"/> + <placeholder placeholderIdentifier="IBFirstResponder" id="zLU-RU-aDe" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="1953" y="330"/> + <point key="canvasLocation" x="-1912" y="-934"/> </scene> - <!--Split View Controller--> - <scene sceneID="18"> + <!--Navigation Controller--> + <scene sceneID="Rhc-IE-crY"> <objects> - <splitViewController id="5" sceneMemberID="viewController"> - <toolbarItems/> - <navigationItem key="navigationItem" id="Pnc-za-KDo"/> - <simulatedStatusBarMetrics key="simulatedStatusBarMetrics" statusBarStyle="blackTranslucent"/> - <simulatedOrientationMetrics key="simulatedOrientationMetrics" orientation="landscapeRight"/> + <navigationController definesPresentationContext="YES" id="dwa-Pq-2vA" sceneMemberID="viewController"> + <navigationBar key="navigationBar" contentMode="scaleToFill" id="3bj-vr-d0C"> + <autoresizingMask key="autoresizingMask"/> + </navigationBar> <connections> - <segue destination="3" kind="relationship" relationship="masterViewController" id="9"/> - <segue destination="42" kind="relationship" relationship="detailViewController" id="51"/> + <segue destination="dVI-Oo-Sq4" kind="relationship" relationship="rootViewController" id="4oJ-sM-Hd3"/> </connections> - </splitViewController> - <placeholder placeholderIdentifier="IBFirstResponder" id="17" sceneMemberID="firstResponder"/> + </navigationController> + <placeholder placeholderIdentifier="IBFirstResponder" id="4VW-NK-Xj1" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="-879" y="-806"/> + <point key="canvasLocation" x="-2892" y="-934"/> </scene> <!--Master View Controller - Master--> <scene sceneID="24"> @@ -159,7 +171,7 @@ </navigationController> <placeholder placeholderIdentifier="IBFirstResponder" id="49" userLabel="First Responder" sceneMemberID="firstResponder"/> </objects> - <point key="canvasLocation" x="342" y="338"/> + <point key="canvasLocation" x="336" y="340"/> </scene> </scenes> <classes> @@ -167,7 +179,6 @@ <source key="sourceIdentifier" type="project" relativePath="./Classes/DetailViewController.h"/> <relationships> <relationship kind="action" name="PViewIntervalType:"/> - <relationship kind="action" name="PViewVisible:"/> <relationship kind="action" name="pinch:" candidateClass="UIPinchGestureRecognizer"/> <relationship kind="action" name="tap:" candidateClass="UITapGestureRecognizer"/> <relationship kind="outlet" name="detailDescriptionLabel" candidateClass="UILabel"/> @@ -182,6 +193,9 @@ <class className="ModelListController" superclassName="UITableViewController"> <source key="sourceIdentifier" type="project" relativePath="./Classes/ModelListController.h"/> </class> + <class className="SplitViewController" superclassName="UISplitViewController"> + <source key="sourceIdentifier" type="project" relativePath="./Classes/SplitViewController.h"/> + </class> </classes> <simulatedMetricsContainer key="defaultSimulatedMetrics"> <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/> diff --git a/contrib/mobile/iOS/Onelab/main.m b/contrib/mobile/iOS/Onelab/main.mm similarity index 100% rename from contrib/mobile/iOS/Onelab/main.m rename to contrib/mobile/iOS/Onelab/main.mm