void buildDestPage(Page *destination) { // Definitions for Destination Page // Memory management destination->hasKeyboard = 0; destination->buttons = malloc(sizeof(Button) * 1); destination->objects = malloc(sizeof(Object) * 4); destination->inputBoxes = malloc(sizeof(InputBox) * 4); destination->sdBoxes = malloc(sizeof(SDBox) * 4); destination->numButtons = 1; destination->numObjects = 4; destination->backColour = WHITE; destination->numInputBoxes = 4; destination->numSDBoxes = 4; // Home button buildButton(160, 330, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Home", &(destination->buttons[0]), strlen("Home"), home); //Save Plaintext To SD buildSDBox(160, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Save Plaintext", &(destination->sdBoxes[0]), strlen("Save Plaintext")); //Save Encrypted To SD buildSDBox(320, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Save Encrypted", &(destination->sdBoxes[1]), strlen("Save Encrypted")); //Load from SD buildSDBox(480, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Load Data", &(destination->sdBoxes[2]), strlen("Load Data")); buildSDBox(640, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Load Secure", &(destination->sdBoxes[3]), strlen("Load Secure")); // Page contents // Headings buildObject(150, 100, BUTTON_WIDTH, BUTTON_HEIGHT, WHITE, WHITE, BLACK, "Your Destination Is: ", &(destination->objects[0]), strlen("Your Destination Is: ")); buildObject(150, 150, BUTTON_WIDTH, BUTTON_HEIGHT, WHITE, WHITE, BLACK, "Home Address: ", &(destination->objects[1]), strlen("Home Address: ")); buildObject(150, 200, BUTTON_WIDTH, BUTTON_HEIGHT, WHITE, WHITE, BLACK, "Phone #: ", &(destination->objects[2]), strlen("Phone #: ")); buildObject(150, 250, BUTTON_WIDTH, BUTTON_HEIGHT, WHITE, WHITE, BLACK, "Name: ", &(destination->objects[3]), strlen("Name: ")); // Text Fields for Input Boxes from top to bottom respectively buildInputBox(&(destination->inputBoxes[0]), 450, 100, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(destination->inputBoxes[1]), 450, 150, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(destination->inputBoxes[2]), 450, 200, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(destination->inputBoxes[3]), 450, 250, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); }
void buildHomePage(Page *home) { // Allocate memory for home screen buttons home->buttons = malloc(sizeof(Button) * 6); home->objects = malloc(sizeof(Object) * 3); home->numButtons = 6; home->numObjects = 3; home->numInputBoxes = 0; home->numSDBoxes = 0; home->backColour = WHITE; // Destination button buildButton(400, 359, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, LIME_GREEN, BLACK, "Destination", &(home->buttons[0]), strlen("Destination"), destination); // "Where am I?" button buildButton(600, 359, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, GOLD, BLACK, "Where am I?", &(home->buttons[1]), strlen("Where am I?"), self); //Password buildButton(200, 359, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, GOLD, BLACK, "Set Password", &(home->buttons[2]), strlen("Set Password"), passwordSetup); //map buildButton(266, 250, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, LIME_GREEN, BLACK, "Map", &(home->buttons[3]), strlen("Map"), map); //loggingSettings buildButton(533, 250, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, LIME_GREEN, BLACK, "Log Settings", &(home->buttons[4]), strlen("Log Settings"), loggingSettings); //addresses buildButton(400, 150, 300, 50, BLACK, GOLD, BLACK, "Addresses", &(home->buttons[5]), strlen("Addresses"), addresses); // Title Object buildObject(100, 100, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "SPRINT2 GROUP 3", &(home->objects[0]), strlen("SPRINT2 GROUP 3")); // Course Title Object buildObject(700, 100, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "CPEN391", &(home->objects[1]), strlen("CPEN391")); // Time Object buildObject(770, 20, BUTTON_WIDTH, BUTTON_HEIGHT, WHITE, WHITE, BLACK, " ", &(home->objects[2]), strlen("00:00")); }
void buildPWLoginPage(Page *password) { password->buttons = malloc(sizeof(Button) * 1); password->objects = malloc(sizeof(Object) * 1); password->inputBoxes = malloc(sizeof(InputBox) * 1); password->backColour = WHITE; password->numObjects = 1; password->numButtons = 1; password->numInputBoxes = 1; password->numSDBoxes = 0; // Enter Button buildButton(400, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Enter", &(password->buttons[0]), strlen("Enter"), home); // Incorrect Password Message buildObject(400, 100, BUTTON_WIDTH * 3, BUTTON_HEIGHT, BLACK, GOLD, BLACK, "Please Enter Your Password", &(password->objects[0]), strlen("Please Enter Your Password")); // Input Box buildInputBox(&(password->inputBoxes[0]), 380, 200, BUTTON_WIDTH * 4, BUTTON_HEIGHT * 2, GOLD, BLACK, BLACK); }
void buildLoggingSettingsPage(Page * loggingSettings) { loggingSettings->buttons = malloc(sizeof(Button) * 1); loggingSettings->objects = malloc(sizeof(Object) * 1); loggingSettings->inputBoxes = malloc(sizeof(InputBox) * 1); loggingSettings->sdBoxes = malloc(sizeof(SDBox) * 3); loggingSettings->numButtons = 1; loggingSettings->numObjects = 1; loggingSettings->backColour = WHITE; loggingSettings->numInputBoxes = 1; loggingSettings->numSDBoxes = 3; buildButton(160, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Home", &(loggingSettings->buttons[0]), strlen("Home"), home); buildObject(380 + 15, 150, BUTTON_WIDTH * 3 + 30, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Please Set Fence Radius In Metres:", &(loggingSettings->objects[0]), strlen("Please Set Fence Radius In Metres:")); buildInputBox(&(loggingSettings->inputBoxes[0]), 380, 200, BUTTON_WIDTH * 3, BUTTON_HEIGHT, WHITE, BLACK, BLACK); buildSDBox(320, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Enable Logging", &(loggingSettings->sdBoxes[0]), strlen("Enable Logging")); buildSDBox(480, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, RED, BLACK, "Disable Logging", &(loggingSettings->sdBoxes[1]), strlen("Disable Logging")); buildSDBox(640, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, LIME_GREEN, BLACK, "Save Distance", &(loggingSettings->sdBoxes[2]), strlen("Save Distance")); }
void buildPanicPage(Page *panicPage) { panicPage->buttons = malloc(sizeof(Button) * 4); panicPage->objects = malloc(sizeof(Object) * 1); panicPage->numButtons = 4; panicPage->numObjects = 1; panicPage->backColour = BLACK; panicPage->numInputBoxes = 0; panicPage->numSDBoxes = 0; buildButton(700, 420, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Menu", &(panicPage->buttons[0]), strlen("Menu"), home); buildButton(200, 300, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Where am I?", &(panicPage->buttons[1]), strlen("Where am I?"), map); buildButton(600, 300, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Remind Me", &(panicPage->buttons[2]), strlen("Remind Me"), self); buildButton(400, 300, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Logging", &(panicPage->buttons[3]), strlen("Logging"), loggingSettings); buildObject(400, 200, 500, 100, RED, RED, RED, "You Got Out Of The Fence", &(panicPage->objects[0]), strlen("You Got Out Of The Fence")); // disable logging intially writeToSD("n", "logfl.txt"); // intialize panicFlag panicFlag = 0; }
object::Object* Simulation::buildObject(const String& name, object::Object::Type type) { // Try to find object internal object type auto desc = findObjectType(name); if (desc) { // Create parent object auto obj = buildObject(desc->baseName); // Configure obj->configure(desc->config, *this); return obj; } Log::debug("Create object '", name, "'"); // Create object with given name auto object = getPluginContext().createObject(name, *this, type); // Register module if (object) return addObject(std::move(object)); Log::warning("Unable to create object: ", name, " (unsupported by library?)"); return nullptr; }
void add_builtins() { // Adds built ins: Object, IO, String, Int, Bool ast->add(buildObject()); ast->add(buildIO()); ast->add(buildString()); ast->add(buildBool()); add_nums(); ast->add(buildConvert()); }
void QJsonView::setJson(const QString &text) { clear(); QJsonDocument document = QJsonDocument::fromJson(text.toUtf8()); if( document.isArray() ) { buildArray("", document.array()); } else if( document.isObject() ) { buildObject("", document.object()); } else { throw -1; } }
void buildKeysPage(Page *keys) { keys->objects = malloc(sizeof(Object) * 1); keys->backColour = WHITE; keys->hasKeyboard = 1; //ONLY THIS PAGE WILL HAVE THIS FLAG HIGH keys->numObjects = 1; keys->numButtons = 0; Keyboard *kb = malloc(sizeof(Keyboard)); buildKeyboard(kb); keys->keyboard = *kb; keys->keyboard.isNum = 0; keys->keyboard.isUpper = 0; keys->keyboard.bufCount = 0; keys->keyboard.currentKeyset = keys->keyboard.keyset_lowercase; keys->numInputBoxes = 0; keys->numSDBoxes = 0; buildObject(380, 200, BUTTON_WIDTH * 4, BUTTON_HEIGHT * 2, BLACK, WHITE, BLACK, "", &(keys->objects[0]), 0); }
void updateBuffer(Key k, Page *currentScreen) { char input = k.writeChar; char *buffer = currentScreen->keyboard.buffer; Object *inputBox = &(currentScreen->objects[0]); currentScreen->keyboard.bufCount++; //Check if the buffer is empty if (currentScreen->keyboard.bufCount == 1) { strcpy(buffer, "\0"); strncat(buffer, &input, 1); } else { strncat(buffer, &input, 1); } //Check the buffer and draws the buffer to the box //Maximum input characters is 55 if (currentScreen->keyboard.bufCount < 55) { buildObject(400, 200, BUTTON_WIDTH * 4, BUTTON_HEIGHT * 2, BLACK, WHITE, BLACK, buffer, inputBox, strlen(buffer)); drawObject(inputBox); writeCaptionObjectLarge(inputBox, BLACK, WHITE); } }
std::shared_ptr<rapidjson::Document> Page::getJSONObject(long long headerpos) { //reading the Page tasking::RWLockGuard<> lock(m_rwLock, tasking::READ); //get the header first auto l_header = reinterpret_cast<HeaderMetaData*>(static_cast<char*>(m_header) + headerpos); //get the type auto l_objectType = l_header->getObjektType(); //get the idx auto& l_metaIdx = meta::MetaIndex::getInstance(); //get the meta dataset auto& l_meta = l_metaIdx[l_objectType]; //create the document auto l_obj = std::make_shared<rapidjson::Document>(); l_obj->SetObject(); //now generate the inner part of the object rapidjson::Value l_value; l_value.SetObject(); //calc the start id void* start = (static_cast<char*>(m_body) + l_header->getPos()); auto temp = buildObject(l_objectType, start, l_value, l_obj->GetAllocator()); if(temp == nullptr) { LOG_WARN << "build failed id: " << l_header->getOID(); return nullptr; } //generate name auto l_objName = l_meta->getName(); rapidjson::Value l_name(l_objName.c_str(), l_objName.length(), l_obj->GetAllocator()); //now add the inner object l_obj->AddMember(l_name, l_value, l_obj->GetAllocator()); return l_obj; }
void buildSelfPage(Page *self) { // Definitions for "Where am I?" // Memory Management self->buttons = malloc(sizeof(Button) * 1); self->objects = malloc(sizeof(Object) * 7); self->inputBoxes = malloc(sizeof(InputBox) * 4); self->sdBoxes = malloc(sizeof(SDBox) * 4); self->numButtons = 1; self->numObjects = 7; self->backColour = WHITE; self->numInputBoxes = 4; self->numSDBoxes = 4; // Buttons buildButton(160, 330, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Home", &(self->buttons[0]), strlen("Home"), home); //Save Plaintext To SD buildSDBox(160, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Save Plaintext", &(self->sdBoxes[0]), strlen("Save Plaintext")); //Save Encrypted To SD buildSDBox(320, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Save Encrypted", &(self->sdBoxes[1]), strlen("Save Encrypted")); //Load from SD buildSDBox(480, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Load Data", &(self->sdBoxes[2]), strlen("Load Data")); buildSDBox(640, 400, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Load Secure", &(self->sdBoxes[3]), strlen("Load Secure")); // Info fields // Name buildObject(150, 50, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Your Name Is: ", &(self->objects[0]), strlen("Your Name Is: ")); // Address buildObject(150, 100, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Home Address: ", &(self->objects[1]), strlen("Home Address: ")); // Phone buildObject(150, 150, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Phone #: ", &(self->objects[2]), strlen("Phone #: ")); // Emergency Contact buildObject(150, 200, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Emergency #: ", &(self->objects[3]), strlen("Emergency #: ")); // Current Location buildObject(150, 250, OBJECT_WIDTH, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Your Location Is: ", &(self->objects[4]), strlen("Your Location Is: ")); // Latitude buildObject(450, 250, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, WHITE, BLACK, "------------", &(self->objects[5]), 12); // Longitude buildObject(450, 300, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, WHITE, BLACK, "-------------", &(self->objects[6]), 13); // Input boxes on screen from top to bottom respectively buildInputBox(&(self->inputBoxes[0]), 450, 50, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(self->inputBoxes[1]), 450, 100, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(self->inputBoxes[2]), 450, 150, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); buildInputBox(&(self->inputBoxes[3]), 450, 200, OBJECT_WIDTH + 100, OBJECT_HEIGHT / 2, WHITE, BLACK, BLACK); }
void executeMapPress(Button theButton, int choice) { if (choice == 1 || choice == 2 || choice == 3) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; Object *o7; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); o7 = malloc(sizeof(Object)); buildObject(560, 70, 301, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: Kaiser Building", o, strlen("Name: Kaiser Building")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latitude = 49.2622103", o2, strlen("Latitude = 49.2622103")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 155, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude = -123.2501992", o3, strlen("Longitude = -123.2501992")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "2332 Main Mall V6T 1Z4", o4, strlen("2332 Main Mall V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Faculty of Electrical", o5, strlen("Faculty of Electrical")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "And Computer Engineering", o6, strlen("And Computer Engineering")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); buildObject(560, 348, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Offices of the Dean", o7, strlen("Offices of the Dean")); drawObject(o7); writeCaptionObjectLarge(o7, BLACK, WHITE); WaitForTouch(); free(o); free(o2); free(o3); free(o4); free(o5); free(o6); } else if (choice == 4 || choice == 5 || choice == 6) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); buildObject(560, 70, 301, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: MacLeod Building", o, strlen("Name: MacLeod Building")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latitude = 49.2617596", o2, strlen("Latitude = 49.2617596")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 158, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude = -123.2493528", o3, strlen("Longitude = -123.2493528")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "2356 Main Mall V6T 1Z4", o4, strlen("2356 Main Mall V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Electrical and Computer", o5, strlen("Electrical and Computer")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Engineering Building", o6, strlen("Engineering Building")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); WaitForTouch(); free(o); free(o2); } else if (choice == 10) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); buildObject(560, 70, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: The Cheeze Factory", o, strlen("Name: The Cheeze Factory")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latitude =49.26216059", o2, strlen("Latitude =49.26216059")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 158, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude = -123.249256100", o3, strlen("Longitude = -123.249256100")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "2335 Engineering Road V6T 1Z4", o4, strlen("2335 Engineering Road V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Dairy Products", o5, strlen("Dairy Products")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 325, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Manufacturing laboratory", o6, strlen("Manufacturing laboratory")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); WaitForTouch(); free(o); free(o2); } else if (choice == 11 || choice == 12) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; Object *o7; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); o7 = malloc(sizeof(Object)); buildObject(560, 70, 301, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: Brimacombe", o, strlen("Name: Brimacombe")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latidude = 49.261883399", o2, strlen("Latidude = 49.261883399 ")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 158, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude =-123.24831760", o3, strlen("Longitude =-123.24831760")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "2355 East Mall V6T 1Z4", o4, strlen("2355 East Mall V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Advanced Materials ", o5, strlen("Advanced Materials ")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "And Process Engineering", o6, strlen("And Process Engineering")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); buildObject(560, 348, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Laboratory", o7, strlen("Laboratory")); drawObject(o7); writeCaptionObjectLarge(o7, BLACK, WHITE); WaitForTouch(); free(o); free(o2); } else if (choice == 7 || choice == 8 || choice == 9) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); buildObject(560, 70, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: CEME", o, strlen("Name: CEME")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latitude = 49.2626097", o2, strlen("Latitude = 49.2626097")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 158, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude = -123.249115899", o3, strlen("Longitude = -123.249256100")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "6250 Applied Science Lane V6T 1Z4", o4, strlen("6250 Applied Science Lane V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Civil And Mechanical", o5, strlen("Civil And Mechanical")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 365, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Engineering Building", o6, strlen("Engineering Building")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); WaitForTouch(); free(o); free(o2); free(o3); } else if (choice == 13 || choice == 14) { Object *o; Object *o2; Object *o3; Object *o4; Object *o5; Object *o6; Object *o7; o = malloc(sizeof(Object)); o2 = malloc(sizeof(Object)); o3 = malloc(sizeof(Object)); o4 = malloc(sizeof(Object)); o5 = malloc(sizeof(Object)); o6 = malloc(sizeof(Object)); o7 = malloc(sizeof(Object)); buildObject(560, 70, 301, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Name: ICICS", o, strlen("Name: ICICS")); drawObject(o); writeCaptionObjectLarge(o, BLACK, WHITE); buildObject(560, 115, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Latitude = 49.2611776", o2, strlen("Latitude = 49.2611776")); drawObject(o2); writeCaptionObjectLarge(o2, BLACK, WHITE); buildObject(560, 158, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Longitude =-123.24880439", o3, strlen("Longitude =-123.24880439")); drawObject(o3); writeCaptionObjectLarge(o3, BLACK, WHITE); buildObject(560, 200, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "2366 Main Mall V6T 1Z4", o4, strlen("2366 Main Mall V6T 1Z4")); drawObject(o4); writeCaptionObjectLarge(o4, BLACK, WHITE); buildObject(560, 246, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Cognative Systems", o5, strlen("Cognative Systems")); drawObject(o5); writeCaptionObjectLarge(o5, BLACK, WHITE); buildObject(560, 295, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "And Computer Science", o6, strlen("And Computer Engineering")); drawObject(o6); writeCaptionObjectLarge(o6, BLACK, WHITE); buildObject(560, 348, 300, OBJECT_HEIGHT, WHITE, WHITE, BLACK, "Building", o7, strlen("Building")); drawObject(o7); writeCaptionObjectLarge(o7, BLACK, WHITE); WaitForTouch(); free(o); free(o2); free(o3); } else { globalCurrentPage = theButton.targetPage; } }
void Simulation::configure(const config::Configuration& config) { // Resize world { auto size = config.get<SizeVector>("world-size"); if (size.getWidth() == Zero || size.getHeight() == Zero) throw config::Exception("Width or height is zero!"); setWorldSize(size); } // Time step setTimeStep(config.get<units::Time>("dt")); if (config.has("length-coefficient")) { m_converter.setLengthCoefficient(config.get<RealType>("length-coefficient")); } // Set gravity setGravity(config.get("gravity", getGravity())); // Number of iterations setIterations(config.get("iterations", getIterations())); // Background color setBackgroundColor(config.get("background", getBackgroundColor())); #if CONFIG_RENDER_TEXT_ENABLE setFontColor(config.get("text-color", getBackgroundColor().inverted())); #endif #if CONFIG_RENDER_TEXT_ENABLE setFontSize(config.get("text-size", getFontSize())); #endif #if CONFIG_RENDER_TEXT_ENABLE setSimulationTimeRender(config.get("show-simulation-time", isSimulationTimeRender())); #endif #ifdef CECE_ENABLE_RENDER setVisualized(config.get("visualized", isVisualized())); #endif // Parse plugins for (auto&& pluginConfig : config.getConfigurations("plugin")) { // Returns valid pointer or throws an exception requirePlugin(pluginConfig.get("name"))->configure(*this, pluginConfig); } // Parse parameters for (auto&& parameterConfig : config.getConfigurations("parameter")) { setParameter(parameterConfig.get("name"), units::parse(parameterConfig.get("value"))); } // Register user types for (auto&& typeConfig : config.getConfigurations("type")) { addObjectType({ typeConfig.get("name"), typeConfig.get("base"), typeConfig.toMemory() }); } // Parse init for (auto&& initConfig : config.getConfigurations("init")) { const String typeName = initConfig.has("language") ? initConfig.get("language") : initConfig.get("type"); auto initializer = getPluginContext().createInitializer(typeName); if (initializer) { // Configure initializer initializer->loadConfig(*this, initConfig); // Register initializer addInitializer(std::move(initializer)); } } // Parse modules for (auto&& moduleConfig : config.getConfigurations("module")) { // Get name auto name = moduleConfig.get("name"); if (hasModule(name)) continue; const String typeName = moduleConfig.has("language") ? moduleConfig.get("language") : moduleConfig.has("type") ? moduleConfig.get("type") : name ; auto module = getPluginContext().createModule(typeName, *this); if (module) { module->loadConfig(*this, moduleConfig); addModule(std::move(name), std::move(module)); } } // Parse programs for (auto&& programConfig : config.getConfigurations("program")) { const String typeName = programConfig.has("language") ? programConfig.get("language") : programConfig.get("type"); auto program = getPluginContext().createProgram(typeName); if (program) { // Configure program program->loadConfig(*this, programConfig); // Register program addProgram(programConfig.get("name"), std::move(program)); } } // Parse objects for (auto&& objectConfig : config.getConfigurations("object")) { // Create object auto object = buildObject( objectConfig.get("class"), objectConfig.get("type", object::Object::Type::Dynamic) ); if (object) object->configure(objectConfig, *this); } if (config.has("data-out-objects-filename")) { m_dataOutObjects = makeUnique<OutFileStream>(config.get("data-out-objects-filename")); *m_dataOutObjects << "iteration;totalTime;id;typeName;posX;posY;velX;velY\n"; } }
void buildAddressesPage(Page *addresses) { addresses->buttons = malloc(sizeof(Button) * 1); addresses->objects = malloc(sizeof(Object) * 4); addresses->numButtons = 1; addresses->numObjects = 4; addresses->backColour = POWDER_BLUE; addresses->numInputBoxes = 0; addresses->numSDBoxes = 0; char read[512] = ""; char read2[512] = ""; char read3[512] = ""; char* ad; char* ad2; char* ad3; int i; readFromSD(read, AD1, 512); for(i=0;i<512;i++){ if(read[i]=='$'){ read[i]='\0'; break; } } ad = malloc(strlen(read) * sizeof(char)); strcpy(ad,read); readFromSD(read2, AD2, 512); for(i=0;i<512;i++){ if(read2[i]=='$'){ read2[i]='\0'; break; } } ad2 = malloc(strlen(read2) * sizeof(char)); strcpy(ad2,read2); readFromSD(read3, AD3, 512); for(i=0;i<512;i++){ if(read3[i]=='$'){ read3[i]='\0'; break; } } ad3 = malloc(strlen(read3) * sizeof(char)); strcpy(ad3,read3); buildButton(700, 420, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Menu", &(addresses->buttons[0]), strlen("Menu"), home); buildObject(400, 50, 400, 30, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, "List of Addresses", &(addresses->objects[0]), strlen("List of Addresses")); buildObject(400, 170, 650, 50, WHITE, WHITE, WHITE, ad, &(addresses->objects[1]), strlen(ad)); buildObject(400, 250, 650, 50, WHITE, WHITE, WHITE, ad2, &(addresses->objects[2]), strlen(ad2)); buildObject(400, 345, 650, 50, WHITE, WHITE, WHITE, ad3, &(addresses->objects[3]), strlen(ad3)); }
void buildMapPage(Page *Map) { Map->buttons = malloc(sizeof(Button) * 15); Map->objects = malloc(sizeof(Object) * 5); Map->numButtons = 15; Map->numObjects = 5; Map->backColour = GRAY_REPEAT; Map->numInputBoxes = 0; Map->numSDBoxes = 0; //Kaiser Red buildButton(700, 420, BUTTON_WIDTH, BUTTON_HEIGHT, BLACK, AQUA, BLACK, "Menu", &(Map->buttons[0]), strlen("Menu"), home); buildButton(190, 90, 120, 200, RED, RED, RED, "Kaiser", &(Map->buttons[1]), strlen("Kaiser"), NULL); buildButton(190, 196, 85, 10, RED, RED, RED, "", &(Map->buttons[2]), strlen(""), NULL); buildButton(293, 40, 85, 20, RED, RED, RED, "", &(Map->buttons[3]), strlen(""), NULL); //Mcleod Yellow buildButton(190, 276, 35, 150, ORANGE, ORANGE, ORANGE, "", &(Map->buttons[4]), strlen(""), NULL); buildButton(288, 370, 230, 47, ORANGE, ORANGE, ORANGE, "MacLeod", &(Map->buttons[5]), strlen("MacLeod"), NULL); buildButton(406, 370, 10, 23, ORANGE, ORANGE, ORANGE, "", &(Map->buttons[6]), strlen(""), NULL); //CEME buildButton(500, 39, 350, 74, INDIGO, INDIGO, INDIGO, "Civil and Mechanical", &(Map->buttons[7]), strlen("Civil and Mechanical"), NULL); buildButton(455, 170, 70, 240, INDIGO, INDIGO, INDIGO, "", &(Map->buttons[8]), strlen(""), NULL); buildButton(660, 120, 100, 200, INDIGO, INDIGO, INDIGO, "", &(Map->buttons[9]), strlen(""), NULL); //CHEESE buildButton(330, 250, 90, 60, WHITE, WHITE, BLACK, "CHEESE", &(Map->buttons[10]), strlen("CHEESE"), NULL); //Brimacombe Building buildButton(500, 390, 90, 170, ORANGE_RED, ORANGE_RED, ORANGE_RED, "", &(Map->buttons[11]), strlen(""), NULL); buildButton(630, 340, 190, 50, ORANGE_RED, ORANGE_RED, ORANGE_RED, "Brimacomb", &(Map->buttons[12]), strlen("Brimacomb"), NULL); //ICICS buildButton(230, 450, 180, 80, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, "ICICS", &(Map->buttons[13]), strlen("ICICS"), NULL); buildButton(135, 445, 10, 30, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, CORN_FLOWER_BLUE, "", &(Map->buttons[14]), strlen(""), NULL); //GRASS buildObject(50, 120, 70, 200, FOREST_GREEN, FOREST_GREEN, FOREST_GREEN, "", &(Map->objects[0]), strlen("")); buildObject(50, 340, 70, 200, FOREST_GREEN, FOREST_GREEN, FOREST_GREEN, "", &(Map->objects[1]), strlen("")); //Main Mall road buildObject(95, 230, 156, 15, LIGHT_GRAY, LIGHT_GRAY, LIGHT_GRAY, "", &(Map->objects[2]), strlen("")); //Engineering Road buildObject(435, 385, 15, 189, LIGHT_GRAY, LIGHT_GRAY, LIGHT_GRAY, "", &(Map->objects[3]), strlen("")); //.road. buildObject(100, 200, 20, 600, LIGHT_GRAY, LIGHT_GRAY, LIGHT_GRAY, "", &(Map->objects[4]), strlen("")); }
void buildSurfaceOfRotation( ) { /**** BODY ****/ buildObject( 0.0, 14.0, bodyControlPoints[0], BODY ); buildObject( 0.5, 13.5, bodyControlPoints[1], BODY); buildObject( 1.15, 13.0, bodyControlPoints[2], BODY ); buildObject( 1.15, 9.0, bodyControlPoints[3], BODY ); buildObject( 1.15, 8.0, bodyControlPoints[4], BODY ); buildObject( 1.15, 7.0, bodyControlPoints[5], BODY ); buildObject( 1.15, 6.0, bodyControlPoints[6], BODY ); buildObject( 1.15, 2.0, bodyControlPoints[7], BODY ); buildObject( 0.5, 1.5, bodyControlPoints[8], BODY ); buildObject( 0.0, 1.0, bodyControlPoints[9], BODY ); /**** WING ****/ buildObject( 0.0, 9.5, wingControlPoints[0], WING ); buildObject( 0.25, 9.0, wingControlPoints[1], WING); buildObject( 0.75, 8.5, wingControlPoints[2], WING ); buildObject( 0.75, 8.0, wingControlPoints[3], WING ); buildObject( 0.75, 7.5, wingControlPoints[4], WING ); buildObject( 0.75, 7.0, wingControlPoints[5], WING ); buildObject( 0.75, 6.5, wingControlPoints[6], WING ); buildObject( 0.5, 6.0, wingControlPoints[7], WING ); buildObject( 0.25, 5.5, wingControlPoints[8], WING ); buildObject( 0.0, 5.0, wingControlPoints[9], WING ); /**** DORSAL ****/ buildObject( 0.0, 3.5, dorsalControlPoints[0], DORSAL ); buildObject( 0.25, 3.0, dorsalControlPoints[1], DORSAL ); buildObject( 0.5, 2.5, dorsalControlPoints[2], DORSAL ); buildObject( 0.5, 2.0, dorsalControlPoints[3], DORSAL ); buildObject( 0.5, 1.5, dorsalControlPoints[4], DORSAL ); buildObject( 0.5, 1.0, dorsalControlPoints[5], DORSAL ); buildObject( 0.25, 0.5, dorsalControlPoints[6], DORSAL ); buildObject( 0.0, 0.0, dorsalControlPoints[7], DORSAL ); /**** SIDE DORSALS ****/ buildObject( 0.0, 2.0, sideDorsalControlPoints[0], SIDEDORSAL ); buildObject( 0.25, 1.75, sideDorsalControlPoints[1], SIDEDORSAL ); buildObject( 0.5, 1.5, sideDorsalControlPoints[2], SIDEDORSAL ); buildObject( 0.5, 1.25, sideDorsalControlPoints[3], SIDEDORSAL ); buildObject( 0.5, 1.0, sideDorsalControlPoints[4], SIDEDORSAL ); buildObject( 0.5, 0.75, sideDorsalControlPoints[5], SIDEDORSAL ); buildObject( 0.25, 0.25, sideDorsalControlPoints[6], SIDEDORSAL ); buildObject( 0.0, 0.0, sideDorsalControlPoints[7], SIDEDORSAL ); }