void handle_init() { autoconfig_init(); window = window_create(); window_set_background_color(window, GColorWhite); window_stack_push(window, true); app_message_register_inbox_received(in_received_handler); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); for (int i = 0; i < TOTAL_IMAGE_SLOTS; i++) { bitmaps[i] = NULL; image_containers[i] = bitmap_layer_create(GRect( ((i % 4) * 36), ((i / 4) * 70)+15, 36,70)); layer_add_child(window_layer, bitmap_layer_get_layer(image_containers[i])); } inverter_layer = inverter_layer_create (bounds); layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted()); layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer)); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); }
Pnt2f Slider::calculateSliderAlignment(const Pnt2f& Position1, const Vec2f& Size1, const Vec2f& Size2, const Real32& VAlign, const Real32& HAlign) { Vec2f CorrectedSize2(Size2); if(getOrientation() != VERTICAL_ORIENTATION) { CorrectedSize2[0] = Size2.y(); CorrectedSize2[1] = Size2.x(); } Real32 CorrectedVAlign(VAlign), CorrectedHAlign(HAlign); if(getInverted()) { if(getOrientation() == VERTICAL_ORIENTATION) { CorrectedVAlign = (1.0-VAlign); } else { CorrectedHAlign = (1.0-HAlign); } } Pnt2f AlignedPosition; AlignedPosition[0] = Position1[0]-CorrectedSize2[0]/2+CorrectedHAlign*(Size1[0]); AlignedPosition[1] = Position1[1]-CorrectedSize2[1]/2+CorrectedVAlign*(Size1[1]); return AlignedPosition; }
BranchPlain ExtendedTbrProposer::determinePrimeBranch(const TreeAln &traln, Randomness& rand) const { auto canMove = [&](const BranchPlain &b) -> bool { auto result = traln.isTipBranch(b); if( not result) { auto desc = traln.getDescendents(b) ; result = not(traln.isTipBranch(desc.first) && traln.isTipBranch(desc.second) ); // tout << b << " with children " << std::get<0>(desc) << "," << std::get<1>(desc)<< std::endl ; } return result; }; auto bisectedBranch = BranchPlain{}; auto movableA = bool{false}; auto movableB = bool{false}; while(not ( movableA || movableB ) ) { bisectedBranch = TreeRandomizer::drawBranchWithInnerNode(traln,rand); movableA = canMove(bisectedBranch); movableB = canMove(bisectedBranch.getInverted()); } return bisectedBranch; }
static void in_received_handler(DictionaryIterator *iter, void *context) { // Let Pebble Autoconfig handle received settings autoconfig_in_received_handler(iter, context); // Update display with new values layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted()); }
void ExtendedTbrProposer::determineMove(TreeAln &traln, LikelihoodEvaluator &eval, Randomness& rand, BranchPlain primeBranch, const std::vector<AbstractParameter*> ¶ms) { auto modifiedPath1 = Path{}; auto modifiedPath2 = Path{}; auto bisectedBranch = primeBranch; // determine, if a true TBR move can be executed auto canMove = [&](const BranchPlain &b) -> bool { if(traln.isTipNode(b.getPrimNode())) return false; else { auto desc = traln.getDescendents(b) ; return not(traln.isTipBranch(desc.first) && traln.isTipBranch(desc.second)) ; } }; auto oneMovable = canMove(bisectedBranch); auto otherMovable = canMove(bisectedBranch.getInverted()); auto descOne = BranchPlain{}; if(oneMovable) { buildPath(modifiedPath1, bisectedBranch, traln, rand, params); descOne = modifiedPath1.at( int(modifiedPath1.size() -1) ); } auto descOther = BranchPlain{}; if(otherMovable) { buildPath(modifiedPath2, bisectedBranch.getInverted(), traln, rand, params); descOther = modifiedPath2.at(int(modifiedPath2.size()-1)); } _forwProb = log_double::fromAbs(1.); _move = TbrMove(traln, bisectedBranch, descOne, descOther) ; }
int main(void) { autoconfig_init(); app_message_register_inbox_received(in_received_handler); center = GPoint(72, 74); window = window_create(); window_stack_push(window, true); window_set_background_color(window, GColorBlack); Layer *window_layer = window_get_root_layer(window); GRect bounds = layer_get_frame(window_layer); layer = layer_create(bounds); layer_set_update_proc(layer, update_layer_callback); layer_add_child(window_layer, layer); inverter_layer = inverter_layer_create(bounds); layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted()); layer_add_child(window_layer, inverter_layer_get_layer(inverter_layer)); custom_font = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_UNSTEADY_OVERSTEER_22)); image = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_PATTERN); time_t now = time(NULL); struct tm *tick_time = localtime(&now); handle_minute_tick(tick_time, MINUTE_UNIT); tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick); bluetooth_connection_service_subscribe(bluetooth_connection_handler); bluetooth_connected = bluetooth_connection_service_peek(); app_event_loop(); layer_destroy(layer); inverter_layer_destroy(inverter_layer); window_destroy(window); gbitmap_destroy(image); fonts_unload_custom_font(custom_font); tick_timer_service_unsubscribe(); bluetooth_connection_service_unsubscribe(); autoconfig_deinit(); }
void FreeCameraController::handleMouseMoveEvent(int x, int y) { if (!isActive()) return; if (mNaviPrimary) { double scalar = getCameraSensitivity() * (getInverted() ? -1.0 : 1.0); yaw(x * scalar); pitch(y * scalar); } else if (mNaviSecondary) { osg::Vec3d movement; movement += LocalLeft * -x * getSecondaryMovementMultiplier(); movement += LocalUp * y * getSecondaryMovementMultiplier(); translate(movement); } }
void OrbitCameraController::handleMouseMoveEvent(int x, int y) { if (!isActive()) return; if (!mInitialized) initialize(); if (mNaviPrimary) { double scalar = getCameraSensitivity() * (getInverted() ? -1.0 : 1.0); rotateHorizontal(x * scalar); rotateVertical(-y * scalar); } else if (mNaviSecondary) { osg::Vec3d movement; movement += LocalLeft * x * getSecondaryMovementMultiplier(); movement += LocalUp * -y * getSecondaryMovementMultiplier(); translate(movement); } }
static void in_received_handler(DictionaryIterator *iter, void *context) { autoconfig_in_received_handler(iter, context); layer_set_hidden(inverter_layer_get_layer(inverter_layer), !getInverted()); }