Ejemplo n.º 1
0
void RepastHPCDemoModel::doSomething(){
	int whichRank = 0;
	if(repast::RepastProcess::instance()->rank() == whichRank) std::cout << " TICK " << repast::RepastProcess::instance()->getScheduleRunner().currentTick() << std::endl;

	if(repast::RepastProcess::instance()->rank() == whichRank){
		std::cout << "LOCAL AGENTS:" << std::endl;
		for(int r = 0; r < 4; r++){
			for(int i = 0; i < 10; i++){
				repast::AgentId toDisplay(i, r, 0);
				RepastHPCDemoAgent* agent = context.getAgent(toDisplay);
				if((agent != 0) && (agent->getId().currentRank() == whichRank)) std::cout << agent->getId() << " " << agent->getC() << " " << agent->getTotal() << std::endl;
			}
		}

		std::cout << "NON LOCAL AGENTS:" << std::endl;
		for(int r = 0; r < 4; r++){
			for(int i = 0; i < 10; i++){
				repast::AgentId toDisplay(i, r, 0);
				RepastHPCDemoAgent* agent = context.getAgent(toDisplay);
				if((agent != 0) && (agent->getId().currentRank() != whichRank)) std::cout << agent->getId() << " " << agent->getC() << " " << agent->getTotal() << std::endl;
			}
		}
	}
	
	std::vector<RepastHPCDemoAgent*> agents;
	context.selectAgents(repast::SharedContext<RepastHPCDemoAgent>::LOCAL, countOfAgents, agents);
	std::vector<RepastHPCDemoAgent*>::iterator it = agents.begin();
	while(it != agents.end()){
		(*it)->play(&context);
		it++;
    }

	repast::RepastProcess::instance()->synchronizeAgentStates<RepastHPCDemoAgentPackage, RepastHPCDemoAgentPackageProvider, RepastHPCDemoAgentPackageReceiver>(*provider, *receiver);

}
Ejemplo n.º 2
0
void		Input::display()
{
  sf::String	Text("", sf::Font::GetDefaultFont(), 15);
  sf::Shape	Rect;
  std::string	toDisplay(_entry);

  Rect.AddPoint(_originInput.first,
		_originInput.second,
		sf::Color(255, 255, 255),
		sf::Color(0, 0, 0));
  Rect.AddPoint(_originInput.first + _input_sizes.first,
		_originInput.second,
		sf::Color(255, 255, 255),
		sf::Color(0, 0, 0));
  Rect.AddPoint(_originInput.first + _input_sizes.first,
		_originInput.second + _input_sizes.second,
		sf::Color(255, 255, 255),
		sf::Color(0, 0, 0));
  Rect.AddPoint(_originInput.first,
		_originInput.second + _input_sizes.second,
		sf::Color(255, 255, 255),
		sf::Color(0, 0, 0));
  Rect.EnableFill(true);
  Rect.EnableOutline(true);
  Rect.SetOutlineWidth(2);
  Text.SetColor(sf::Color(128, 128, 0));
  Text.SetPosition(_originInput.first + 5, _originInput.second + 5);
  Text.SetText(_entry.substr(_cmp));
  _app->Draw(Rect);
  _app->Draw(Text);
  _app->Display();
}
Ejemplo n.º 3
0
USER_OBJECT_
RS_GGOBI(getDisplayOptions)(USER_OBJECT_ which)
{
  USER_OBJECT_ ans, names;
  gint NumOptions = 8;
  DisplayOptions *options;
  
  if (GET_LENGTH(which) == 0)
    options = GGOBI(getDefaultDisplayOptions)();
  else {
    displayd *display = toDisplay(which);
    g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
    options = &(display->options);
  }
  
  g_return_val_if_fail(options != NULL, NULL_USER_OBJECT);

  PROTECT(ans = NEW_LOGICAL(NumOptions));
  PROTECT(names = NEW_CHARACTER(NumOptions));

  LOGICAL_DATA(ans)[DOPT_POINTS] = options->points_show_p;
  SET_STRING_ELT(names, DOPT_POINTS, COPY_TO_USER_STRING("Show points"));
  LOGICAL_DATA(ans)[DOPT_AXES] = options->axes_show_p;
  SET_STRING_ELT(names, DOPT_AXES,  COPY_TO_USER_STRING("Show axes"));

  LOGICAL_DATA(ans)[DOPT_AXESLAB] = options->axes_label_p;
  SET_STRING_ELT(names, DOPT_AXESLAB,
    COPY_TO_USER_STRING("Show tour axes"));
  LOGICAL_DATA(ans)[DOPT_AXESVALS] = options->axes_values_p;
  SET_STRING_ELT(names, DOPT_AXESVALS,
    COPY_TO_USER_STRING("Show axes labels"));

  LOGICAL_DATA(ans)[DOPT_EDGES_U] = options->edges_undirected_show_p;
  SET_STRING_ELT(names, DOPT_EDGES_U, COPY_TO_USER_STRING("Undirected edges"));
  LOGICAL_DATA(ans)[DOPT_EDGES_A] = options->edges_arrowheads_show_p;
  SET_STRING_ELT(names, DOPT_EDGES_A, COPY_TO_USER_STRING("Arrowheads"));
  LOGICAL_DATA(ans)[DOPT_EDGES_D] = options->edges_directed_show_p;
  SET_STRING_ELT(names, DOPT_EDGES_D, COPY_TO_USER_STRING("Directed edges"));

  LOGICAL_DATA(ans)[DOPT_WHISKERS] = options->whiskers_show_p;
  SET_STRING_ELT(names, DOPT_WHISKERS,
    COPY_TO_USER_STRING("Show whiskers"));

/* unused
  LOGICAL_DATA(ans)[5] = options->missings_show_p;
  SET_STRING_ELT(names, 5, COPY_TO_USER_STRING("Missing Values"));
  LOGICAL_DATA(ans)[8] = options->axes_center_p;
  SET_STRING_ELT(names, 8,  COPY_TO_USER_STRING("Center axes"));
  LOGICAL_DATA(ans)[9] = options->double_buffer_p;
  SET_STRING_ELT(names, 9,  COPY_TO_USER_STRING("Double buffer"));
  LOGICAL_DATA(ans)[10] = options->link_p;
  SET_STRING_ELT(names, 10,  COPY_TO_USER_STRING("Link"));
*/

  SET_NAMES(ans, names);

  UNPROTECT(2);

  return(ans);
}
Ejemplo n.º 4
0
USER_OBJECT_
RS_GGOBI(getTourProjection)(USER_OBJECT_ s_display, USER_OBJECT_ s_mode_name)
{
	displayd *display = toDisplay(s_display);
  ProjectionMode mode = GGOBI(getPModeId)(asCString(s_mode_name));
  gint k, n;
  USER_OBJECT_ matrix;
  gdouble *x = NULL, *y = NULL;
  
  g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  RS_INTERNAL_GGOBI(getTourVectorsFromMode)(display, mode, &x, &y);
  g_return_val_if_fail(x != NULL, NULL_USER_OBJECT);
  
  n = display->d->ncols;
  PROTECT(matrix = allocMatrix(REALSXP, n, 3));
  for (k = 0; k < n; k++) {
    vartabled *vt = vartable_element_get (k, display->d);
    REAL(matrix)[k] = x[k]; /* x coeff */
    if (y)
      REAL(matrix)[k+n] = y[k]; /* y coeff */
    else REAL(matrix)[k+n] = 0;
    REAL(matrix)[k+2*n] = vt->lim.max - vt->lim.min; /* range */
  }
  
  UNPROTECT(1);
  
  return matrix;
}
Ejemplo n.º 5
0
/* Expects a 2 column matrix with the X and Y coefficients for each var */
USER_OBJECT_
RS_GGOBI(setTourProjection)(USER_OBJECT_ s_display, USER_OBJECT_ s_mode_name,
  USER_OBJECT_ matrix)
{
  displayd *display = toDisplay(s_display);
  ProjectionMode mode = GGOBI(getPModeId)(asCString(s_mode_name));
  gint k, n;
  gdouble *x = NULL, *y = NULL;
  
  g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  RS_INTERNAL_GGOBI(getTourVectorsFromMode)(display, mode, &x, &y);
  g_return_val_if_fail(x != NULL, NULL_USER_OBJECT);
  
  n = display->d->ncols;
  for (k = 0; k < n; k++) {
    x[k] = REAL(matrix)[k];
    if (y)
      y[k] = REAL(matrix)[k+n];
  }
  
  display_tailpipe (display, FULL, display->ggobi);
  varcircles_refresh (display->d, display->ggobi);
  
  return NULL_USER_OBJECT;
}
Ejemplo n.º 6
0
/*
  Allows the R user to set the variables within a given display
 */
USER_OBJECT_
RS_GGOBI(setDisplayVariables)(USER_OBJECT_ vars, USER_OBJECT_ varPrev, USER_OBJECT_ dpy)
{
  displayd *display, *prev_display;
  USER_OBJECT_ ans = NULL_USER_OBJECT;

  display = toDisplay(dpy);
	g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  /* ensure that display is current before changing variables */
  prev_display = display->ggobi->current_display;
  display_set_current(display, display->ggobi);
  
  /* If any of the requested variables AREN'T selected, select them */
  toggle_display_variables(display, vars, false);
  varpanel_refresh(display, display->ggobi);
  /* If any of the obsolete variables ARE still selected, select (toggle) them */
  toggle_display_variables(display, varPrev, true);
  
  /* refresh everything */
  varpanel_refresh(display, display->ggobi);
  display_tailpipe(display, FULL,  display->ggobi);
  while(gtk_events_pending()) /* ensure display is redrawn */
    gtk_main_iteration();
  
  /* revert to previously selected display */
  display_set_current(prev_display, prev_display->ggobi);
  
  return(ans);
}
Ejemplo n.º 7
0
USER_OBJECT_
RS_GGOBI(getDisplayVariables)(USER_OBJECT_ dpy)
{
  USER_OBJECT_ buttons, vars, ans;
  static gchar *button_names[] = { "X", "Y", "Z" };
  gint i;
  
  displayd *display = toDisplay(dpy);
  
  /* get the currently plotted variables */
  gint *plotted_vars = g_new (gint, display->d->ncols);
  gint nplotted_vars = GGOBI_EXTENDED_DISPLAY_GET_CLASS (display)->plotted_vars_get(
    display, plotted_vars, display->d, display->ggobi);
    
  PROTECT(ans = NEW_LIST(2));
  buttons = NEW_CHARACTER(nplotted_vars);
  SET_VECTOR_ELT(ans, 1, buttons);
  vars = NEW_INTEGER(nplotted_vars);
  SET_VECTOR_ELT(ans, 0, vars);
  
  for (i = 0; i < nplotted_vars; i++) {
    gint var = plotted_vars[i], j;
    for (j = 0; j < G_N_ELEMENTS(button_names); j++) {
      GtkWidget *wid = varpanel_widget_get_nth(j, var, display->d);
      if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(wid)))
        SET_STRING_ELT(buttons, i, mkChar(button_names[j]));
    }
    INTEGER_DATA(vars)[i] = var;
  }
  
  UNPROTECT(1);
  g_free(plotted_vars);
  
  return(ans);
}
Ejemplo n.º 8
0
/* Ideally the GGobi would be a property of the display, allowing access
  with RGtk2, but this is not so... */
USER_OBJECT_
RS_GGOBI(getGGobiForDisplay)(USER_OBJECT_ s_display)
{
  displayd *display = toDisplay(s_display);
  g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  return RS_ggobiInstance(display->ggobi);
}
Ejemplo n.º 9
0
USER_OBJECT_
RS_GGOBI(getDisplayWidget)(USER_OBJECT_ r_display) {
  displayd *display  = (displayd *) toDisplay(r_display);
  GtkWidget *widget = GTK_WIDGET(display);
  if (GGOBI_IS_WINDOW_DISPLAY(display) &&
      GGOBI_WINDOW_DISPLAY(display)->useWindow)
    widget = gtk_bin_get_child(GTK_BIN(GGOBI_WINDOW_DISPLAY(display)->window));
  return toRPointer(widget, "GtkWidget");
}
Ejemplo n.º 10
0
USER_OBJECT_
RS_GGOBI(getDisplayDataset)(USER_OBJECT_ dpy)
{
 displayd * display;
 USER_OBJECT_ ans;

  display = toDisplay(dpy);
	g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  ans = RS_datasetInstance(display->d);
  return(ans);
}
void AMCurrentAmplifierSingleView::onAmplifierValueChanged()
{
	if (isValid()) {
		amplifier_->blockSignals(true);

		int newIndex = value_->findText( toDisplay(amplifier_->value(), amplifier_->units()) );

		if (newIndex != -1)
			value_->setCurrentIndex(newIndex);

		amplifier_->blockSignals(false);
	}
}
Ejemplo n.º 12
0
MyRoom::MyRoom(Server *server):QObject()
{
    backEngine = new BackgroundEngine();
    testUI = new TestUIex(NULL);
    this->serverModule = server;

    engineThr = new MyThread;
    backEngine->moveToThread(engineThr);
    engineThr->start();

    //connect(backEngine,SIGNAL(askForActSIG(QList<CardEntity*>,int)),testUI,SLOT(actSLOT(QList<CardEntity*>,int)));
    //connect(backEngine,SIGNAL(askForReply(QList<CardEntity*>,QString,int)),testUI,SLOT(replySLOT(QList<CardEntity*>,QString,int)));
    //connect(backEngine,SIGNAL(askForHeal(int,int)),testUI,SLOT(healSLOT(int,int)));
    connect(backEngine,SIGNAL(toInforDisplay(QString)),testUI,SLOT(toDisplay(QString)));

    connect(serverModule,SIGNAL(seatArrangeSIG()),backEngine,SLOT(seatArrange()));
    connect(serverModule,SIGNAL(seatPrearrangeSIG(int,int,QString)),backEngine,SLOT(seatPrearrange(int,int,QString)));
    connect(this->serverModule,SIGNAL(toDisplay(QString)),this->testUI,SLOT(toDisplay(QString)));
    connect(backEngine,SIGNAL(sendMessageSIG(int,QString)),this->serverModule,SLOT(sendMessage(int,QString)));
    connect(&coder,SIGNAL(sendMessage(int,QString)),this->serverModule,SLOT(sendMessage(int,QString)));

    switch(serverModule->getRoleStrategy())
    {
    case 0:
        connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(roleRandom()));
        break;
    case 1:
        connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine,SLOT(role3Pick1()));
        connect(serverModule,SIGNAL(role3Pick1ReplySIG(int,int)),backEngine,SLOT(role3Pick1Reply(int,int)));
        connect(serverModule,SIGNAL(gameStartSIG()),this->backEngine,SLOT(gameStart()));
        connect(this->serverModule,SIGNAL(roleNoticeSIG()),backEngine,SLOT(seatPostarrange()));
        break;
    case 2:
        connect(this->serverModule,SIGNAL(roleStrategySIG()),backEngine, SLOT(BP()));
    }

//    emit this->serverModule->toDisplayPublic("server IP:" + this->serverModule->serverAddress().toString());
    emit this->serverModule->toDisplayPublic("server port:" + QString::number(this->serverModule->serverPort()));
}
Ejemplo n.º 13
0
USER_OBJECT_
RS_GGOBI(getNumPlotsInDisplay)(USER_OBJECT_ dpy)
{
  displayd *display;
  gint len;
  
  USER_OBJECT_ ans = NEW_INTEGER(1);
  display = toDisplay(dpy);
	g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  len = g_list_length(display->splots);
  INTEGER_DATA(ans)[0] = len;

  return(ans);
}
Ejemplo n.º 14
0
void QActivityMonitor::display(QString message)
{
    QString toDisplay("(");
    toDisplay.append(time.currentTime().toString("hh:mm:ss"));
    toDisplay.append(")");
    toDisplay.append(" ");
    toDisplay.append(message);

    activityDisplay->append(toDisplay);

    if(autoscroll)
    {
        QTextCursor c = activityDisplay->textCursor();
        c.movePosition(QTextCursor::End);
        activityDisplay->setTextCursor(c);
    }
}
Ejemplo n.º 15
0
/**
 This is called when we have reset all the variables in the different
 splots within a display.
 The intent is that this will recompute everything, including the 
 positions of the points/glyphs. Currently this is not doing that.
 Need to call some other method.
 */
USER_OBJECT_
RS_GGOBI(updateDisplay)(USER_OBJECT_ dpy, USER_OBJECT_ ggobiId)
{
  USER_OBJECT_ ans = NEW_LOGICAL(1);
  ggobid *gg;
  displayd *display;  

  gg = toGGobi(ggobiId);
  g_return_val_if_fail(GGOBI_IS_GGOBI(gg), NULL_USER_OBJECT);
  display = toDisplay(dpy);
  g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  display_tailpipe(display, FULL,  gg);
  
  LOGICAL_DATA(ans)[0] = TRUE;
  return(ans);
}
Ejemplo n.º 16
0
USER_OBJECT_
RS_GGOBI(setDisplayOptions)(USER_OBJECT_ which, USER_OBJECT_ values)
{
  gint i;
  DisplayOptions *options;
  displayd *display = NULL;
  int apply = 0;

  g_return_val_if_fail(GET_LENGTH(values) == 8, NULL_USER_OBJECT);
  
  if(GET_LENGTH(which) == 0) {
     options = GGOBI(getDefaultDisplayOptions)();
  } else {
     display = toDisplay(which);
     g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
     options = &(display->options);
     g_return_val_if_fail(options != NULL, NULL_USER_OBJECT);
     apply = 1;
  }
  
  i = 0;
  options->points_show_p = LOGICAL_DATA(values)[i++];
  options->axes_show_p = LOGICAL_DATA(values)[i++];
  options->axes_label_p = LOGICAL_DATA(values)[i++];
  options->axes_values_p = LOGICAL_DATA(values)[i++];
  options->edges_undirected_show_p = LOGICAL_DATA(values)[i++];
  options->edges_arrowheads_show_p = LOGICAL_DATA(values)[i++];
  options->edges_directed_show_p = LOGICAL_DATA(values)[i++];
  options->whiskers_show_p = LOGICAL_DATA(values)[i++];
/* unused
  options->missings_show_p = LOGICAL_DATA(values)[i++];
  options->axes_center_p = LOGICAL_DATA(values)[i++];
  options->double_buffer_p = LOGICAL_DATA(values)[i++];
  options->link_p = LOGICAL_DATA(values)[i++];
*/

  if(apply) {
    set_display_options(display, display->ggobi);
  }

  return (NULL_USER_OBJECT);
}
Ejemplo n.º 17
0
Archivo: plots.c Proyecto: cran/rggobi
/* Sets a plot as the active plot given a display and a plot index */
USER_OBJECT_
RS_GGOBI(setActivePlot)(USER_OBJECT_ s_display, USER_OBJECT_ s_plot)
{
  USER_OBJECT_ ans = NEW_LOGICAL(1);
  displayd *display;
  splotd *sp;
  
  display = toDisplay(s_display);
  g_return_val_if_fail(GGOBI_IS_DISPLAY(display), NULL_USER_OBJECT);
  
  display_set_current(display, display->ggobi);

  sp = GGOBI(getPlot)(display, INTEGER_DATA(s_plot)[0]);
  g_return_val_if_fail(sp != NULL, NULL_USER_OBJECT);
  GGOBI(splot_set_current_full)(display, sp, display->ggobi);
  LOGICAL_DATA(ans)[0] = 1;

  gdk_flush();
   
  return (ans);
}
void AMCurrentAmplifierCompositeView::refreshValues()
{
	value_->clear();

	double minValue = 0;
	double maxValue = 0;

	// (re)populate value_ with appropriate options provided by the amplifier.
	QStringList unitsList = amplifier1_->unitsList();
	QList<double> valuesList = amplifier1_->values();

	foreach (QString units, unitsList) {
		foreach (double value, valuesList) {

			minValue = amplifier1_->minimumValueForUnits(units);
			maxValue = amplifier1_->maximumValueForUnits(units);

			if (value >= minValue && value <= maxValue) {
				QString item = toDisplay(value, units);
				value_->addItem(item);
			}
		}