From 1d66f7369bc022152a861f39b6c901bba6fb6a46 Mon Sep 17 00:00:00 2001
From: Maxime Graulich <maxime.graulich@gmail.com>
Date: Mon, 5 Aug 2013 06:53:22 +0000
Subject: [PATCH]

---
 contrib/mobile/CMakeLists.txt                 |  1 +
 contrib/mobile/drawContext.cpp                |  2 +-
 contrib/mobile/drawString.cpp                 |  9 ++++----
 .../iOS/Onelab.xcodeproj/project.pbxproj      | 14 ++++++++----
 .../mobile/iOS/Onelab/DetailViewController.mm |  5 +++--
 .../mobile/iOS/Onelab/MasterViewController.mm |  2 +-
 contrib/mobile/iosGModel.cpp                  | 22 +++++++++++++++++++
 contrib/mobile/iosGModel.h                    | 16 +++-----------
 8 files changed, 45 insertions(+), 26 deletions(-)
 create mode 100644 contrib/mobile/iosGModel.cpp

diff --git a/contrib/mobile/CMakeLists.txt b/contrib/mobile/CMakeLists.txt
index 4a363582ce..9b13e72382 100644
--- a/contrib/mobile/CMakeLists.txt
+++ b/contrib/mobile/CMakeLists.txt
@@ -63,6 +63,7 @@ if(ENABLE_BUILD_IOS_EMULATOR OR ENABLE_BUILD_IOS)
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Trackball.h ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/movePosition.h ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/
     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/iosGModel.h ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/
+    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/iosGModel.cpp ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/frameworks/GetDP.framework/Headers/
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/frameworks/Gmsh.framework/Headers/
     COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/Onelab/Onelab/frameworks/petsc.framework/Headers/
diff --git a/contrib/mobile/drawContext.cpp b/contrib/mobile/drawContext.cpp
index 6b3c098915..3a434e3356 100644
--- a/contrib/mobile/drawContext.cpp
+++ b/contrib/mobile/drawContext.cpp
@@ -438,7 +438,7 @@ void drawContext::drawScale()
 		free(vertex);
 		free(color);
 		char label[1024];
-		drawString *lbl = new drawString(p->getData()->getName().c_str(), 16);
+		drawString *lbl = new drawString(p->getData()->getName().c_str(), 20);
 		lbl->draw(xmin+width/2, ymin-height/2, 0., _width/(_right-_left), _height/(_top-_bottom));
 		drawString *val = new drawString(p->getData()->getName().c_str(), 14);
 		for(int i = 0; i < 3; i++) {
diff --git a/contrib/mobile/drawString.cpp b/contrib/mobile/drawString.cpp
index 4cb44feb38..0531a22175 100644
--- a/contrib/mobile/drawString.cpp
+++ b/contrib/mobile/drawString.cpp
@@ -28,7 +28,6 @@ void drawString::setText(std::string text)
 {
 	this->_text = text;
 	getBitmapFromString(this->_text.c_str(), _size, &this->_map, &this->_height, &this->_width, &this->_realWidth);
-    //printf("\n%s\n", _text.c_str());for(int i=0; i<_height*_width;i++) printf("0x%x ", _map[i]);printf("\n");
 }
 
 void drawString::setColor(float color[4])
@@ -73,14 +72,14 @@ void drawString::draw(float x, float y, float z, float w, float h, bool center)
 	glEnable(GL_TEXTURE_2D);
 	glEnable(GL_BLEND);
 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	glEnableClientState(GL_VERTEX_ARRAY);
+	glTexCoordPointer(2, GL_FLOAT, 0, texture);
 	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
 	glVertexPointer(3, GL_FLOAT, 0, vertex);
-	glTexCoordPointer(2, GL_FLOAT, 0, texture);
+	glEnableClientState(GL_VERTEX_ARRAY);
 	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
-	glDisable(GL_TEXTURE_2D);
-	glDisable(GL_BLEND);
 	glDisableClientState(GL_VERTEX_ARRAY);
 	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+	glDisable(GL_BLEND);
+	glDisable(GL_TEXTURE_2D);
 	glDeleteTextures(1, &textureId);
 }
diff --git a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
index b99abbea2b..c8a0972ed3 100644
--- a/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
+++ b/contrib/mobile/iOS/Onelab.xcodeproj/project.pbxproj
@@ -38,6 +38,7 @@
 		9CE08E16178AEC5F00A83B4B /* movePosition.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E03178AE6BE00A83B4B /* movePosition.h */; };
 		9CE08E17178AEC5F00A83B4B /* Trackball.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E04178AE6BE00A83B4B /* Trackball.cpp */; };
 		9CE08E18178AEC5F00A83B4B /* Trackball.h in Sources */ = {isa = PBXBuildFile; fileRef = 9CE08E05178AE6BE00A83B4B /* Trackball.h */; };
+		9CEAE86E17AF824B00813524 /* iosGModel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAE86D17AF824B00813524 /* iosGModel.cpp */; };
 		9CEAECC717A91CD20014D229 /* ModelListController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CEAECC617A91CD20014D229 /* ModelListController.mm */; };
 		9CF1C1ED17AA6E7E002CD2E3 /* iPhoneStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 9CF1C1EB17AA6E7E002CD2E3 /* iPhoneStoryboard.storyboard */; };
 		9CF1C1EF17AA8997002CD2E3 /* Onelab-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9CF1C1EE17AA8997002CD2E3 /* Onelab-Info.plist */; };
@@ -92,6 +93,7 @@
 		9CE08E0D178AEB1600A83B4B /* GetDP.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GetDP.framework; path = Onelab/frameworks/GetDP.framework; sourceTree = "<group>"; };
 		9CE08E0E178AEB1600A83B4B /* Gmsh.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Gmsh.framework; path = Onelab/frameworks/Gmsh.framework; sourceTree = "<group>"; };
 		9CE08E0F178AEB1600A83B4B /* petsc.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = petsc.framework; path = Onelab/frameworks/petsc.framework; sourceTree = "<group>"; };
+		9CEAE86D17AF824B00813524 /* iosGModel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = iosGModel.cpp; sourceTree = "<group>"; };
 		9CEAECC517A91CD20014D229 /* ModelListController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModelListController.h; sourceTree = "<group>"; };
 		9CEAECC617A91CD20014D229 /* ModelListController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ModelListController.mm; sourceTree = "<group>"; };
 		9CF1C1EC17AA6E7E002CD2E3 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/iPhoneStoryboard.storyboard; sourceTree = "<group>"; };
@@ -175,14 +177,15 @@
 				9CF1C1EB17AA6E7E002CD2E3 /* iPhoneStoryboard.storyboard */,
 				9C9608491712C16300E1D4A0 /* AppDelegate.h */,
 				9C96084A1712C16300E1D4A0 /* AppDelegate.mm */,
-				9CE08E01178AE6BE00A83B4B /* drawContext.cpp */,
+				9C99754C17390DEE0036EC24 /* iosGModel.h */,
+				9CEAE86D17AF824B00813524 /* iosGModel.cpp */,
 				9CE08E02178AE6BE00A83B4B /* drawContext.h */,
-				9C6A645617A7C3DB00DEDAFC /* drawString.cpp */,
+				9CE08E01178AE6BE00A83B4B /* drawContext.cpp */,
 				9C6A645717A7C3DB00DEDAFC /* drawString.h */,
-				9C99754C17390DEE0036EC24 /* iosGModel.h */,
+				9C6A645617A7C3DB00DEDAFC /* drawString.cpp */,
 				9CE08E03178AE6BE00A83B4B /* movePosition.h */,
-				9CE08E04178AE6BE00A83B4B /* Trackball.cpp */,
 				9CE08E05178AE6BE00A83B4B /* Trackball.h */,
+				9CE08E04178AE6BE00A83B4B /* Trackball.cpp */,
 				9C96084F1712C16400E1D4A0 /* MasterViewController.h */,
 				9C9608501712C16400E1D4A0 /* MasterViewController.mm */,
 				9C9608521712C16400E1D4A0 /* DetailViewController.h */,
@@ -351,6 +354,7 @@
 				9C95B7F61726C88E00C0CCE2 /* main.m in Sources */,
 				9C6A645817A7C3DB00DEDAFC /* drawString.cpp in Sources */,
 				9CEAECC717A91CD20014D229 /* ModelListController.mm in Sources */,
+				9CEAE86E17AF824B00813524 /* iosGModel.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -468,6 +472,7 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "Onelab/Onelab-Prefix.pch";
 				INFOPLIST_FILE = "Onelab/Onelab-Info.plist";
+				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
 				OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
 				PRODUCT_NAME = "$(TARGET_NAME)";
@@ -496,6 +501,7 @@
 				GCC_PRECOMPILE_PREFIX_HEADER = YES;
 				GCC_PREFIX_HEADER = "Onelab/Onelab-Prefix.pch";
 				INFOPLIST_FILE = "Onelab/Onelab-Info.plist";
+				IPHONEOS_DEPLOYMENT_TARGET = 5.0;
 				LIBRARY_SEARCH_PATHS = "$(inherited)";
 				PRODUCT_NAME = "$(TARGET_NAME)";
 				PROVISIONING_PROFILE = "";
diff --git a/contrib/mobile/iOS/Onelab/DetailViewController.mm b/contrib/mobile/iOS/Onelab/DetailViewController.mm
index 5b3684aabf..43d8125db3 100644
--- a/contrib/mobile/iOS/Onelab/DetailViewController.mm
+++ b/contrib/mobile/iOS/Onelab/DetailViewController.mm
@@ -341,7 +341,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)
 {
@@ -350,6 +350,7 @@ void getBitmap(void *self, const char *text, int textsize, unsigned char **map,
 -(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)];
+    lbl.font = [UIFont systemFontOfSize:textsize];
     [lbl setText:[NSString stringWithCString:text  encoding:[NSString defaultCStringEncoding]]];
     [lbl setBackgroundColor:[UIColor clearColor]];
     CGSize lblSize = [[lbl text] sizeWithFont:[lbl font]];
@@ -379,7 +380,7 @@ void getBitmap(void *self, const char *text, int textsize, unsigned char **map,
 
     // rawData contains the image data in the RGBA8888 pixel format.
     for (int byteIndex = 0 ; byteIndex < *width * *height * 4 ; byteIndex+=4)
-        *(*map+byteIndex/4) = (rawData[byteIndex + 3] == 0x00)? 0x00 : 0xFF;
+        *(*map+byteIndex/4) = rawData[byteIndex + 3];
     free(rawData);
 }
 @end
diff --git a/contrib/mobile/iOS/Onelab/MasterViewController.mm b/contrib/mobile/iOS/Onelab/MasterViewController.mm
index 42dafa0a4e..2bf97da4ef 100644
--- a/contrib/mobile/iOS/Onelab/MasterViewController.mm
+++ b/contrib/mobile/iOS/Onelab/MasterViewController.mm
@@ -30,7 +30,7 @@
 	// Do any additional setup after loading the view, typically from a nib.
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshObject:) name:@"refreshParameters" object:nil];
     runButton = [[UIBarButtonItem alloc] initWithTitle:@"Run" style:UIBarButtonItemStyleBordered target:self action:@selector(runWithNewParameter)];
-    [runButton setTitle:@"Run"]; // ?? do nothink ??
+    [runButton setTitle:@"Run"];
     self.navigationItem.leftBarButtonItem = runButton;
 
     UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshObject:)];
diff --git a/contrib/mobile/iosGModel.cpp b/contrib/mobile/iosGModel.cpp
new file mode 100644
index 0000000000..e5b1fa2159
--- /dev/null
+++ b/contrib/mobile/iosGModel.cpp
@@ -0,0 +1,22 @@
+//
+//  iosGModel.cpp
+//  Onelab
+//
+//  Created by Maxime Graulich on 05/08/13.
+//  Copyright (c) 2013 Maxime Graulich. All rights reserved.
+//
+
+#include "iosGModel.h"
+
+static void * objc;
+
+void getBitmapFromString(const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth)
+{
+    getBitmap(objc, text, textsize, map, height, width, realWidth);
+}
+
+void setObjCBridge(void *objcObject)
+{
+    objc = objcObject;
+    Msg::SetCallback((GmshMessage*)new MobileMessage(objcObject));
+}
\ No newline at end of file
diff --git a/contrib/mobile/iosGModel.h b/contrib/mobile/iosGModel.h
index 44fd703d19..4479d61f10 100644
--- a/contrib/mobile/iosGModel.h
+++ b/contrib/mobile/iosGModel.h
@@ -12,17 +12,12 @@
 #include <iostream>
 #include <string>
 
-#include "drawContext.h"
-
-static void * objc;
+#include <Gmsh/GmshMessage.h>
 
 void messageFromCpp (void *self, std::string level, std::string msg);
 void getBitmap(void *self, const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth=NULL);
-//void getBitmapFromString(const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth=NULL);
-void getBitmapFromString(const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth)
-{
-    getBitmap(objc, text, textsize, map, height, width, realWidth);
-}
+void getBitmapFromString(const char *text, int textsize, unsigned char **map, int *height, int *width, int *realWidth=NULL);
+void setObjCBridge(void *objcObject);
 
 class MobileMessage : GmshMessage
 {
@@ -36,10 +31,5 @@ public:
         messageFromCpp(_objcObject, level, message);
     }
 };
-void setObjCBridge(void *objcObject)
-{
-    objc = objcObject;
-    Msg::SetCallback((GmshMessage*)new MobileMessage(objcObject));
-}
 
 #endif /* defined(__Onelab__iosGModel__) */
-- 
GitLab