diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp index cfe5073a10a00295e7a1acd3f219f66787addd86..2e849444576c9e366f89f15cf540975ab3d8bbda 100644 --- a/contrib/mobile/drawContext.cpp +++ b/contrib/mobile/drawContext.cpp @@ -94,6 +94,9 @@ void drawContext::load(std::string filename) void drawContext::eventHandler(int event, float x, float y) { this->_current.set(this->_scale, this->_translate, this->_right, this->_left, this->_bottom, this->_top, this->_width, this->_height, x, y); + double xx[3] = {1.,0.,0.}; + double yy[3] = {0.,1.,0.}; + double q[4]; switch(event) { case 0: // finger(s) press the screen @@ -121,6 +124,17 @@ void drawContext::eventHandler(int event, float x, float y) case 4: // release the finger(s) // Do nothink ? break; + case 5: // X view + axis_to_quat(xx, M_PI/2, q); + setQuaternion(q[0], q[1], q[2], q[3]); + break; + case 6: // Y view + axis_to_quat(yy, M_PI/2, q); + setQuaternion(q[0], q[1], q[2], q[3]); + break; + case 7: // Z view + setQuaternion(0., 0., 0., 1.); + break; default: // all other reset the position setQuaternion(0., 0., 0., 1.); for(int i = 0; i < 3; i++){ diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.mm b/contrib/mobile/iOS/Onelab/DetailViewController.mm index ab97d6b339a4eb1d5c8f4ee3d2757f34017b5785..6ad70a7fd68960790951e6f5a3a17b1305354f9a 100644 --- a/contrib/mobile/iOS/Onelab/DetailViewController.mm +++ b/contrib/mobile/iOS/Onelab/DetailViewController.mm @@ -26,7 +26,6 @@ { if (_detailItem != newDetailItem) { _detailItem = newDetailItem; - // Update the view. [self configureView]; } @@ -39,17 +38,20 @@ - (void)configureView { // Update the user interface for the detail item. - if (self.detailItem) { self.detailDescriptionLabel.text = [self.detailItem description]; } } +-(void)viewDidAppear:(BOOL)animated +{ + if(self.initialModel != nil) [self.glView load:self.initialModel]; +} + - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(requestRender) name:@"requestRender" object:nil]; [self configureView]; scaleFactor = 1.; setObjCBridge((__bridge void*) self); @@ -59,16 +61,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.navigationController.navigationItem setLeftBarButtonItems:btns]; - [self.navigationController.navigationItem setRightBarButtonItem:model]; + [self.navigationItem setLeftBarButtonItems:btns]; + [self.navigationItem setRightBarButtonItem:model]; } 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:)]; - 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; + [self.navigationItem setLeftBarButtonItem:model]; + [self.navigationItem setRightBarButtonItems:btns]; } } @@ -335,14 +337,13 @@ else if([text isEqualToString:@"Show geometry"]) glView->mContext->showGeom(); else if([text isEqualToString:@"Set X view"]){ - /*glView->mContext->setRotation(0, 0, 0); - glView->mContext->setRotation(90, 0, 0);*/ + glView->mContext->eventHandler(5); } else if([text isEqualToString:@"Set Y view"]){ - //glView->mContext->setRotation(0, 90, 0); + glView->mContext->eventHandler(6); } else if([text isEqualToString:@"Set Z view"]){ - //glView->mContext->setRotation(0, 0, 0); + glView->mContext->eventHandler(7); } [glView drawView]; }