int View::create() { if (output_id < 0) //does not need thread protection because it is set up by a callback during call of add_view return add_view(this, output_x, output_y, output_width, output_height, title.c_str()); else return output_id; }
void MorphologyViewerWidget::split_horizontally( unsigned int view_index , unsigned int width_factor ) { float aspect_ratio = static_cast<float>( this->width()) / static_cast<float>( this->height() ); osgViewer::View * parent_view = _viewer -> getView (view_index); osg::Camera * parent_camera = parent_view -> getCamera(); osg::Viewport * parent_viewport = parent_camera -> getViewport(); int new_parent_width = parent_viewport -> width() * (width_factor - 1) / width_factor; add_view( parent_viewport -> x() + new_parent_width , parent_viewport -> y() , parent_viewport -> width() - new_parent_width , parent_viewport -> height() ); parent_camera->setViewport( parent_viewport -> x() , parent_viewport -> y() , new_parent_width , parent_viewport -> height() ); parent_camera->setProjectionMatrixAsPerspective( 30.f , static_cast<float>(new_parent_width) / static_cast<float>(parent_viewport -> height()) , 1.0f , 10000.0f ); }
static void impl_activate (GeditPlugin *plugin, GeditWindow *window) { WindowData *data; GList *views, *l; gedit_debug (DEBUG_PLUGINS); data = g_slice_new (WindowData); data->provider = gtk_source_completion_words_new (_("Document Words"), NULL); views = gedit_window_get_views (window); for (l = views; l != NULL; l = g_list_next (l)) { add_view (data, GTK_SOURCE_VIEW (l->data)); } g_object_set_data_full (G_OBJECT (window), WINDOW_DATA_KEY, data, (GDestroyNotify) free_window_data); data->tab_added_id = g_signal_connect (window, "tab-added", G_CALLBACK (tab_added_cb), NULL); data->tab_removed_id = g_signal_connect (window, "tab-removed", G_CALLBACK (tab_removed_cb), NULL); }
MorphologyViewerWidget::MorphologyViewerWidget( Morphology * morphology , QWidget * parent , const QGLWidget* share_widget , Qt::WindowFlags f ) : morphology(morphology) , QGLWidget( parent , share_widget , f ) , _graphics_window( new osgViewer::GraphicsWindowEmbedded( this->x() , this->y() , this->width() , this->height() ) ) , _viewer( new osgViewer::CompositeViewer ) , capture_format("jpeg") , capture_location("/home/aviral/moogli_test") { osg::StateSet* stateSet = morphology -> get_scene_graph()->getOrCreateStateSet(); osg::Material* material = new osg::Material; material->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE ); stateSet->setAttributeAndModes( material, osg::StateAttribute::ON ); stateSet->setMode( GL_DEPTH_TEST, osg::StateAttribute::ON ); _previous_width = this -> width(); _previous_height = this -> height(); add_view(0,0,this -> width(), this -> height()); // add_view(this -> width()/2, 0, this -> width()/2, this -> height()); _viewer->setThreadingModel( osgViewer::CompositeViewer::SingleThreaded ); // This ensures that the widget will receive keyboard events. This focus // policy is not set by default. The default, Qt::NoFocus, will result in // keyboard events that are ignored. this->setFocusPolicy( Qt::StrongFocus ); this->setMinimumSize( 200 , 200 ); // Ensures that the widget receives mouse move events even though no // mouse button has been pressed. We require this in order to let the // graphics window switch viewports properly. this->setMouseTracking( true ); const osg::BoundingSphere& bs = morphology -> get_scene_graph() -> getBound(); up_distance = bs.radius() * 0.01; down_distance = bs.radius() * 0.01; left_distance = bs.radius() * 0.01; right_distance = bs.radius() * 0.01; forward_distance = bs.radius() * 0.01; backward_distance = bs.radius() * 0.01; zoom_factor = 0.10; roll_angle = M_PI / 36.0; pitch_angle = M_PI / 36.0; yaw_angle = M_PI / 36.0; }
int initifstat(void) { field_view *v; read_if(); for (v = views_if; v->name != NULL; v++) add_view(v); return(1); }
int initpf(void) { field_view *v; for (v = views_pf; v->name != NULL; v++) add_view(v); return(1); }
int initpool(void) { field_view *v; for (v = views_pool; v->name != NULL; v++) add_view(v); read_pool(); return(0); }
int initvmstat(void) { field_view *v; int mib[4], i; size_t size; hertz = stathz; if (!dkinit(1)) return(0); mib[0] = CTL_KERN; mib[1] = KERN_INTRCNT; mib[2] = KERN_INTRCNT_NUM; size = sizeof(nintr); if (sysctl(mib, 3, &nintr, &size, NULL, 0) < 0) return (-1); intrloc = calloc(nintr, sizeof(long)); intrname = calloc(nintr, sizeof(char *)); for (i = 0; i < nintr; i++) { char name[128]; mib[0] = CTL_KERN; mib[1] = KERN_INTRCNT; mib[2] = KERN_INTRCNT_NAME; mib[3] = i; size = sizeof(name); if (sysctl(mib, 4, name, &size, NULL, 0) < 0) return (-1); intrname[i] = strdup(name); if (intrname[i] == NULL) return (-1); } nextintsrow = INTSROW + 2; allocinfo(&s); allocinfo(&s1); allocinfo(&s2); allocinfo(&s3); allocinfo(&z); getinfo(&s2); copyinfo(&z, &s1); for (v = views_vm; v->name != NULL; v++) add_view(v); return(1); }
int initmalloc(void) { field_view *v; for (v = views_malloc; v->name != NULL; v++) add_view(v); read_buckets(); read_types(); return(0); }
int initiostat(void) { field_view *v; dkinit(1); dkreadstats(); bzero(&bccur, sizeof(bccur)); for (v = views_io; v->name != NULL; v++) add_view(v); return(1); }
// To make a StaticLSTMLayer with n cells, you must specify 2*n as size in Python StaticLstmLayer::Parameters::Parameters(size_t n_inputs, size_t n_cells) : IX(NULL, n_cells/2, n_inputs - (n_cells/2), 1), FX(NULL, n_cells/2, n_inputs - (n_cells/2), 1), ZX(NULL, n_cells/2, n_inputs - (n_cells/2), 1), OX(NULL, n_cells/2, n_inputs - (n_cells/2), 1), I_bias(NULL, n_cells/2, 1, 1), F_bias(NULL, n_cells/2, 1, 1), Z_bias(NULL, n_cells/2, 1, 1), O_bias(NULL, n_cells/2, 1, 1) { add_view("IX", &IX); add_view("FX", &FX); add_view("ZX", &ZX); add_view("OX", &OX); add_view("I_bias", &I_bias); add_view("F_bias", &F_bias); add_view("Z_bias", &Z_bias); add_view("O_bias", &O_bias); }
static void tab_added_cb (GeditWindow *window, GeditTab *tab, gpointer useless) { GeditView *view; WindowData *data; data = (WindowData *) g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY); g_return_if_fail (data != NULL); view = gedit_tab_get_view (tab); add_view (data, GTK_SOURCE_VIEW (view)); }
void MorphologyViewerWidget::split_vertically( unsigned int view_index , unsigned int height_factor ) { float aspect_ratio = static_cast<float>( this->width()) / static_cast<float>( this->height() ); osgViewer::View * parent_view = _viewer -> getView (view_index); osg::Camera * parent_camera = parent_view -> getCamera(); osg::Viewport * parent_viewport = parent_camera -> getViewport(); // std::cout << "parent x => " << parent_viewport -> x() << std::endl; // std::cout << "parent y => " << parent_viewport -> y() << std::endl; // std::cout << "parent width => " << parent_viewport -> width() << std::endl; // std::cout << "parent height => " << parent_viewport -> height() << std::endl; int new_parent_height = parent_viewport -> height() * (height_factor - 1) / height_factor; add_view( parent_viewport -> x() , parent_viewport -> y() + new_parent_height , parent_viewport -> width() , parent_viewport -> height() - new_parent_height ); // std::cout << "child x => " << parent_viewport -> x() << std::endl; // std::cout << "child y => " << parent_viewport -> y() + new_parent_height << std::endl; // std::cout << "child width => " << parent_viewport -> width() << std::endl; // std::cout << "child height => " << parent_viewport -> height() - new_parent_height << std::endl; parent_camera->setViewport( parent_viewport -> x() , parent_viewport -> y() , parent_viewport -> width() , new_parent_height ); // std::cout << "parent2 x => " << parent_viewport -> x() << std::endl; // std::cout << "parent2 y => " << parent_viewport -> y() << std::endl; // std::cout << "parent2 width => " << parent_viewport -> width() << std::endl; // std::cout << "parent2 height => " << new_parent_height << std::endl; parent_camera->setProjectionMatrixAsPerspective( 30.f , static_cast<float>(parent_viewport -> width()) / static_cast<float>(new_parent_height) , 1.0f , 10000.0f ); }
int initnetstat(void) { field_view *v; int ret; if (kd) { if ((ret = kvm_nlist(kd, namelist)) == -1) errx(1, "%s", kvm_geterr(kd)); else if (ret) nlisterr(namelist); if (namelist[X_TCBTABLE].n_value == 0) { error("No symbols in namelist"); return(0); } } protos = TCP|UDP; for (v = views_ns; v->name != NULL; v++) add_view(v); return(1); }
void MainWindow::create_resource_viewer_view() { add_view(new ResourceViewerView(workspace, this)); }
StaticLstmLayer::BwdState::BwdState(size_t, size_t n_cells, size_t n_batches, size_t time) : //Views on all activations Ia(n_cells/2, n_batches, time), Ib(n_cells/2, n_batches, time), //Input gate activation Fa(n_cells/2, n_batches, time), Fb(n_cells/2, n_batches, time), //forget gate activation Oa(n_cells/2, n_batches, time), Ob(n_cells/2, n_batches, time), //output gate activation Za(n_cells/2, n_batches, time), Zb(n_cells/2, n_batches, time), //Net Activation S(n_cells/2, n_batches, time), //Cell activations f_S(n_cells/2, n_batches, time), //cell state activations // Hb(n_cells/2, n_batches, time), //!< output of LSTM block tmp1(n_cells/2, n_batches, time) // for calculating derivs { add_view("Ia", &Ia); add_view("Ib", &Ib); add_view("Fa", &Fa); add_view("Fb", &Fb); add_view("Oa", &Oa); add_view("Ob", &Ob); add_view("Za", &Za); add_view("Zb", &Zb); add_view("S", &S); add_view("f_S", &f_S); // add_view("Hb", &Hb); add_view("tmp1", &tmp1); }
int initmembufs(void) { struct if_rxring_info *ifr; field_view *v; int i, mib[4], npools; struct kinfo_pool pool; char pname[32]; size_t size; sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock == -1) { err(1, "socket()"); /* NOTREACHED */ } /* set up the "System" interface */ interfaces = calloc(1, sizeof(*interfaces)); if (interfaces == NULL) err(1, "calloc: interfaces"); ifr = calloc(MCLPOOLS, sizeof(*ifr)); if (ifr == NULL) err(1, "calloc: system pools"); strlcpy(interfaces[0].name, "System", sizeof(interfaces[0].name)); interfaces[0].data.ifri_total = MCLPOOLS; interfaces[0].data.ifri_entries = ifr; num_ifs = 1; /* go through all pools to identify mbuf and cluster pools */ mib[0] = CTL_KERN; mib[1] = KERN_POOL; mib[2] = KERN_POOL_NPOOLS; size = sizeof(npools); if (sysctl(mib, 3, &npools, &size, NULL, 0) < 0) { err(1, "sysctl(KERN_POOL_NPOOLS)"); /* NOTREACHED */ } for (i = 1; i <= npools; i++) { mib[0] = CTL_KERN; mib[1] = KERN_POOL; mib[2] = KERN_POOL_NAME; mib[3] = i; size = sizeof(pname); if (sysctl(mib, 4, &pname, &size, NULL, 0) < 0) { continue; } if (strcmp(pname, "mbpl") == 0) { mbpool_index = i; continue; } if (strncmp(pname, "mcl", 3) != 0) continue; if (mclpool_count == MCLPOOLS) { warnx("mbufs: Too many mcl* pools"); break; } mib[2] = KERN_POOL_POOL; size = sizeof(pool); if (sysctl(mib, 4, &pool, &size, NULL, 0) < 0) { err(1, "sysctl(KERN_POOL_POOL, %d)", i); /* NOTREACHED */ } snprintf(ifr[mclpool_count].ifr_name, sizeof(ifr[mclpool_count].ifr_name), "%dk", pool.pr_size / 1024); ifr[mclpool_count].ifr_size = pool.pr_size; mclpools_index[mclpool_count++] = i; } if (mclpool_count != MCLPOOLS) warnx("mbufs: Unable to read all %d mcl* pools", MCLPOOLS); /* add view to the engine */ for (v = views_mb; v->name != NULL; v++) add_view(v); /* finally read it once */ read_mb(); return(1); }
void MainWindow::create_welcome_view() { View *view = new WelcomeView(workspace, this); view->set_closable(false); add_view(view); }
void MainWindow::create_ico_creator_view() { add_view(new IcoCreatorView(workspace, this)); }
void MainWindow::create_css_packer_view() { add_view(new CssPackerView(workspace, this)); }
StaticLstmLayer::FwdState::FwdState(size_t, size_t n_cells, size_t n_batches, size_t time) : //Views on all activations S_last(NULL, n_cells/2, n_batches, time), // Cell states from previous layer (NEW!) Ia(NULL, n_cells/2, n_batches, time), Ib(NULL, n_cells/2, n_batches, time), //!< Input gate activation Fa(NULL, n_cells/2, n_batches, time), Fb(NULL, n_cells/2, n_batches, time), //!< forget gate activation Oa(NULL, n_cells/2, n_batches, time), Ob(NULL, n_cells/2, n_batches, time), //!< output gate activation Za(NULL, n_cells/2, n_batches, time), Zb(NULL, n_cells/2, n_batches, time), //!< Za =Net Activation, Zb=f(Za) S(NULL, n_cells/2, n_batches, time), //!< Sa =Cell State activations f_S(NULL, n_cells/2, n_batches, time), //!< Sa =Cell State activations // Hb(NULL, n_cells/2, n_batches, time), //!< output of LSTM block tmp1(NULL, n_cells/2, n_batches, time) // for calculating derivs { add_view("S_last", &S_last); add_view("Ia", &Ia); add_view("Ib", &Ib); add_view("Fa", &Fa); add_view("Fb", &Fb); add_view("Oa", &Oa); add_view("Ob", &Ob); add_view("Za", &Za); add_view("Zb", &Zb); add_view("S", &S); add_view("f_S", &f_S); // add_view("Hb", &Hb); add_view("tmp1", &tmp1); }
int server::process_command(view *f, uint8_t command, packet &pk) { switch (command) { case SCMD_QUIT : // delete player { dprintf("Player %d has quit\n",f->player_number); return 0; } break; case SCMD_VIEW_RESIZE : // change view area { uint32_t view_size[8]; if (pk.read((uint8_t *)view_size,8*4)!=8*4) return 0; else { f->resize_view(lltl(view_size[0]),lltl(view_size[1]),lltl(view_size[2]),lltl(view_size[3])); f->pan_x=lltl(view_size[4]); f->pan_y=lltl(view_size[5]); f->shift_down=lltl(view_size[6]); f->shift_right=lltl(view_size[7]); f->suggest.send_view=0; if (is_server) // if we are a server, tell everybody about this. { uint8_t cmd=SCMD_VIEW_RESIZE; next_out.write((uint8_t *)&cmd,1); uint16_t pn=lstl(f->player_number); next_out.write((uint8_t *)&pn,2); next_out.write((uint8_t *)view_size,8*4); } } } break; case SCMD_WEAPON_CHANGE : // change weapon { uint32_t new_weap; if (pk.read((uint8_t *)&new_weap,4)!=4) return 0; else { f->current_weapon=lltl(new_weap); f->suggest.send_weapon_change=0; if (is_server) // if we are a server, tell everybody about this. { uint8_t cmd=SCMD_WEAPON_CHANGE; next_out.write((uint8_t *)&cmd,1); uint16_t pn=lstl(f->player_number); next_out.write((uint8_t *)&pn,2); next_out.write((uint8_t *)&new_weap,4); } } } break; case SCMD_SET_INPUT : // set the input from this player { signed char inp[5]; if (pk.read((uint8_t *)inp,5)!=5) return 0; else f->set_input(inp[0],inp[1],inp[2],inp[3],inp[4]); } break; case SCMD_ADD_VIEW : { view *v=add_view(pk); if (v) { for (view *f=player_list; f && f->next; f=f->next); if (f) f->next=v; else player_list=f; } } break; case SCMD_SYNC : { uint32_t x; if (pk.read((uint8_t *)&x,4)!=4) return 0; else { uint32_t s=make_sync_uint32(); if (lltl(x)!=s) printf("Out of sync, %x!=%x\n",lltl(x),s); return 1; } } break; default : return 0; } return 1; }
int server::join_game(out_socket *os, char *name, char *server_name) { char *re="Error occurred while reading from server\n"; packet pk; if (!get_pkt(os,pk)) // read join status packet, 0 means we can't join { fputs(re,stderr); exit(0); } int32_t nfs_port; if (pk.read((uint8_t *)&nfs_port,4)!=4) { fputs(re,stderr); exit(0); } // connect_to_nfs_server(server_name,lltl(nfs_port)); pk.write((uint8_t *)name,strlen(name)+1); // send or name and see if it's ok to join in if (!send_pkt(os,pk)) { printf("Unable to write to server\n"); exit(0); } if (!get_pkt(os,pk)) // read join status packet, 0 means we can't join { fputs(re,stderr); exit(0); } uint8_t stat; if (pk.read((uint8_t *)&stat,1)!=1) { fputs(re,stderr); exit(0); } if (stat==0) { printf("Sorry, this server is refusing you (%s)\n",name); exit(0); } if (current_level) delete current_level; int32_t vs[4]={ lltl(320/2-155),lltl(200/2-95),lltl(320/2+155),lltl(200/2+70)}; pk.write((uint8_t *)vs,4*4); if (!send_pkt(os,pk)) { printf("Unable to write to server\n"); exit(0); } current_level=new level(os); if (current_level->load_failed()) { printf("Error occurred while downloading level\n"); exit(1); } if (!get_pkt(os,pk)) { printf("Unable to read views from server\n"); exit(0); } uint16_t tv; if (pk.read((uint8_t *)&tv,2)!=2) { fputs(re,stderr); exit(0); } tv=lstl(tv); view *last=NULL; for (int i=0; i<tv; i++) { if (!get_pkt(os,pk)) { fputs(re,stderr); exit(0); } view *v=add_view(pk); if (v) { printf("added view %d\n",v->player_number); if (last) last->next=v; else player_list=v; last=v; } else printf("no view created, why?\n"); } if (!get_pkt(os,pk)) { fputs(re,stderr); exit(0); } if (pk.read((uint8_t *)&rand_on,2)!=2) // read the current random seed used by the server. { fputs(re,stderr); exit(0); } rand_on=lstl(rand_on); uint16_t rtab[1024]; if (!pk.read((uint8_t *)rtab,1024*2)) { fputs(re,stderr); exit(0); } // read the rand table for (int j=0; j<1024*2; j++) if (((uint8_t *)rtab)[j]!=((uint8_t *)rtable)[j]) { printf("rtables differ on byte %d\n",j); exit(0); } if (last) { last->Drawable=1; last->connect=os; } start_running=1; is_server=0; return 1; }
void MainWindow::create_texture_packer_view() { add_view(new TexturePackerView(workspace, this)); }