diff --git a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj index 42d093315baf27a182d334e645ea02fae8a61e82..72fce9261ae9bbeb2569fe4f877e7a8d370518fc 100644 --- a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj +++ b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 9CC6EBB717BA0A38001CA21A /* drawGeom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CC6EBB617BA0A38001CA21A /* drawGeom.cpp */; }; 9CC6EBB917BA1CC7001CA21A /* drawMesh.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CC6EBB817BA1CC7001CA21A /* drawMesh.cpp */; }; 9CC85C021790286C00F241C4 /* files in Resources */ = {isa = PBXBuildFile; fileRef = 9CC85C011790286C00F241C4 /* files */; }; + 9CDCED2317D5C00500B39082 /* Model.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CDCED2217D5C00500B39082 /* Model.mm */; }; 9CE08E10178AEB1600A83B4B /* GetDP.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0D178AEB1600A83B4B /* GetDP.framework */; }; 9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0E178AEB1600A83B4B /* Gmsh.framework */; }; 9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE08E0F178AEB1600A83B4B /* petsc.framework */; }; @@ -35,6 +36,7 @@ 9CE18C2017B27EDB009BA06E /* Parameter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CE18C1F17B27EDB009BA06E /* Parameter.mm */; }; 9CE1A65717B0F39D00E5152F /* Utils.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CE1A65617B0F39D00E5152F /* Utils.mm */; }; 9CE1A65A17B0FB9700E5152F /* iPhoneiPodStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9CE1A65817B0FB9600E5152F /* iPhoneiPodStoryboard.storyboard */; }; + 9CE2773B17E197F50076E728 /* Social.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CE2773917E197DA0076E728 /* Social.framework */; }; 9CEAE86E17AF824B00813524 /* iosGModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAE86D17AF824B00813524 /* iosGModel.cpp */; }; 9CEAE87D17AFD5BB00813524 /* SplitViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAE87C17AFD5BB00813524 /* SplitViewController.mm */; }; 9CEAECC717A91CD20014D229 /* ModelListController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAECC617A91CD20014D229 /* ModelListController.mm */; }; @@ -71,6 +73,8 @@ 9CC6EBB617BA0A38001CA21A /* drawGeom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drawGeom.cpp; sourceTree = "<group>"; usesTabs = 1; }; 9CC6EBB817BA1CC7001CA21A /* drawMesh.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drawMesh.cpp; sourceTree = "<group>"; }; 9CC85C011790286C00F241C4 /* files */ = {isa = PBXFileReference; lastKnownFileType = folder; path = files; sourceTree = "<group>"; }; + 9CDCED2117D5C00500B39082 /* Model.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Model.h; sourceTree = "<group>"; }; + 9CDCED2217D5C00500B39082 /* Model.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Model.mm; sourceTree = "<group>"; }; 9CE08E01178AE6BE00A83B4B /* drawContext.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = drawContext.cpp; sourceTree = "<group>"; usesTabs = 1; }; 9CE08E02178AE6BE00A83B4B /* drawContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = drawContext.h; sourceTree = "<group>"; usesTabs = 1; }; 9CE08E03178AE6BE00A83B4B /* movePosition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = movePosition.h; sourceTree = "<group>"; usesTabs = 1; }; @@ -84,6 +88,7 @@ 9CE1A65517B0F39C00E5152F /* Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utils.h; sourceTree = "<group>"; usesTabs = 1; }; 9CE1A65617B0F39D00E5152F /* Utils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Utils.mm; sourceTree = "<group>"; usesTabs = 1; }; 9CE1A65917B0FB9700E5152F /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/iPhoneiPodStoryboard.storyboard; sourceTree = "<group>"; }; + 9CE2773917E197DA0076E728 /* Social.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Social.framework; path = System/Library/Frameworks/Social.framework; sourceTree = SDKROOT; }; 9CEAE86D17AF824B00813524 /* iosGModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = iosGModel.cpp; sourceTree = "<group>"; usesTabs = 1; }; 9CEAE87B17AFD5BB00813524 /* SplitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SplitViewController.h; sourceTree = "<group>"; usesTabs = 1; }; 9CEAE87C17AFD5BB00813524 /* SplitViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SplitViewController.mm; sourceTree = "<group>"; usesTabs = 1; }; @@ -106,6 +111,7 @@ 9C96083B1712C16300E1D4A0 /* UIKit.framework in Frameworks */, 9C96083D1712C16300E1D4A0 /* Foundation.framework in Frameworks */, 9C96083F1712C16300E1D4A0 /* CoreGraphics.framework in Frameworks */, + 9CE2773B17E197F50076E728 /* Social.framework in Frameworks */, 9CE08E10178AEB1600A83B4B /* GetDP.framework in Frameworks */, 9CE08E11178AEB1600A83B4B /* Gmsh.framework in Frameworks */, 9CE08E12178AEB1600A83B4B /* petsc.framework in Frameworks */, @@ -137,6 +143,7 @@ 9C9608391712C16300E1D4A0 /* Frameworks */ = { isa = PBXGroup; children = ( + 9CE2773917E197DA0076E728 /* Social.framework */, 9CE08E0D178AEB1600A83B4B /* GetDP.framework */, 9CE08E0E178AEB1600A83B4B /* Gmsh.framework */, 9CE08E0F178AEB1600A83B4B /* petsc.framework */, @@ -172,6 +179,8 @@ 9CE08E04178AE6BE00A83B4B /* Trackball.cpp */, 9CE1A65517B0F39C00E5152F /* Utils.h */, 9CE1A65617B0F39D00E5152F /* Utils.mm */, + 9CDCED2117D5C00500B39082 /* Model.h */, + 9CDCED2217D5C00500B39082 /* Model.mm */, 9CE18C1E17B27EDB009BA06E /* Parameter.h */, 9CE18C1F17B27EDB009BA06E /* Parameter.mm */, 9CEAECC517A91CD20014D229 /* ModelListController.h */, @@ -288,6 +297,7 @@ 9CC6EBB917BA1CC7001CA21A /* drawMesh.cpp in Sources */, 9C1C10FA17BA5E7D00BFD483 /* OptionsViewController.mm in Sources */, 9CF34DE417C62FC500A3D5E3 /* PostProcessingViewController.mm in Sources */, + 9CDCED2317D5C00500B39082 /* Model.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -380,6 +390,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/Onelab/frameworks\"", @@ -401,6 +413,8 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_OBJC_ARC = YES; + CODE_SIGN_IDENTITY = ""; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SRCROOT)/../../getdp-iOS\"", diff --git a/contrib/mobile/iOS/Onelab/EAGLView.h b/contrib/mobile/iOS/Onelab/EAGLView.h index 8d91d25cd5f8b925e6ac7d2cbb3f1e7229b8ef68..caa7c1eb1d3b7b097c6e8040f41c7528017fcd25 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.h +++ b/contrib/mobile/iOS/Onelab/EAGLView.h @@ -35,4 +35,6 @@ - (void)load:(NSString*) file; +- (UIImage*) getGLScreenshot; + @end diff --git a/contrib/mobile/iOS/Onelab/EAGLView.mm b/contrib/mobile/iOS/Onelab/EAGLView.mm index 7555624d5321238733b64fbb95a4798d80552c33..8e8086879a5ae5bad0bf73060fdb9c47ad2f3252 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.mm +++ b/contrib/mobile/iOS/Onelab/EAGLView.mm @@ -148,4 +148,38 @@ } } +- (UIImage*) getGLScreenshot +{ + NSInteger myDataLength = backingWidth * backingHeight * 4; + + GLubyte *buffer = (GLubyte *) malloc(myDataLength); + glReadPixels(0, 0, backingWidth, backingHeight, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + GLubyte *buffer2 = (GLubyte *) malloc(myDataLength); + for(int y = 0; y <backingHeight; y++) + { + for(int x = 0; x <backingWidth * 4; x++) + { + buffer2[(backingHeight - 1 - y) * backingWidth * 4 + x] = buffer[y * 4 * backingWidth + x]; + } + } + + CGDataProviderRef provider = CGDataProviderCreateWithData(NULL, buffer2, myDataLength, NULL); + + int bitsPerComponent = 8; + int bitsPerPixel = 32; + int bytesPerRow = 4 * backingWidth; + CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); + CGBitmapInfo bitmapInfo = kCGBitmapByteOrderDefault; + CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; + + CGImageRef imageRef = CGImageCreate(backingWidth, backingHeight, bitsPerComponent, bitsPerPixel, bytesPerRow, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); + + return [UIImage imageWithCGImage:imageRef]; +} + +- (void)saveGLScreenshotToPhotosAlbum { + UIImageWriteToSavedPhotosAlbum([self getGLScreenshot], nil, nil, nil); +} + @end diff --git a/contrib/mobile/iOS/Onelab/ModelListController.mm b/contrib/mobile/iOS/Onelab/ModelListController.mm index d34a4bf2393b304eac81a4a2152481fe264b661b..b83b2a42ac819884e5036a2deb415c180b44af26 100644 --- a/contrib/mobile/iOS/Onelab/ModelListController.mm +++ b/contrib/mobile/iOS/Onelab/ModelListController.mm @@ -15,6 +15,10 @@ @implementation ModelListController -(void)viewDidLoad { + UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; + [refreshControl addTarget:self action:@selector(refreshList) forControlEvents:UIControlEventValueChanged]; + self.refreshControl = refreshControl; + UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; lpgr.minimumPressDuration = 1.0; [self.tableView addGestureRecognizer:lpgr]; @@ -23,7 +27,7 @@ NSString *docsPath = [Utils getApplicationDocumentsDirectory]; [Utils copyRes]; NSArray *docs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docsPath error:NULL]; - for(NSString* doc in docs){ + for(NSString* doc in docs) { NSString *docPath = [NSString stringWithFormat:@"%@/%@/", docsPath, doc]; BOOL isDir = NO; [[NSFileManager defaultManager] fileExistsAtPath:docPath isDirectory:&isDir]; if(isDir){ @@ -36,6 +40,20 @@ } } +-(void)refreshList +{ + /*NSArray *docs = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:docsPath error:NULL]; + for(NSString* doc in docs) { + NSString *docPath = [NSString stringWithFormat:@"%@/%@/", docsPath, doc]; + BOOL isDir = NO; [[NSFileManager defaultManager] fileExistsAtPath:docPath isDirectory:&isDir]; + if(isDir){ + + } + }*/ + [self.tableView reloadData]; + [self.refreshControl endRefreshing]; +} + - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; diff --git a/contrib/mobile/iOS/Onelab/ModelViewController.mm b/contrib/mobile/iOS/Onelab/ModelViewController.mm index 95d0679d16f24100a4493b926db16ac7e4667ca3..c3cd92fa04a4b7ebd6c1885cbd5820a6fb289a73 100644 --- a/contrib/mobile/iOS/Onelab/ModelViewController.mm +++ b/contrib/mobile/iOS/Onelab/ModelViewController.mm @@ -6,9 +6,11 @@ // Copyright (c) 2013 Maxime Graulich. All rights reserved. // #import <QuartzCore/QuartzCore.h> +#import <Social/Social.h> #import "ModelViewController.h" #import "iosGModel.h" +#import "Utils.h" #import "AppDelegate.h" @@ -93,14 +95,15 @@ setObjCBridge((__bridge void*) self); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestRender) name:@"requestRender" object:nil]; _runStopButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(compute)]; + UIBarButtonItem *share = [[UIBarButtonItem alloc] initWithTitle:@"Share" style:UIBarButtonItemStyleBordered target:self action:@selector(share)]; if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Model list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; - [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_runStopButton, model, nil]]; + [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_runStopButton, model, share, nil]]; } else { UIBarButtonItem *settings = [[UIBarButtonItem alloc] initWithTitle:@"Parameters" style:UIBarButtonItemStyleBordered target:self action:@selector(showSettings)]; - [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_runStopButton, settings, nil]]; + [self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:_runStopButton, settings, share, nil]]; } } @@ -110,6 +113,13 @@ _progressIndicator.frame = CGRectMake(20, self.view.frame.size.height - 25, _progressIndicator.frame.size.width, _progressIndicator.frame.size.height); } +-(void)share +{ + NSArray *dataToShare = @[[self.glView getGLScreenshot]]; + UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil]; + [self presentViewController:activityVC animated:YES completion:nil]; +} + - (void)compute { [_runStopButton setAction:@selector(stop)]; diff --git a/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm b/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm index e43b32537fc151305bfdcc2b1cdc0ee8e517bfcb..f274e8b28ec4c987c07980b657a4ddbf526f4cc9 100644 --- a/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm +++ b/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm @@ -37,7 +37,6 @@ [_Name setText:[NSString stringWithCString:_pview->getData()->getName().c_str() encoding:[NSString defaultCStringEncoding]]]; [_IntervalsType setDataSource:self]; [_IntervalsType setDelegate:self]; - [_IntervalsType selectRow:_pview->getOptions()->intervalsType-1 inComponent:0 animated:YES]; [_Intervals setText:[NSString stringWithFormat:@"%d",_pview->getOptions()->nbIso]]; UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)]; numberToolbar.barStyle = UIBarStyleBlackTranslucent; @@ -50,8 +49,13 @@ _Intervals.inputAccessoryView = numberToolbar; [_RaiseZ setValue:_pview->getOptions()->raise[2]]; [_RaiseZ addTarget:self action:@selector(slideRaiseZ:) forControlEvents:UIControlEventValueChanged]; + [_IntervalsStepper setStepValue:1]; } } +-(void)viewDidAppear:(BOOL)animated +{ + [_IntervalsType selectRow:_pview->getOptions()->intervalsType-1 inComponent:0 animated:YES]; +} -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; @@ -108,6 +112,7 @@ [self setIntervals:nil]; [self setIntervalsType:nil]; [self setName:nil]; + [self setIntervalsStepper:nil]; [super viewDidUnload]; } @end