Ejemplo n.º 1
0
GLUI_RadioButton *GLUI::add_radiobutton_to_group(  GLUI_RadioGroup *group,
						   char *name )
{
  GLUI_RadioButton *control;

  if ( group->type != GLUI_CONTROL_RADIOGROUP ) {
    /*fprintf( stderr, "ERROR: Trying to add radiobutton to non-radiogroup\n" );              */
    /*fflush( stderr );              */
    return NULL;
  }

  control = new GLUI_RadioButton;

  if ( control ) {
    control->set_int_val( 0 );
    /*int_val = 0;              */

    /** A radio button's user id is always its ordinal number (zero-indexed)
      within the group */
    control->user_id    = group->num_buttons;
    group->num_buttons++;   /* Increments radiogroup's button count */
    control->set_name( name );
    control->group = group;

    add_control( group, control );

    /*** Now update button states ***/
    group->set_int_val( group->int_val ); /* This tells the group to
					     reset itself to its
					     current value, thereby
					     updating all its buttons */

    return control;
  }
  else {
    return NULL;
  }

}
Ejemplo n.º 2
0
GLUI_Translation   
   *GLUI::add_translation_to_panel( 
				   GLUI_Panel *panel, char *name, 
				   int trans_type, float *value_ptr,
				   int id, GLUI_Update_CB callback )
{
  GLUI_Translation *control;

  control = new GLUI_Translation;

  if ( control ) {
    control->set_ptr_val( value_ptr );
    control->user_id    = id;
    control->set_name( name );
    control->callback    = callback;
    add_control( panel, control );
    control->init_live();

    control->trans_type = trans_type;

    if ( trans_type == GLUI_TRANSLATION_XY ) {
      control->float_array_size = 2;
    }
    else if ( trans_type == GLUI_TRANSLATION_X ) {
      control->float_array_size = 1;
    }
    else if ( trans_type == GLUI_TRANSLATION_Y ) {
      control->float_array_size = 1;
    }
    else if ( trans_type == GLUI_TRANSLATION_Z ) {
      control->float_array_size = 1;
    }

    return control;
  }
  else {
    return NULL;
  }
}
Ejemplo n.º 3
0
GLUI_Rollout *GLUI::add_rollout_to_panel(GLUI_Panel *panel,char *name,int open)
{
  GLUI_Rollout     *rollout;
  
  rollout = new GLUI_Rollout;

  if ( rollout ) {
    rollout->set_name( name );
    rollout->user_id    = -1;
    rollout->int_val    = GLUI_PANEL_EMBOSSED;
		
    if ( NOT open ) {
      rollout->is_open = false;
      rollout->h = GLUI_DEFAULT_CONTROL_HEIGHT + 7;
    }

    add_control( panel, rollout );

    return rollout;
  }
  else {
    return NULL;
  }  
}
//======================================================================
void sccan_point_pair_handler::
interaction(){
	
	std::string key_user_wants_to_take_more_sccan_points  ="m";
	std::string key_show_list_of_sccan_points_in_current_directory ="s";
	std::string key_reset_exposure_times ="r";
	std::string key_show_star_position_indicator_image ="i";
	std::string key_modify_sigma_threshold ="sigma";
	std::string key_modify_recognition_radius ="radius";
	std::string key_user_wants_to_end_taking_sccan_points  ="back";
	std::string key_modify_star_cam_desired_max_rel_respone  ="star_cr";	
	std::string key_modify_refl_cam_desired_max_rel_respone  ="refl_cr";
	std::string key_max_valid_exposure_time = "max_exp";
		
	add_control(key_user_wants_to_take_more_sccan_points,
	"aquire >N< additional sccan points");
	
	add_control
	(key_show_list_of_sccan_points_in_current_directory,
	"show list of sccan_points in current directory");

	add_control
	(key_show_star_position_indicator_image,
	"show star position indicator image");

	add_control
	(key_reset_exposure_times,
	"reset exposure times of cameras");
	
	add_control
	(key_modify_sigma_threshold,
	"modify sigma threshold");
	
	add_control
	(key_modify_recognition_radius,
	"modify recognition radius");	
	
	add_control
	(key_modify_star_cam_desired_max_rel_respone,
	"modify star camera max desired rel. respone");

	add_control
	(key_modify_refl_cam_desired_max_rel_respone,
	"modify reflector camera max desired rel. respone");
	
	add_control
	(key_user_wants_to_end_taking_sccan_points,
	"back to main menu");	

	add_control(key_max_valid_exposure_time,
	"set max valid exposure time");
	
	std::string user_input;
	
	std::stringstream out;
	
	bool flag_user_wants_to_acquire_sccan_points = true;
	
	do{
	//==============================================================
	// prompt snapshot options to command line
	//==============================================================
	update_list_of_runs_in_current_directory();
	update_status_prompt(get_prompt());
	//==============================================================
	// get input of user via command line
	//==============================================================
	get_user_input();
	//==============================================================
	// interpret answer of user
	//==============================================================
	//std::cout<<"valid_user_input: "<<valid_user_input<<std::endl;	
	//==============================================================
	if(valid_user_input.compare
	(key_user_wants_to_end_taking_sccan_points)==0){
		flag_user_wants_to_acquire_sccan_points = false;
	}
	//==================================================================
	if(valid_user_input.compare
	(key_user_wants_to_take_more_sccan_points)==0){
		int number_of_sccan_points_to_be_acquired = ask_user_for_integer
		("Enter number of sccan points to be acquired",0,1e4);
		acquire_sccan_points(number_of_sccan_points_to_be_acquired);
	}
	//==================================================================
	if(valid_user_input.compare(
	key_show_list_of_sccan_points_in_current_directory)==0){
		disp_list_of_sccan_points_in_current_directory();
	}
	//==================================================================
	if(valid_user_input.compare(key_modify_sigma_threshold)==0){
		threshold_in_sigmas_for_star_detection =
		ask_user_for_non_zero_float(
		"Enter threshold for star detection in sigmas of image noise",
		0.0,100.0);
	}
	//==================================================================
	if(valid_user_input.compare(key_modify_recognition_radius)==0){
		star_recognition_one_sigma_radius_in_degrees =
		ask_user_for_non_zero_float
		("Enter new star recognition radius",0.0,180.0);
	}
	//==================================================================
	if(
	valid_user_input.compare(key_show_star_position_indicator_image)==0)
	{
		display_star_position_indicator_image();
	}
	//==================================================================
	if(valid_user_input.compare(key_reset_exposure_times)==0){
		reset_exposure_times();
	}	
	//==================================================================
	if(valid_user_input.compare(
	key_modify_star_cam_desired_max_rel_respone)==0){
		star_camera_desired_max_relative_camera_response = 
		ask_user_for_non_zero_float(
		"enter new relative star camera response (0,1)",0.01,0.99);
	}
	//==================================================================
	if(valid_user_input.compare(
	key_modify_refl_cam_desired_max_rel_respone)==0){
		reflector_camera_desired_max_relative_camera_response = 
		ask_user_for_non_zero_float(
		"enter new relative reflector camera response (0,1)",0.01,0.99);
	}
	//==================================================================
	if(valid_user_input.compare(
	key_max_valid_exposure_time)==0){
		max_exposure_time_until_sccan_point_is_not_valid_anymore = 
		ask_user_for_non_zero_float(
		"enter new maximal valid exposure time [ms]",0.01,60000);
	}
	//==================================================================
}while(flag_user_wants_to_acquire_sccan_points);	
}
Ejemplo n.º 5
0
/**
  process command line options
*/
struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, 
					int argc, const char **argv,
					void (*usage)(struct ldb_context *))
{
	struct ldb_cmdline *ret=NULL;
	poptContext pc;
	int num_options = 0;
	int opt;
	unsigned int flags = 0;
	int rc;
	struct poptOption **popt_options;

	/* make the ldb utilities line buffered */
	setlinebuf(stdout);

	ret = talloc_zero(ldb, struct ldb_cmdline);
	if (ret == NULL) {
		fprintf(stderr, "Out of memory!\n");
		goto failed;
	}

	options = *ret;
	
	/* pull in URL */
	options.url = getenv("LDB_URL");

	/* and editor (used by ldbedit) */
	options.editor = getenv("VISUAL");
	if (!options.editor) {
		options.editor = getenv("EDITOR");
	}
	if (!options.editor) {
		options.editor = "vi";
	}

	options.scope = LDB_SCOPE_DEFAULT;

	popt_options = ldb_module_popt_options(ldb);
	(*popt_options) = builtin_popt_options;

	rc = ldb_modules_hook(ldb, LDB_MODULE_HOOK_CMDLINE_OPTIONS);
	if (rc != LDB_SUCCESS) {
		fprintf(stderr, "ldb: failed to run command line hooks : %s\n", ldb_strerror(rc));
		goto failed;
	}

	pc = poptGetContext(argv[0], argc, argv, *popt_options,
			    POPT_CONTEXT_KEEP_FIRST);

	while((opt = poptGetNextOpt(pc)) != -1) {
		switch (opt) {
		case 's': {
			const char *arg = poptGetOptArg(pc);
			if (strcmp(arg, "base") == 0) {
				options.scope = LDB_SCOPE_BASE;
			} else if (strcmp(arg, "sub") == 0) {
				options.scope = LDB_SCOPE_SUBTREE;
			} else if (strcmp(arg, "one") == 0) {
				options.scope = LDB_SCOPE_ONELEVEL;
			} else {
				fprintf(stderr, "Invalid scope '%s'\n", arg);
				goto failed;
			}
			break;
		}

		case 'v':
			options.verbose++;
			break;

		case 'o':
			options.options = talloc_realloc(ret, options.options, 
							 const char *, num_options+3);
			if (options.options == NULL) {
				fprintf(stderr, "Out of memory!\n");
				goto failed;
			}
			options.options[num_options] = poptGetOptArg(pc);
			options.options[num_options+1] = NULL;
			num_options++;
			break;

		case 'c': {
			const char *cs = poptGetOptArg(pc);
			const char *p;

			for (p = cs; p != NULL; ) {
				const char *t, *c;

				t = strchr(p, ',');
				if (t == NULL) {
					c = talloc_strdup(options.controls, p);
					p = NULL;
				} else {
					c = talloc_strndup(options.controls, p, t-p);
			        	p = t + 1;
				}
				if (c == NULL || !add_control(ret, c)) {
					fprintf(stderr, __location__ ": out of memory\n");
					goto failed;
				}
			}

			break;	  
		}
		case 'P':
			if (!add_control(ret, "paged_results:1:1024")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'D':
			if (!add_control(ret, "show_deleted:1")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'R':
			if (!add_control(ret, "show_recycled:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'd':
			if (!add_control(ret, "show_deactivated_link:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'r':
			if (!add_control(ret, "reveal_internals:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case CMDLINE_RELAX:
			if (!add_control(ret, "relax:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'N':
			if (!add_control(ret, "search_options:1:2")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'E':
			if (!add_control(ret, "extended_dn:1:1")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		default:
			fprintf(stderr, "Invalid option %s: %s\n", 
				poptBadOption(pc, 0), poptStrerror(opt));
			if (usage) usage(ldb);
			goto failed;
		}
	}

	/* setup the remaining options for the main program to use */
	options.argv = poptGetArgs(pc);
	if (options.argv) {
		options.argv++;
		while (options.argv[options.argc]) options.argc++;
	}

	*ret = options;

	/* all utils need some option */
	if (ret->url == NULL) {
		fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n");
		if (usage) usage(ldb);
		goto failed;
	}

	if (strcmp(ret->url, "NONE") == 0) {
		return ret;
	}

	if (options.nosync) {
		flags |= LDB_FLG_NOSYNC;
	}

	if (options.show_binary) {
		flags |= LDB_FLG_SHOW_BINARY;
	}

	if (options.tracing) {
		flags |= LDB_FLG_ENABLE_TRACING;
	}

	if (options.modules_path != NULL) {
		ldb_set_modules_dir(ldb, options.modules_path);
	}

	rc = ldb_modules_hook(ldb, LDB_MODULE_HOOK_CMDLINE_PRECONNECT);
	if (rc != LDB_SUCCESS) {
		fprintf(stderr, "ldb: failed to run preconnect hooks : %s\n", ldb_strerror(rc));
		goto failed;
	}

	/* now connect to the ldb */
	if (ldb_connect(ldb, ret->url, flags, ret->options) != LDB_SUCCESS) {
		fprintf(stderr, "Failed to connect to %s - %s\n", 
			ret->url, ldb_errstring(ldb));
		goto failed;
	}

	rc = ldb_modules_hook(ldb, LDB_MODULE_HOOK_CMDLINE_POSTCONNECT);
	if (rc != LDB_SUCCESS) {
		fprintf(stderr, "ldb: failed to run post connect hooks : %s\n", ldb_strerror(rc));
		goto failed;
	}

	return ret;

failed:
	talloc_free(ret);
	exit(LDB_ERR_OPERATIONS_ERROR);
	return NULL;
}
Ejemplo n.º 6
0
TestMRPPWindow::TestMRPPWindow(HWND parent, std::string title) : MRPWindow(parent, title)
{
	for (int i = 0; i < 8; ++i)
	{
		auto but = std::make_shared<WinButton>(this, std::to_string(i));
		but->GenericNotifyCallback = [i](GenericNotifications)
		{
			readbg() << "you pressed " << i << "\n";
		};
		add_control(but);
	}
	// Button 0 toggless enabled state of button 1
	m_controls[0]->GenericNotifyCallback = [this](GenericNotifications)
	{
		m_controls[1]->setEnabled(!m_controls[1]->isEnabled());
	};
	m_envcontrol1 = std::make_shared<EnvelopeControl>(this);

	// Button 3 toggless enabled state of envelope control
	m_controls[3]->GenericNotifyCallback = [this](GenericNotifications)
	{
		m_envcontrol1->setEnabled(!m_envcontrol1->isEnabled());
	};

	// Button 7 toggless visible state of button 0
	m_controls[7]->GenericNotifyCallback = [this](GenericNotifications)
	{
		m_controls[0]->setVisible(!m_controls[0]->isVisible());
	};
	auto env = std::make_shared<breakpoint_envelope>("foo", LICE_RGBA(255, 255, 255, 255));
	env->add_point({ 0.0, 0.5 , envbreakpoint::Power, 0.5 }, true);
	env->add_point({ 0.5, 0.0 , envbreakpoint::Power, 0.5 }, true);
	env->add_point({ 1.0, 0.5 }, true);
	m_envcontrol1->add_envelope(env);

	m_envcontrol1->GenericNotifyCallback = [this, env](GenericNotifications reason)
	{
		//if (reason == GenericNotifications::AfterManipulation)
		//	generate_items_sequence(env, m_edit1->getText().c_str());
	};

	add_control(m_envcontrol1);

	// Button 5 does some Xenakios silliness
	m_controls[5]->GenericNotifyCallback = [this, env](GenericNotifications)
	{
		generate_items_sequence(env, m_edit1->getText().c_str());
	};

	m_label1 = std::make_shared<WinLabel>(this, "This is a label");
	add_control(m_label1);

	m_edit1 = std::make_shared<WinLineEdit>(this, "C:/MusicAudio/pihla_ei/ei_mono_005.wav");
	add_control(m_edit1);
	m_edit1->TextCallback = [this](std::string txt)
	{
		m_label1->setText(txt);
	};
	// Button 6 launches bogus work in another thread to demo progress bar
	m_controls[6]->GenericNotifyCallback = [this](GenericNotifications)
	{
		m_progressbar1->setVisible(true);
		// we don't deal with multiple background tasks now, so disable the button to start the task
		m_controls[6]->setEnabled(false);
		static int rseed = 0;
		auto task = [this](int randseed)
		{
			std::mt19937 randgen(randseed);
			std::uniform_real_distribution<double> randdist(0.0, 1.0);
			double accum = 0.0;
			const int iterations = 50000000;
			double t0 = time_precise();
			for (int i = 0; i < iterations; ++i)
			{
				accum += randdist(randgen);
				//accum += randdist(randgen);
				// Production code should not do this at this granularity, because setProgressValue deals with
				// an atomic value. but this is just a demo...
				m_progressbar1->setProgressValue(1.0 / iterations*i);
			}
			double t1 = time_precise();
			auto finishtask = [=]()
			{
				m_edit1->setText(std::to_string(accum) + " elapsed time " + std::to_string(t1-t0));
				m_progressbar1->setProgressValue(0.0);
				m_progressbar1->setVisible(false);
				m_controls[6]->setEnabled(true);
			};
			execute_in_main_thread(finishtask);
		};
		m_future1 = std::async(std::launch::async, task, rseed);
		++rseed;
	};
	// Button 1 shows popup menu
	m_controls[1]->GenericNotifyCallback = [this, env](GenericNotifications)
	{
		PopupMenu popmenu(getWindowHandle());
		popmenu.add_menu_item("Menu entry 1", [](PopupMenu::CheckState) {});
		popmenu.add_menu_item("Menu entry 2", m_menuitem2state, [this](PopupMenu::CheckState cs)
		{
			m_menuitem2state = cs;
		});
		popmenu.add_menu_item("Menu entry 3", m_menuitem3state, [this](PopupMenu::CheckState cs) 
		{
			m_menuitem3state = cs;
		});
		PopupMenu submenu(getWindowHandle());
		submenu.add_menu_item("Submenu entry 1", [](PopupMenu::CheckState) { readbg() << "submenu entry 1\n"; });
		submenu.add_menu_item("Submenu entry 2", [](PopupMenu::CheckState) { readbg() << "submenu entry 2\n"; });
		PopupMenu subsubmenu(getWindowHandle());
		for (int i = 0; i < 8; ++i)
		{
			subsubmenu.add_menu_item(std::string("Subsubmenu entry ") + std::to_string(i + 1), [i](PopupMenu::CheckState) 
			{
				readbg() << "subsubmenu entry " << i + 1 << "\n";
			});
		}
		submenu.add_submenu("Going still deeper", subsubmenu);
		popmenu.add_submenu("More stuff", submenu);
		popmenu.execute(m_controls[1]->getXPosition(), m_controls[1]->getYPosition());
	};
	// Button 4 removes envelope points with value over 0.5
	m_controls[4]->GenericNotifyCallback = [this, env](GenericNotifications)
	{
		env->remove_points_conditionally([](const envbreakpoint& pt)
		{ return pt.get_y() > 0.5; });
		m_envcontrol1->repaint();
	};
	m_combo1 = std::make_shared<WinComboBox>(this);
	m_combo1->addItem("Apple", -9001);
	m_combo1->addItem("Pear", 666);
	m_combo1->addItem("Kiwi", 42);
	m_combo1->addItem("Banana", 100);
	m_combo1->SelectedChangedCallback = [this](int index)
	{
		int user_id = m_combo1->userIDfromIndex(index);
		readbg() << "combo index " << index << " userid " << user_id << "\n";
	};
	add_control(m_combo1);
	m_combo1->setSelectedUserID(42);

	m_combo2 = std::make_shared<WinComboBox>(this);
	m_combo2->addItem("Item 1", 100);
	m_combo2->addItem("Item 2", 101);
	m_combo2->addItem("Item 3", 102);
	m_combo2->addItem("Item 4", 103);
	m_combo2->SelectedChangedCallback = [this](int index)
	{
		int user_id = m_combo2->userIDfromIndex(index);
		readbg() << "combo index " << index << " userid " << user_id << "\n";
	};
	add_control(m_combo2);
	m_combo2->setSelectedIndex(0);

	m_slider1 = std::make_shared<ReaSlider>(this, 0.5);
	//m_slider1->setValueConverter(std::make_shared<FFTSizesValueConverter>());
	m_slider1->SliderValueCallback = [this](GenericNotifications, double x)
	{
		m_label1->setText(std::to_string(x));
		m_progressbar1->setProgressValue(x);
	};
	add_control(m_slider1);
	m_zoomscroll1 = std::make_shared<ZoomScrollBar>(this);
	add_control(m_zoomscroll1);
	m_zoomscroll1->RangeChangedCallback = [this](double t0, double t1)
	{
		m_envcontrol1->setViewTimeRange(t0, t1);
	};

	m_progressbar1 = std::make_shared<ProgressControl>(this);
	m_progressbar1->setVisible(false);
}
Ejemplo n.º 7
0
SimpleExampleWindow::SimpleExampleWindow(HWND parent, std::string title) : MRPWindow(parent,title)
{
	m_last_project_change_count = GetProjectStateChangeCount(nullptr);
	m_but1 = std::make_shared<WinButton>(this, "Get take name");
	m_but1->GenericNotifyCallback = [this](GenericNotifications)
	{
		if (CountSelectedMediaItems(nullptr) > 0)
		{
			MediaItem* item = GetSelectedMediaItem(nullptr, 0);
			MediaItem_Take* take = GetActiveTake(item);
			if (take != nullptr)
			{
				char buf[2048];
				GetSetMediaItemTakeInfo_String(take, "P_NAME", buf, false);
				m_edit1->setText(buf);
			}
		}
	};
	add_control(m_but1);
	m_but2 = std::make_shared<WinButton>(this, "Set take name");
	m_but2->GenericNotifyCallback = [this](GenericNotifications)
	{
		if (CountSelectedMediaItems(nullptr) > 0)
		{
			MediaItem* item = GetSelectedMediaItem(nullptr, 0);
			MediaItem_Take* take = GetActiveTake(item);
			if (take != nullptr)
			{
				GetSetMediaItemTakeInfo_String(take, "P_NAME", (char*)m_edit1->getText().c_str(), true);
				UpdateArrange();
			}
		}
	};
	add_control(m_but2);
	
	m_but3 = std::make_shared<WinButton>(this, "Refresh item list");
	m_but3->GenericNotifyCallback = [this](GenericNotifications)
	{
		populate_listbox();
	};
	add_control(m_but3);
	
	m_but4 = std::make_shared<WinButton>(this, "Remove selected listbox item foffoffooo");
	m_but4->GenericNotifyCallback = [this](GenericNotifications)
	{
		int selindex = m_listbox1->getSelectedIndex();
		if (selindex >= 0)
		{
			m_listbox1->removeItem(selindex);
			m_itemmap.erase(m_listbox1->userIDfromIndex(selindex));
		}
	};
	add_control(m_but4);
	
	m_edit1 = std::make_shared<WinLineEdit>(this, "No take name yet");
	add_control(m_edit1);
	m_listbox1 = std::make_shared<WinListBox>(this);
	
	m_listbox1->SelectedChangedCallback = [this](int index) mutable
	{
		if (index >= 0)
		{
			std::string temp = m_listbox1->getItemText(index);
			readbg() << "you chose " << temp << " from the listbox\n";
			int user_id = m_listbox1->userIDfromIndex(index);
			MediaItem* itemfromlist = m_itemmap[user_id];
			if (ValidatePtr((void*)itemfromlist, "MediaItem*") == true)
			{
				m_edit1->setText(std::string("You chose item with mem address " +
					std::to_string((uint64_t)itemfromlist) + " from the listbox"));
			}
			else m_edit1->setText(("You chose an item from listbox that's no longer valid!"));
		}
		else readbg() << "you managed to choose no item from the listbox\n";
	};
	add_control(m_listbox1);
	add_control(m_listbox1);
	
	m_checkbox1 = std::make_shared<WinCheckBox>(this,"The check box");
	add_control(m_checkbox1);
	m_checkbox1->GenericNotifyCallback = [this](GenericNotifications reason)
	{
		if (reason == GenericNotifications::Checked)
			readbg() << "check box was checked\n";
		else readbg() << "check box was unchecked\n";
	};
	
	m_label1 = std::make_shared<WinLabel>(this, "Ok, will all this text be shown by default...? I wonder...");
	add_control(m_label1);
	m_label1->setTopLeftPosition(150, 60);

	m_rectcontrol1 = std::make_shared<RectangleTestControl>(this);
	add_control(m_rectcontrol1);

	setSize(900, 650);
}
Ejemplo n.º 8
0
RutPropInspector *
rut_prop_inspector_new (RutContext *ctx,
                        RutProperty *property,
                        RutPropInspectorCallback inspector_property_changed_cb,
                        RutPropInspectorControlledCallback inspector_controlled_cb,
                        bool with_label,
                        void *user_data)
{
  RutPropInspector *inspector =
    rut_object_alloc0 (RutPropInspector,
                       &rut_prop_inspector_type,
                       _rut_prop_inspector_init_type);
  RutBin *grab_padding;

  inspector->ref_count = 1;
  inspector->context = ctx;

  rut_graphable_init (inspector);

  inspector->target_prop = property;
  inspector->inspector_property_changed_cb = inspector_property_changed_cb;
  inspector->controlled_changed_cb = inspector_controlled_cb;
  inspector->user_data = user_data;

  inspector->top_stack = rut_stack_new (ctx, 1, 1);
  rut_graphable_add_child (inspector, inspector->top_stack);
  rut_refable_unref (inspector->top_stack);

  inspector->top_hbox = rut_box_layout_new (ctx, RUT_BOX_LAYOUT_PACKING_LEFT_TO_RIGHT);
  rut_stack_add (inspector->top_stack, inspector->top_hbox);
  rut_refable_unref (inspector->top_hbox);

  /* XXX: Hack for now, to make sure its possible to drag and drop any
   * property without inadvertanty manipulating the property value...
   */
  grab_padding = rut_bin_new (inspector->context);
  rut_bin_set_right_padding (grab_padding, 15);
  rut_box_layout_add (inspector->top_hbox, false, grab_padding);
  rut_refable_unref (grab_padding);

  if (inspector->controlled_changed_cb && property->spec->animatable)
    add_controlled_toggle (inspector, property);

  inspector->widget_stack = rut_stack_new (ctx, 1, 1);
  rut_box_layout_add (inspector->top_hbox, true, inspector->widget_stack);
  rut_refable_unref (inspector->widget_stack);

  inspector->widget_hbox =
    rut_box_layout_new (inspector->context, RUT_BOX_LAYOUT_PACKING_LEFT_TO_RIGHT);
  rut_stack_add (inspector->widget_stack, inspector->widget_hbox);
  rut_refable_unref (inspector->widget_hbox);

  inspector->disabled_overlay =
    rut_rectangle_new4f (ctx, 1, 1, 0.5, 0.5, 0.5, 0.5);
  inspector->input_region =
    rut_input_region_new_rectangle (0, 0, 1, 1, block_input_cb, NULL);

  add_control (inspector, property, with_label);

  rut_prop_inspector_reload_property (inspector);

  rut_sizable_set_size (inspector, 10, 10);

  inspector->target_prop_closure =
    rut_property_connect_callback (property,
                                   target_property_changed_cb,
                                   inspector);

  return inspector;
}
Ejemplo n.º 9
0
/**
  process command line options
*/
struct ldb_cmdline *ldb_cmdline_process(struct ldb_context *ldb, 
					int argc, const char **argv,
					void (*usage)(void))
{
	struct ldb_cmdline *ret=NULL;
	poptContext pc;
#if (_SAMBA_BUILD_ >= 4)
	int r;
#endif
	int num_options = 0;
	int opt;
	int flags = 0;

#if (_SAMBA_BUILD_ >= 4)
	r = ldb_register_samba_handlers(ldb);
	if (r != 0) {
		goto failed;
	}

#endif

	/* make the ldb utilities line buffered */
	setlinebuf(stdout);

	ret = talloc_zero(ldb, struct ldb_cmdline);
	if (ret == NULL) {
		fprintf(stderr, "Out of memory!\n");
		goto failed;
	}

	options = *ret;
	
	/* pull in URL */
	options.url = getenv("LDB_URL");

	/* and editor (used by ldbedit) */
	options.editor = getenv("VISUAL");
	if (!options.editor) {
		options.editor = getenv("EDITOR");
	}
	if (!options.editor) {
		options.editor = "vi";
	}

	options.scope = LDB_SCOPE_DEFAULT;

	pc = poptGetContext(argv[0], argc, argv, popt_options, 
			    POPT_CONTEXT_KEEP_FIRST);

	while((opt = poptGetNextOpt(pc)) != -1) {
		switch (opt) {
		case 's': {
			const char *arg = poptGetOptArg(pc);
			if (strcmp(arg, "base") == 0) {
				options.scope = LDB_SCOPE_BASE;
			} else if (strcmp(arg, "sub") == 0) {
				options.scope = LDB_SCOPE_SUBTREE;
			} else if (strcmp(arg, "one") == 0) {
				options.scope = LDB_SCOPE_ONELEVEL;
			} else {
				fprintf(stderr, "Invalid scope '%s'\n", arg);
				goto failed;
			}
			break;
		}

		case 'v':
			options.verbose++;
			break;

		case 'o':
			options.options = talloc_realloc(ret, options.options, 
							 const char *, num_options+3);
			if (options.options == NULL) {
				fprintf(stderr, "Out of memory!\n");
				goto failed;
			}
			options.options[num_options] = poptGetOptArg(pc);
			options.options[num_options+1] = NULL;
			num_options++;
			break;

		case 'c': {
			const char *cs = poptGetOptArg(pc);
			const char *p;

			for (p = cs; p != NULL; ) {
				const char *t, *c;

				t = strchr(p, ',');
				if (t == NULL) {
					c = talloc_strdup(options.controls, p);
					p = NULL;
				} else {
					c = talloc_strndup(options.controls, p, t-p);
			        	p = t + 1;
				}
				if (c == NULL || !add_control(ret, c)) {
					fprintf(stderr, __location__ ": out of memory\n");
					goto failed;
				}
			}

			break;	  
		}
		case 'P':
			if (!add_control(ret, "paged_results:1:1024")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'D':
			if (!add_control(ret, "show_deleted:1")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'R':
			if (!add_control(ret, "show_recycled:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'd':
			if (!add_control(ret, "show_deactivated_link:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'r':
			if (!add_control(ret, "reveal_internals:0")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'N':
			if (!add_control(ret, "search_options:1:2")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		case 'E':
			if (!add_control(ret, "extended_dn:1:1")) {
				fprintf(stderr, __location__ ": out of memory\n");
				goto failed;
			}
			break;
		default:
			fprintf(stderr, "Invalid option %s: %s\n", 
				poptBadOption(pc, 0), poptStrerror(opt));
			if (usage) usage();
			goto failed;
		}
	}

	/* setup the remaining options for the main program to use */
	options.argv = poptGetArgs(pc);
	if (options.argv) {
		options.argv++;
		while (options.argv[options.argc]) options.argc++;
	}

	*ret = options;

	/* all utils need some option */
	if (ret->url == NULL) {
		fprintf(stderr, "You must supply a url with -H or with $LDB_URL\n");
		if (usage) usage();
		goto failed;
	}

	if (strcmp(ret->url, "NONE") == 0) {
		return ret;
	}

	if (options.nosync) {
		flags |= LDB_FLG_NOSYNC;
	}

	if (options.show_binary) {
		flags |= LDB_FLG_SHOW_BINARY;
	}

	if (options.tracing) {
		flags |= LDB_FLG_ENABLE_TRACING;
	}

#if (_SAMBA_BUILD_ >= 4)
	/* Must be after we have processed command line options */
	gensec_init(cmdline_lp_ctx); 
	
	if (ldb_set_opaque(ldb, "sessionInfo", system_session(cmdline_lp_ctx))) {
		goto failed;
	}
	if (ldb_set_opaque(ldb, "credentials", cmdline_credentials)) {
		goto failed;
	}
	if (ldb_set_opaque(ldb, "loadparm", cmdline_lp_ctx)) {
		goto failed;
	}

	ldb_set_utf8_fns(ldb, NULL, wrap_casefold);
#endif

	if (options.modules_path != NULL) {
		ldb_set_modules_dir(ldb, options.modules_path);
	} else if (getenv("LDB_MODULES_PATH") != NULL) {
		ldb_set_modules_dir(ldb, getenv("LDB_MODULES_PATH"));
	}

	/* now connect to the ldb */
	if (ldb_connect(ldb, ret->url, flags, ret->options) != 0) {
		fprintf(stderr, "Failed to connect to %s - %s\n", 
			ret->url, ldb_errstring(ldb));
		goto failed;
	}

	return ret;

failed:
	talloc_free(ret);
	exit(1);
	return NULL;
}
Ejemplo n.º 10
0
static void show_settings_dialog() {
#define HEIGHT 15
#define WIDTH 400
#define LABEL_WIDTH 80

  unsigned char mem[4096], *p;
  const char **option_names, *long_option_name;
  DWORD style;
  DLGTEMPLATE *dia = (DLGTEMPLATE *) mem;
  WORD i, cl, x, y, width, nelems = 0;
  static int guard;

  static struct {
    DLGTEMPLATE dialog_template; // 18 bytes
    WORD menu, window_class;
    wchar_t caption[1];
    WORD fontsiz;
    wchar_t fontface[7];
  } dialog_header = {{WS_CAPTION | WS_POPUP | WS_SYSMENU | WS_VISIBLE |
    DS_SETFONT | WS_DLGFRAME, WS_EX_TOOLWINDOW, 0, 200, 200, WIDTH, 0},
    0, 0, L"", 8, L"Tahoma"};

  if (guard == 0) {
    guard++;
  } else {
    return;
  }

  (void) memset(mem, 0, sizeof(mem));
  (void) memcpy(mem, &dialog_header, sizeof(dialog_header));
  p = mem + sizeof(dialog_header);

  option_names = mg_get_valid_option_names();
  for (i = 0; option_names[i * 2] != NULL; i++) {
    long_option_name = option_names[i * 2];
    style = WS_CHILD | WS_VISIBLE | WS_TABSTOP;
    x = 10 + (WIDTH / 2) * (nelems % 2);
    y = (nelems/2 + 1) * HEIGHT + 5;
    width = WIDTH / 2 - 20 - LABEL_WIDTH;
    if (is_numeric_options(long_option_name)) {
      style |= ES_NUMBER;
      cl = 0x81;
      style |= WS_BORDER | ES_AUTOHSCROLL;
    } else if (is_boolean_option(long_option_name)) {
      cl = 0x80;
      style |= BS_AUTOCHECKBOX;
    } else if (is_filename_option(long_option_name) ||
               is_directory_option(long_option_name)) {
      style |= WS_BORDER | ES_AUTOHSCROLL;
      width -= 20;
      cl = 0x81;
      add_control(&p, dia, 0x80,
                  ID_CONTROLS + i + ID_FILE_BUTTONS_DELTA,
                  WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
                  (WORD) (x + width + LABEL_WIDTH + 5),
                  y, 15, 12, "...");
    } else {
      cl = 0x81;
      style |= WS_BORDER | ES_AUTOHSCROLL;
    }
    add_control(&p, dia, 0x82, ID_STATIC, WS_VISIBLE | WS_CHILD,
                x, y, LABEL_WIDTH, HEIGHT, long_option_name);
    add_control(&p, dia, cl, ID_CONTROLS + i, style,
                (WORD) (x + LABEL_WIDTH), y, width, 12, "");
    nelems++;
  }

  y = (WORD) (((nelems + 1) / 2 + 1) * HEIGHT + 5);
  add_control(&p, dia, 0x80, ID_GROUP, WS_CHILD | WS_VISIBLE |
              BS_GROUPBOX, 5, 5, WIDTH - 10, y, " Settings ");
  y += 10;
  add_control(&p, dia, 0x80, ID_SAVE,
              WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
              WIDTH - 70, y, 65, 12, "Save Settings");
  add_control(&p, dia, 0x80, ID_RESET_DEFAULTS,
              WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | WS_TABSTOP,
              WIDTH - 140, y, 65, 12, "Reset to defaults");
  add_control(&p, dia, 0x82, ID_STATIC,
              WS_CHILD | WS_VISIBLE | WS_DISABLED,
              5, y, 180, 12, server_name);

  dia->cy = ((nelems + 1) / 2 + 1) * HEIGHT + 30;
  DialogBoxIndirectParam(NULL, dia, NULL, DlgProc, (LPARAM) NULL);
  guard--;
}
Ejemplo n.º 11
0
//------------------------------------------------------------------------------
void sccan_point_analysis::interaction(){
	
	std::string key_fill_sccan_point_matrix  ="f";
	add_control(key_fill_sccan_point_matrix,"fill sccan point matrix");

	std::string key_show_sccan_point_matrix  ="s";
	add_control(key_show_sccan_point_matrix,"show sccan point matrix");	

	std::string key_analyse_sccan_point_matrix  ="a";
	add_control(key_analyse_sccan_point_matrix,
	"analyse sccan point matrix");	
	
	std::string key_toggle_light_flux_normalizing  ="n";
	add_control(key_toggle_light_flux_normalizing,
	"toggle mirror response normalizing");	
	
	std::string key_toggle_max_response_estimation_method  ="method";
	add_control(key_toggle_max_response_estimation_method,
	"toggle max response estimation method");
	
	std::string key_draw_all_mirror_response_maps  ="draw";
	add_control(key_draw_all_mirror_response_maps,
	"draw all mirror response maps");

	std::string key_toggle_multithread  ="m";
	add_control(key_toggle_multithread,"toggle multithread");	
	
	std::string key_substract_global_direction_offset = "sub_off";
	add_control(key_substract_global_direction_offset," toggle sub. global direction offset");

	std::string key_user_wants_to_end_analysis  ="back";
	add_control(key_user_wants_to_end_analysis,"back to main menu");	
	
	std::string user_input;
	std::stringstream out;
	
	bool flag_user_wants_to_analyse = true;
	
	do{
		// prompt snapshot options to command line
		update_status_prompt(get_analysis_prompt());
		// get input of user via command line
		get_user_input();
		// interpret answer of user

		if(valid_user_input.compare(key_user_wants_to_end_analysis)==0)
			flag_user_wants_to_analyse = false;
		
		if(valid_user_input.compare(key_fill_sccan_point_matrix)==0)
			fill_sccan_matrix();
		
		if(valid_user_input.compare(key_show_sccan_point_matrix)==0)
			display_sccan_matrix_prompt();
		
		if(valid_user_input.compare(key_analyse_sccan_point_matrix)==0)
			run_anaysis();
		
		if(valid_user_input.compare(key_draw_all_mirror_response_maps)==0){
				
			for(uint mirror_it=0;
				mirror_it<get_number_of_mirrors();
				mirror_it++
			)
				draw_mirror_response(mirror_it);
		}
		
		if(valid_user_input.compare(key_toggle_light_flux_normalizing)==0)
			normalize_mirror_response = ! normalize_mirror_response;	
		
		if(valid_user_input.compare(key_toggle_multithread)==0)
			use_multithread =! use_multithread;	
		
		if(valid_user_input.compare(key_toggle_max_response_estimation_method)==0)
			max_only_instead_of_CoG =! max_only_instead_of_CoG;	
		
		if(valid_user_input.compare(key_substract_global_direction_offset)==0)
			substract_global_offset =! substract_global_offset;
		
	}while(flag_user_wants_to_analyse);
}