Skip to content
Snippets Groups Projects
Commit f8d8bcce authored by Maxime Graulich's avatar Maxime Graulich
Browse files

Fix bugs on iOS

parent 2b8b05fe
No related branches found
No related tags found
No related merge requests found
......@@ -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.;
......@@ -614,10 +613,14 @@ void drawContext::drawView()
checkGlError("Draw axes");
this->drawPost();
checkGlError("Draw post-pro");
if(_showGeom) this->drawGeom();
if(CTX::instance()->geom.draw){
this->drawGeom();
checkGlError("Draw geometry");
if(_showMesh) this->drawMesh();
}
if(CTX::instance()->mesh.draw){
this->drawMesh();
checkGlError("Draw mesh");
}
this->drawScale();
checkGlError("Draw scales");
}
......
#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
......@@ -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]);
......
......@@ -65,12 +65,12 @@
[self.navigationItem setLeftBarButtonItem:model];
[self.navigationItem setRightBarButtonItems:btns];
}
else {
UIBarButtonItem *model = [[UIBarButtonItem alloc] initWithTitle:@"Models list" style:UIBarButtonItemStyleBordered target:self action:@selector(showModelsList)];
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:)];
NSArray *btns = [[NSArray alloc] initWithObjects:postpro, more, nil];
[self.navigationItem setLeftBarButtonItem:model];
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];
}
}
......@@ -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)
{
......
......@@ -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,11 +207,9 @@
- (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
......
......@@ -14,18 +14,6 @@
@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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment