From f0d294883f4b2c50fcaa6dc89f7c81976c75b503 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 25 Jun 2014 08:06:22 +0000 Subject: [PATCH] remove extra refresh + pp --- contrib/mobile/iOS/Onelab/EAGLView.mm | 2 + contrib/mobile/iOS/Onelab/Model.mm | 8 ++++ .../mobile/iOS/Onelab/ModelListController.mm | 7 +++ .../mobile/iOS/Onelab/ModelViewController.mm | 13 +++++ contrib/mobile/iOS/Onelab/Parameter.mm | 47 +++++++++++++++++++ .../iOS/Onelab/ParametersViewController.mm | 15 +++++- .../Onelab/PostProcessingViewController.mm | 12 ++++- 7 files changed, 102 insertions(+), 2 deletions(-) diff --git a/contrib/mobile/iOS/Onelab/EAGLView.mm b/contrib/mobile/iOS/Onelab/EAGLView.mm index 3314df0db6..ac831bfc3d 100644 --- a/contrib/mobile/iOS/Onelab/EAGLView.mm +++ b/contrib/mobile/iOS/Onelab/EAGLView.mm @@ -78,12 +78,14 @@ [context presentRenderbuffer:GL_RENDERBUFFER_OES]; rendering = NO; } + - (void)load:(NSString*) file { mContext->load(*new std::string([file fileSystemRepresentation])); [[NSNotificationCenter defaultCenter] postNotificationName:@"resetParameters" object:nil]; [self drawView]; } + - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { NSUInteger ntouch = [[event allTouches] count]; diff --git a/contrib/mobile/iOS/Onelab/Model.mm b/contrib/mobile/iOS/Onelab/Model.mm index d57160a242..c34b3a8c4f 100644 --- a/contrib/mobile/iOS/Onelab/Model.mm +++ b/contrib/mobile/iOS/Onelab/Model.mm @@ -32,34 +32,42 @@ { return _name; } + -(NSString *) getSummary { return _summary; } + -(NSString *) getFile { return _file; } + -(NSURL *) getUrl { return _url; } + -(UIImage *) getPreview { return _preview; } + -(void) setSummary:(NSString *)summary { _summary = summary; } + -(void) setFile:(NSString *)file { _file = file; } + -(void) setPreview:(NSString *)path { _preview = [UIImage imageWithContentsOfFile:path]; } + -(void) setUrl:(NSString *)url { _url = [NSURL URLWithString:url]; diff --git a/contrib/mobile/iOS/Onelab/ModelListController.mm b/contrib/mobile/iOS/Onelab/ModelListController.mm index 571f82ee54..186217b124 100644 --- a/contrib/mobile/iOS/Onelab/ModelListController.mm +++ b/contrib/mobile/iOS/Onelab/ModelListController.mm @@ -93,10 +93,12 @@ cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; return cell; } + -(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { return @"Select a model"; } + -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; @@ -114,6 +116,7 @@ [self performSegueWithIdentifier:@"showModelSegue" sender:self]; } } + -(void)handleLongPress:(UILongPressGestureRecognizer *)sender { CGPoint p = [sender locationInView:self.tableView]; @@ -128,6 +131,7 @@ actionSheet.tag = indexPath.row; [actionSheet showInView:self.view]; } + -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { switch (buttonIndex) { @@ -153,12 +157,14 @@ return [parser parse]; } + -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { currentElement = elementName; //[currentElementValue release]; currentElementValue = nil; } + -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if (!currentElementValue) @@ -166,6 +172,7 @@ else [currentElementValue appendString:string]; } + -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if([elementName isEqual:@"title"]) { diff --git a/contrib/mobile/iOS/Onelab/ModelViewController.mm b/contrib/mobile/iOS/Onelab/ModelViewController.mm index 982406ed8d..7afc0bb58f 100644 --- a/contrib/mobile/iOS/Onelab/ModelViewController.mm +++ b/contrib/mobile/iOS/Onelab/ModelViewController.mm @@ -178,6 +178,7 @@ [self performSelectorOnMainThread:@selector(stopGUI) withObject:nil waitUntilDone:YES]; }); } + -(void)stopGUI { [_runStopButton setAction:@selector(compute)]; @@ -190,16 +191,19 @@ [_errorAlert show]; } } + - (void)stop { onelab_cb("stop"); } + -(void)playAnimation:(UIBarButtonItem *)sender { [_playButton setEnabled:NO]; [_stopButton setEnabled:YES]; _animation = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(nextAnimation) userInfo:nil repeats:YES]; } + -(void)stopAnimation:(UIBarButtonItem *)sender { [_animation invalidate]; @@ -207,8 +211,11 @@ [_playButton setEnabled:YES]; [_stopButton setEnabled:NO]; } + -(void)nextAnimation { animation_next(); [self requestRender]; } + -(void)prevAnimation { animation_prev(); [self requestRender]; } + -(IBAction)pinch:(UIPinchGestureRecognizer *)sender { if([sender numberOfTouches] <= 2) { @@ -354,18 +361,22 @@ void messageFromCpp (void *self, std::string level, std::string msg) else if(level == "Error") [(__bridge id)self addError:msg]; } + -(void)setProgress:(NSString *)progress { [_progressLabel setText:progress]; } + -(void)handleProgressIndicatorTap:(id)sender { [_progressLabel setHidden:!_progressLabel.hidden]; } + void getBitmap(void *self, const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth) { [(__bridge id)self getBitmapFromStringObjC:text withTextSize:textsize inMap:map inHeight:height inWidth:width inRealWidth:realWidth]; } + -(void) getBitmapFromStringObjC:(const char *)text withTextSize:(int)textsize inMap:(unsigned char **)map inHeight:(int *)height inWidth:(int *)width inRealWidth:(int *) realWidth { UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 1024, textsize)]; @@ -406,6 +417,7 @@ void getBitmap(void *self, const char *text, int textsize, unsigned char **map, *(*map+byteIndex/4) = rawData[byteIndex + 3]; free(rawData); } + - (IBAction)startRotation:(UIButton *)sender { glView->rotate = !glView->rotate; if(glView->rotate) @@ -413,4 +425,5 @@ void getBitmap(void *self, const char *text, int textsize, unsigned char **map, else [sender setImage:[UIImage imageNamed:@"icon_rotate.png"] forState:UIControlStateNormal]; } + @end diff --git a/contrib/mobile/iOS/Onelab/Parameter.mm b/contrib/mobile/iOS/Onelab/Parameter.mm index e42e1eb859..b4874169fb 100644 --- a/contrib/mobile/iOS/Onelab/Parameter.mm +++ b/contrib/mobile/iOS/Onelab/Parameter.mm @@ -10,26 +10,32 @@ } return self; } + -(void)refresh { return; } + -(NSString *)getName { return name; } + -(UILabel *)getLabel { return label; } + -(void)setFrame:(CGRect)frame { return; } + -(void)setLabelFrame:(CGRect)frame { [label setFrame:frame]; } + -(void)editValue { if(onelab_cb("check") == 1){ @@ -37,7 +43,9 @@ [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; } } + -(bool) isReadOnly {return NO;} + +(double)getHeight { return 60.0f; @@ -58,6 +66,7 @@ } return self; } + -(void)selectValue { std::vector<onelab::string> string; @@ -71,6 +80,7 @@ [popupSelectValue setCancelButtonIndex:popupSelectValue.numberOfButtons - 1]; [popupSelectValue showInView:button]; } + -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { std::vector<onelab::string> string; @@ -82,20 +92,24 @@ onelab::server::instance()->set(string[0]); [super editValue]; } + -(void)refresh { std::vector<onelab::string> string; onelab::server::instance()->get(string,[name UTF8String]); [button setTitle:[NSString stringWithFormat:@"%s", string[0].getValue().c_str()] forState:UIControlStateNormal]; } + -(void)setFrame:(CGRect)frame { [button setFrame:frame]; } + -(UIButton *)getUIView { return button; } + -(bool)isReadOnly { std::vector<onelab::string> string; @@ -103,6 +117,7 @@ if(string.size() < 1) return YES; return string[0].getReadOnly(); } + +(double)getHeight { return 60.f; @@ -123,6 +138,7 @@ } return self; } + -(void)selectValue { std::vector<onelab::number> number; @@ -136,6 +152,7 @@ [popupSelectValue setCancelButtonIndex:popupSelectValue.numberOfButtons - 1]; [popupSelectValue showInView:button]; } + -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { std::vector<onelab::number> number; @@ -148,20 +165,24 @@ [button setTitle:[NSString stringWithFormat:@"%s", number[0].getValueLabel(number[0].getValue()).c_str()] forState:UIControlStateNormal]; [super editValue]; } + -(void)refresh { std::vector<onelab::number> number; onelab::server::instance()->get(number,[name UTF8String]); [button setTitle:[NSString stringWithFormat:@"%s", number[0].getValueLabel(number[0].getValue()).c_str()] forState:UIControlStateNormal]; } + -(void)setFrame:(CGRect)frame { [button setFrame:frame]; } + -(UIButton *)getUIView { return button; } + -(bool)isReadOnly { std::vector<onelab::number> number; @@ -169,6 +190,7 @@ if(number.size() < 1) return YES; return number[0].getReadOnly(); } + +(double)getHeight { return 60.f; @@ -189,12 +211,14 @@ } return self; } + -(void)refresh { std::vector<onelab::number> number; onelab::server::instance()->get(number,[name UTF8String]); [checkbox setSelected:(number[0].getValue() == 1)]; } + -(void) valueChange:(UISwitch *)sender { std::vector<onelab::number> number; @@ -204,14 +228,17 @@ onelab::server::instance()->set(number[0]); [super editValue]; } + -(void)setFrame:(CGRect)frame { [checkbox setFrame:frame]; } + -(UISwitch *)getCheckbox { return checkbox; } + -(bool)isReadOnly { std::vector<onelab::number> number; @@ -219,6 +246,7 @@ if(number.size() < 1) return YES; return number[0].getReadOnly(); } + +(double)getHeight { return 40.0f; @@ -242,6 +270,7 @@ } return self; } + -(void)stepperValueChanged:(UIStepper *)sender { std::vector<onelab::number> number; @@ -252,6 +281,7 @@ [label setText:[NSString stringWithFormat:@"%s %d" ,number[0].getShortName().c_str(), (int)number[0].getValue()]]; [super editValue]; } + -(void)refresh { std::vector<onelab::number> number; @@ -260,14 +290,17 @@ [stepper setValue:number[0].getValue()]; [label setText:[NSString stringWithFormat:@"%s %d" ,number[0].getShortName().c_str(), (int)number[0].getValue()]]; } + -(void)setFrame:(CGRect)frame { [stepper setFrame:frame]; } + -(UIStepper *)getStepper { return stepper; } + +(double)getHeight { return 60.0f; @@ -292,6 +325,7 @@ } return self; } + -(void)refresh { std::vector<onelab::number> number; @@ -302,6 +336,7 @@ [slider setValue:number[0].getValue()]; [label setText:[NSString stringWithFormat:@"%@ %g", [NSString stringWithCString:number[0].getShortName().c_str() encoding:[NSString defaultCStringEncoding]], number[0].getValue()]]; } + -(void)sliderValueChanged:(UISlider *)sender { std::vector<onelab::number> number; @@ -312,14 +347,17 @@ [label setText:[NSString stringWithFormat:@"%s %g" ,number[0].getShortName().c_str(), number[0].getValue()]]; [super editValue]; } + -(void)setFrame:(CGRect)frame { [slider setFrame:frame]; } + -(UISlider *)getSlider { return slider; } + -(bool)isReadOnly { std::vector<onelab::number> number; @@ -327,6 +365,7 @@ if(number.size() < 1) return YES; return number[0].getReadOnly(); } + +(double)getHeight { return 60.0f; @@ -355,6 +394,7 @@ } return self; } + -(void)refresh { std::vector<onelab::number> number; @@ -363,6 +403,7 @@ [textbox setText:[NSString stringWithFormat:@"%g", number[0].getValue()]]; [textbox reloadInputViews]; } + -(BOOL)textFieldShouldEndEditing:(UITextField *)textField { std::vector<onelab::number> number; @@ -374,22 +415,27 @@ [super editValue]; return YES; } + -(BOOL)textFieldShouldReturn:(UITextField *)textField { return [textField endEditing:YES]; } + -(void)doneWithNumberPad { [textbox endEditing:YES]; } + -(void)setFrame:(CGRect)frame { [textbox setFrame:frame]; } + -(UITextField *)getTextbox { return textbox; } + -(bool)isReadOnly { std::vector<onelab::number> number; @@ -397,6 +443,7 @@ if(number.size() < 1) return YES; return number[0].getReadOnly(); } + +(double)getHeight { return 60.f; diff --git a/contrib/mobile/iOS/Onelab/ParametersViewController.mm b/contrib/mobile/iOS/Onelab/ParametersViewController.mm index 5c603fa8a9..ea269e958f 100644 --- a/contrib/mobile/iOS/Onelab/ParametersViewController.mm +++ b/contrib/mobile/iOS/Onelab/ParametersViewController.mm @@ -46,6 +46,7 @@ } self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Reset" style:UIBarButtonItemStyleBordered target:self action:@selector(resetParameters:)]; } + - (void)viewWillAppear:(BOOL)animated { [self refreshParameters:nil]; @@ -77,9 +78,9 @@ alertView.alertViewStyle = UIAlertViewStylePlainTextInput; [alertView textFieldAtIndex:0].text = [NSString stringWithFormat:@"%g", number[0].getValue()]; [alertView show]; - [parameter refresh]; } } + -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"%@ -> %@", [alertView message], [alertView textFieldAtIndex:0].text); @@ -95,11 +96,13 @@ } } } + - (void)indexDidChangeForSegmentedControl:(id)sender { OptionsViewController *optionsViewController = [[OptionsViewController alloc] init]; [self.navigationController pushViewController:optionsViewController animated:YES]; } + - (void)addParameterNumber:(onelab::number)p atIndexPath:(NSIndexPath*)indexPath { NSMutableArray* section = [_sections objectAtIndex:indexPath.section]; @@ -130,6 +133,7 @@ [self.tableView insertRowsAtIndexPaths:[[NSArray alloc] initWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic]; [self.tableView endUpdates]; } + - (void)addParameterString:(onelab::string)p atIndexPath:(NSIndexPath*)indexPath { NSMutableArray* section = [_sections objectAtIndex:indexPath.section]; @@ -139,12 +143,14 @@ [self.tableView insertRowsAtIndexPaths:[[NSArray alloc] initWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic]; [self.tableView endUpdates]; } + - (void)removeParemeterNumberAtIndex:(NSIndexPath*)index { [self.tableView beginUpdates]; [self.tableView deleteRowsAtIndexPaths: [NSArray arrayWithObject:index] withRowAnimation:UITableViewRowAnimationAutomatic]; [self.tableView endUpdates]; } + - (void)addSection:(NSMutableArray*)s withTitle:(NSString*)t withParameterNumber:(onelab::number)p { [_sections addObject:s]; @@ -154,6 +160,7 @@ [self.tableView endUpdates]; [self addParameterNumber:p atIndexPath:[NSIndexPath indexPathForRow:0 inSection:[_sections count]-1]]; } + - (void)addSection:(NSMutableArray*)s withTitle:(NSString*)t withParameterString:(onelab::string)p { [_sections addObject:s]; @@ -163,6 +170,7 @@ [self.tableView endUpdates]; [self addParameterString:p atIndexPath:[NSIndexPath indexPathForRow:0 inSection:[_sections count]-1]]; } + - (void)refreshTableView { std::vector<onelab::number> number; @@ -258,10 +266,12 @@ { return YES; } + - (void)refreshParameters:(id)sender { [self performSelectorOnMainThread:@selector(refreshParameters) withObject:nil waitUntilDone:NO]; } + - (void)refreshParameters { if(!_lastRefresh) _lastRefresh = [NSDate date]; @@ -271,6 +281,7 @@ } [self refreshTableView]; // Get the param } + - (void)resetParameters:(id)sender { if(((AppDelegate *)[UIApplication sharedApplication].delegate)->compute) { @@ -300,6 +311,7 @@ // Return NO if you do not want the specified item to be editable. return YES; } + -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if([_sections count] < section) @@ -373,4 +385,5 @@ { return [_sectionstitle objectAtIndex:section]; } + @end diff --git a/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm b/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm index b463f2dcdf..543a016c14 100644 --- a/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm +++ b/contrib/mobile/iOS/Onelab/PostProcessingViewController.mm @@ -46,10 +46,12 @@ [_IntervalsStepper setMinimumValue:1]; } } + -(void)viewDidAppear:(BOOL)animated { [_IntervalsType selectRow:_pview->getOptions()->intervalsType-1 inComponent:0 animated:YES]; } + - (IBAction)stepperValueChanged:(UIStepper *)sender { [_Intervals setText:[NSString stringWithFormat:@"%.0f", [sender value]]]; @@ -57,31 +59,37 @@ _pview->setChanged(true); [[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil]; } + -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1; } + -(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return 3; } + -(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { NSArray *name = [[NSArray alloc] initWithObjects:@"Iso-values", @"Continuous map", @"Filled iso-values", nil]; return [name objectAtIndex:row]; } + -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { _pview->getOptions()->intervalsType = 1+row; _pview->setChanged(true); [[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil]; } + - (void)slideRaiseZ:(UISlider*)sender { _pview->getOptions()->raise[2] = sender.value; _pview->setChanged(true); [[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil]; } + - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; @@ -96,16 +104,18 @@ [[NSNotificationCenter defaultCenter] postNotificationName:@"requestRender" object:nil]; return YES; } + -(BOOL)textFieldShouldReturn:(UITextField *)textField { return [_Intervals endEditing:YES]; } + -(void)doneWithNumberPad { [_Intervals endEditing:YES]; } -- (void)viewDidUnload +-(void)viewDidUnload { [self setName:nil]; [self setRaiseZ:nil]; -- GitLab