diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index 2e849444576c9e366f89f15cf540975ab3d8bbda..4748f935b5fc31052ec42ca545e668d79c4ed82e 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -62,8 +62,6 @@ drawContext::drawContext() setQuaternion(0., 0., 0., 1.); _fillMesh = false; - _showMesh = false; - _showGeom = true; _gradiant = true; } @@ -113,7 +111,7 @@ void drawContext::eventHandler(int event, float x, float y) case 2: // fingers move (scale) // in this case we don't care about previous and current position, x represent the scale this->_scale[0] = this->_scale[1] = this->_scale[2] = x; - this->_start.recenter(this->_scale, this->_translate); // FIXME somethink change the value of win + this->_start.recenter(this->_scale, this->_translate); break; case 3: // fingers move (rotate) this->addQuaternion((2. * this->_previous.win[0] - this->_width) / this->_width, @@ -170,6 +168,7 @@ void drawContext::buildRotationMatrix() void drawContext::OrthofFromGModel() { + if(locked) return; SBoundingBox3d bb = GModel::current()->bounds(); double ratio = (double)(this->_width ? this->_width : 1.) / (double)(this->_height ? this->_height : 1.); double xmin = -ratio, xmax = ratio, ymin = -1., ymax = 1.; @@ -611,13 +610,17 @@ void drawContext::drawView() this->drawAxes(this->_right - (this->_top - this->_bottom)/15.0, this->_bottom + (this->_top - this->_bottom)/15.0, 0, (this->_top - this->_bottom)/20.); - checkGlError("Draw axes"); + checkGlError("Draw axes"); this->drawPost(); - checkGlError("Draw post-pro"); - if(_showGeom) this->drawGeom(); - checkGlError("Draw geometry"); - if(_showMesh) this->drawMesh(); - checkGlError("Draw mesh"); + checkGlError("Draw post-pro"); + if(CTX::instance()->geom.draw){ + this->drawGeom(); + checkGlError("Draw geometry"); + } + if(CTX::instance()->mesh.draw){ + this->drawMesh(); + checkGlError("Draw mesh"); + } this->drawScale(); checkGlError("Draw scales"); } diff --git a/contrib/mobile/drawContext.h b/contrib/mobile/drawContext.h index 4a00d9bf933709a9504935b524f8157852b3aea1..11a1570820d660b35b2fe622cc4f001ca6b15dbf 100644 --- a/contrib/mobile/drawContext.h +++ b/contrib/mobile/drawContext.h @@ -1,6 +1,10 @@ #ifndef _DRAW_GMODEL_H_ #define _DRAW_GMODEL_H_ +#ifndef __cplusplus +#error You need a Cpp compiler! +#endif + #if !defined(BUILD_ANDROID) #define BUILD_IOS 1 #endif @@ -27,8 +31,6 @@ private: int _width, _height; // size of OpenGL context in pixel float _left, _right, _top, _bottom; // value of "border" bool _gradiant, // show the background gradiant - _showGeom, // show the Geometry - _showMesh, // show the Mesh _fillMesh; // fill the Mesh void OrthofFromGModel(void); @@ -55,11 +57,11 @@ public: void drawPost(); void drawScale(); void useGradiant(bool gradiant=true) {_gradiant = gradiant;} - void showGeom(bool show=true) {_showGeom = show;} - void showMesh(bool show=true) {_showMesh = show;} + void showGeom(bool show=true) {CTX::instance()->geom.draw = show;} + void showMesh(bool show=true) {CTX::instance()->mesh.draw = show;} void fillMesh(bool show=true) {_fillMesh = show;} - bool isShowedMesh(){return _showMesh;} - bool isShowedGeom(){return _showGeom;} + bool isShowedMesh(){return CTX::instance()->mesh.draw;} + bool isShowedGeom(){return CTX::instance()->geom.draw;} }; #endif diff --git a/contrib/mobile/drawString.cpp b/contrib/mobile/drawString.cpp index 0531a22175db8a43539313aba658cabdac3d18f8..8d2b19e1a681c6f0c2e81ce3a4f28aafab9e9914 100644 --- a/contrib/mobile/drawString.cpp +++ b/contrib/mobile/drawString.cpp @@ -47,11 +47,9 @@ void drawString::setColor(float r, float g, float b, float a) } void drawString::draw(float x, float y, float z, float w, float h, bool center) { - // TODO fix on iOS GLuint textureId; glGenTextures(1, &textureId); glBindTexture(GL_TEXTURE_2D, textureId); - //printf("\n%s\n", _text.c_str());for(int i=0; i<_height*_width;i++) printf("0x%x ", _map[i]);printf("\n"); glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, _width, _height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, _map); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glColor4f(_color[0], _color[1], _color[2], _color[3]); diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.mm b/contrib/mobile/iOS/Onelab/DetailViewController.mm index 77364f12dce8050fae95de39823963c773827c66..98298e2617016d5a4006830e4fb4962bc273e1b2 100644 --- a/contrib/mobile/iOS/Onelab/DetailViewController.mm +++ b/contrib/mobile/iOS/Onelab/DetailViewController.mm @@ -65,14 +65,14 @@ [self.navigationItem setLeftBarButtonItem:model]; [self.navigationItem setRightBarButtonItems:btns]; } - else { - UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Models list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; - 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:)]; - NSArray *btns = [[NSArray alloc] initWithObjects:postpro, more, nil]; - [self.navigationItem setLeftBarButtonItem:model]; - [self.navigationItem setRightBarButtonItems:btns]; - } + 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:@"Models list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)]; + NSArray *btns = [[NSArray alloc] initWithObjects:model, postpro, more, nil]; + [self.navigationItem setRightBarButtonItems:btns]; + } } - (IBAction)pinch:(UIPinchGestureRecognizer *)sender @@ -281,12 +281,7 @@ - (void)splitViewController:(UISplitViewController *)splitController willHideViewController:(UIViewController *)viewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController:(UIPopoverController *)popoverController { barButtonItem.title = NSLocalizedString(@"Settings", @"Settings"); - 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:barButtonItem, postpro, more, nil]; - [self.navigationController.navigationItem setLeftBarButtonItems:btns]; - [self.navigationController.navigationItem setRightBarButtonItem:model]; + [self.navigationItem setLeftBarButtonItem:barButtonItem]; self.masterPopoverController = popoverController; } @@ -327,7 +322,6 @@ @"Set Y view", @"Set Z view", nil]; - //[popupMore showFromBarButtonItem:sender animated:true]; [popupMore showInView:self.view]; } @@ -361,7 +355,7 @@ void messageFromCpp (void *self, std::string level, std::string msg) [[NSNotificationCenter defaultCenter] postNotificationName:@"refreshParameters" object:nil]; } else if(level == "Error") - ;//[(__bridge id)self showAlert:msg title:level]; + [(__bridge id)self showAlert:msg title:level]; } void getBitmap(void *self, const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth) { diff --git a/contrib/mobile/iOS/Onelab/MasterViewController.mm b/contrib/mobile/iOS/Onelab/MasterViewController.mm index 0780bdb7653719b1c69229a242a2b8faad97c1f4..b2dbd46cde597dc2e2ea432f41784571776df724 100644 --- a/contrib/mobile/iOS/Onelab/MasterViewController.mm +++ b/contrib/mobile/iOS/Onelab/MasterViewController.mm @@ -188,13 +188,13 @@ AppDelegate *appDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate; appDelegate->compute = YES; [runButton setTitle:@"Stop"]; - [self.view setNeedsDisplay]; + [self.navigationController.view setNeedsDisplay]; [runButton setAction:@selector(stopRunning)]; self.navigationItem.rightBarButtonItem.enabled = NO; onelab_cb("compute"); if([[UIDevice currentDevice].model isEqualToString:@"iPad"] || [[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ [runButton setTitle:@"Run"]; - [self.view setNeedsDisplay]; + [self.navigationController.view setNeedsDisplay]; [runButton setAction:@selector(runWithNewParameter)]; self.navigationItem.rightBarButtonItem.enabled = YES; } @@ -207,10 +207,8 @@ - (void)stopRunning { onelab_cb("stop"); - if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]){ - ((AppDelegate *)[UIApplication sharedApplication].delegate)->compute = NO; + if(![[UIDevice currentDevice].model isEqualToString:@"iPad"] && ![[UIDevice currentDevice].model isEqualToString:@"iPad Simulator"]) [self.navigationController popViewControllerAnimated:YES]; - } } #pragma mark - Table View diff --git a/contrib/mobile/iOS/Onelab/SplitViewController.mm b/contrib/mobile/iOS/Onelab/SplitViewController.mm index aabcd3f33bf2b04ec30d3184a5d48217d0dcffdd..59ffd586a5186c72e8bf1fbca087563e42046252 100644 --- a/contrib/mobile/iOS/Onelab/SplitViewController.mm +++ b/contrib/mobile/iOS/Onelab/SplitViewController.mm @@ -13,19 +13,7 @@ @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]; @@ -39,6 +27,24 @@ { [super viewDidLoad]; // Do any additional setup after loading the view. + UINavigationController *right = [self.viewControllers objectAtIndex:1]; // right UINavigationController (Detail) + for(UIViewController *v in right.viewControllers){ + if ([v isKindOfClass:[DetailViewController class]]) { + detailViewController = (DetailViewController *)v; + } + } + /*UINavigationController *left = [self.viewControllers objectAtIndex:0]; // left UINavigationController (Master) + for(UIViewController *v in left.viewControllers){ + if ([v isKindOfClass:[MasterViewController class]]) { + masterViewController = (MasterViewController *)v; + } + }*/ + self.delegate = detailViewController; +} + +-(void)viewDidAppear:(BOOL)animated +{ + if(self.initialModel != nil) [detailViewController.glView load:self.initialModel]; } - (void)didReceiveMemoryWarning