Пример #1
0
//*****************************************************************************
//  PRIVATE METHOD:  ossimAtbController::initializeRemappers()
//  
//*****************************************************************************
void ossimAtbController::initializeRemappers()
{
   static const char MODULE[] = "ossimAtbController::initializeRemappers()";
   if (traceExec())  CLOG << "entering..." << endl;

   int num_images = getNumberOfInputs();

   //***
   // Fetch the overall mosaic bounding rect:
   //***
   ossimGridRemapSource* remapper = PTR_CAST(ossimGridRemapSource,
                                             getInput(0));
   theBoundingRect = remapper->getBoundingRect();
   for (int src=1; src<num_images; src++)
   {
      theBoundingRect = theBoundingRect.combine(remapper->getBoundingRect());
   }
 
   //***
   // Loop over each contribution image source chain to fetch each image
   // bounding rect:
   //***
   double dx_ul, dy_ul, dx_lr, dy_lr;
   double grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y;
   for (int src=0; src<num_images; src++)
   {
      remapper = PTR_CAST(ossimGridRemapSource, getInput(src));
      ossimDrect image_rect (remapper->getBoundingRect());

      //***
      // Arrive at the number of grid posts from mosaic origin to image's grid
      // UL and LR corners:
      //***
      dx_ul = (image_rect.ul().x - theBoundingRect.ul().x)/theGridSpacing.x;
      dy_ul = (image_rect.ul().y - theBoundingRect.ul().y)/theGridSpacing.y;
      dx_lr = (image_rect.lr().x - theBoundingRect.lr().x)/theGridSpacing.x;
      dy_lr = (image_rect.lr().y - theBoundingRect.lr().y)/theGridSpacing.y;
   
      //***
      // Establish the view coordinates for the adjusted image grid:
      //***
      grid_ul_x =  theBoundingRect.ul().x + ceil(dx_ul)*theGridSpacing.x;
      grid_ul_y =  theBoundingRect.ul().y + ceil(dy_ul)*theGridSpacing.y;
      grid_lr_x =  theBoundingRect.lr().x + floor(dx_lr)*theGridSpacing.x;
      grid_lr_y =  theBoundingRect.lr().y + floor(dy_lr)*theGridSpacing.y;

      //***
      // Have the remapper initialize a new grid with the given rectangle and
      // spacing:
      //***
      ossimDrect grid_rect (grid_ul_x, grid_ul_y, grid_lr_x, grid_lr_y);
      remapper->initialize(grid_rect, theGridSpacing);
   }
      
   if (traceExec())  CLOG << "returning..." << endl;
   return;
}
Пример #2
0
	MainWindow::MainWindow(const ax::Rect& rect, const std::string& proj_path)
		: _font(0)
		, _view_handler(this)
		, _widget_handler(this)
		, _project_handler(this)
	{
		// Create window.
		win = ax::Window::Create(rect);
		win->event.OnPaint = ax::WBind<ax::GC>(this, &MainWindow::OnPaint);
		win->event.OnPaintOverChildren = ax::WBind<ax::GC>(this, &MainWindow::OnPaintOverChildren);
		win->event.OnResize = ax::WBind<ax::Size>(&_view_handler, &MainWindowViewHandler::OnResize);
		win->event.OnKeyDown = ax::WBind<char>(this, &MainWindow::OnGlobalKey);
		win->event.OnAssignToWindowManager = ax::WBind<int>(this, &MainWindow::OnAssignToWindowManager);

		win->AddConnection(999, GetOnHelpBar());

		_font.SetFontSize(10);

		// Create top menu.
		ax::Rect top_menu_rect(0, 0, rect.size.w, STATUS_BAR_HEIGHT);
		_statusBar = new StatusBar(top_menu_rect);
		win->node.Add(std::shared_ptr<ax::Window::Backbone>(_statusBar));

		if (!proj_path.empty()) {
			_project.Open(proj_path);
			_statusBar->SetLayoutFilePath(_project.GetLayoutPath());
		}
		else {
			_statusBar->SetLayoutFilePath("default.xml");
		}

		ax::Window* sb_win = _statusBar->GetWindow();
		sb_win->AddConnection(StatusBar::SAVE_LAYOUT, _project_handler.GetOnSaveProject());
		sb_win->AddConnection(StatusBar::SAVE_AS_LAYOUT, _project_handler.GetOnSaveAsProject());
		sb_win->AddConnection(StatusBar::OPEN_LAYOUT, _project_handler.GetOnOpenProject());
		sb_win->AddConnection(StatusBar::CREATE_NEW_LAYOUT, _project_handler.GetOnCreateNewProject());

		sb_win->AddConnection(StatusBar::RELOAD_SCRIPT, GetOnReloadScript());
		sb_win->AddConnection(StatusBar::STOP_SCRIPT, GetOnStopScript());

		sb_win->AddConnection(StatusBar::TOGGLE_LEFT_PANEL, _view_handler.GetOnToggleLeftPanel());
		sb_win->AddConnection(StatusBar::TOGGLE_BOTTOM_PANEL, _view_handler.GetOnToggleBottomPanel());
		sb_win->AddConnection(StatusBar::TOGGLE_RIGHT_PANEL, _view_handler.GetOnToggleRightPanel());

		sb_win->AddConnection(StatusBar::VIEW_LAYOUT, _view_handler.GetOnViewLayout());

		// Events from MainWindow to status bar.
		win->AddConnection(HAS_WIDGET_ON_GRID, _statusBar->GetOnHasWidgetOnGrid());

		// Create grid window.
		ax::Rect grid_rect(WIDGET_MENU_WIDTH, STATUS_BAR_HEIGHT,
			rect.size.w - WIDGET_MENU_WIDTH - INSPECTOR_MENU_WIDTH,
			rect.size.h - STATUS_BAR_HEIGHT - 200 - BOTTOM_BAR_HEIGHT);
		win->node.Add(_gridWindow = ax::shared<GridWindow>(grid_rect));

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SELECT_WIDGET, _widget_handler.GetOnSelectWidget());
		_gridWindow->GetWindow()->AddConnection(
			GridWindow::UNSELECT_ALL, _widget_handler.GetOnUnSelectAllWidget());
		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SAVE_PANEL_TO_WORKSPACE, GetOnSavePanelToWorkspace());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DELETE_SELECTED_WIDGET, _widget_handler.GetOnDeleteSelectedWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DUPLICATE_SELECTED_WIDGET, _widget_handler.GetOnDuplicateSelectedWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DELETE_SELECTED_WIDGET_FROM_RIGHT_CLICK, GetOnRemoveWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::DUPLICATE_SELECTED_WIDGET_FROM_RIGHT_CLICK, GetOnDuplicateWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SNAP_WIDGET_TO_GRID_FROM_RIGHT_CLICK, GetOnSnapToGridWidgetFromRightClickMenu());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::SELECT_MULTIPLE_WIDGET, _widget_handler.GetOnSelectMultipleWidget());

		_gridWindow->GetWindow()->AddConnection(
			GridWindow::ARROW_MOVE_SELECTED_WIDGET, _widget_handler.GetOnArrowMoveSelectedWidget());

		if (!proj_path.empty()) {
			_gridWindow->OpenLayout(_project.GetLayoutPath());
		}
		else {
			_gridWindow->OpenLayout("layouts/default.xml");
		}

		// Create widget menu.
		ax::Rect widget_menu_rect(
			0, STATUS_BAR_HEIGHT, WIDGET_MENU_WIDTH, rect.size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);

		auto l_side_menu = ax::shared<LeftSideMenu>(widget_menu_rect);
		win->node.Add(l_side_menu);
		_left_menu = l_side_menu.get();

		l_side_menu->GetWindow()->AddConnection(
			WidgetMenu::SMALLER_MENU, _view_handler.GetOnSmallerLeftMenu());

		// Create info menu.
		ax::Rect info_rect(rect.size.w - INSPECTOR_MENU_WIDTH, STATUS_BAR_HEIGHT, INSPECTOR_MENU_WIDTH,
			rect.size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);

		auto right_menu = ax::shared<RightSideMenu>(info_rect);
		win->node.Add(right_menu);
		_right_menu = right_menu.get();

		// Create code editor.
		TextEditor::Info txt_info;
		txt_info.bg_color = ax::Color(1.0);
		txt_info.cursor_color = ax::Color(0.0);
		txt_info.line_number_bg_color = ax::Color(0.95);
		txt_info.line_number_color = ax::Color(0.4);
		txt_info.text_color = ax::Color(0.0);

		ax::Rect bottom_rect(WIDGET_MENU_WIDTH + 1, rect.size.h - 200 - BOTTOM_BAR_HEIGHT,
			rect.size.w - WIDGET_MENU_WIDTH - INSPECTOR_MENU_WIDTH, 200);

		std::string script_path;

		if (!proj_path.empty()) {
			script_path = _project.GetScriptPath();
		}
		else {
			script_path = "scripts/default.py";
		}

		auto b_section = ax::shared<BottomSection>(bottom_rect, script_path);
		win->node.Add(b_section);
		_bottom_section = b_section.get();
		_bottom_section->GetWindow()->AddConnection(
			BottomSection::RESIZE, _view_handler.GetOnResizeCodeEditor());

		_bottom_section->GetWindow()->AddConnection(10020, ax::event::Function([&](ax::event::Msg* msg) {
			ax::console::Print("Save");
			std::vector<std::shared_ptr<ax::Window>>& children = _gridWindow->GetWindow()->node.GetChildren();

			for (auto& n : children) {
				n->Update();
			}
		}));

		win->AddConnection(global::CREATE_DRAGGING_WIDGET, _widget_handler.GetOnCreateDraggingWidget());
		win->AddConnection(global::DRAGGING_WIDGET, _widget_handler.GetOnDraggingWidget());
		win->AddConnection(global::RELEASE_WIDGET, _widget_handler.GetOnReleaseObjWidget());
		win->AddConnection(
			global::CREATE_CUSTOM_DRAGGING_WIDGET, _widget_handler.GetOnCreateCustomDraggingWidget());

		// Midi feedback.
		auto midi_feedback = ax::shared<at::MidiFeedback>(
			ax::Rect(ax::Point(rect.size.w - 17, rect.size.h - 15), ax::Size(10, 10)));
		_midi_feedback = midi_feedback.get();

		win->node.Add(midi_feedback);
	}
Пример #3
0
	void MainWindowViewHandler::OnResize(const ax::Size& size)
	{
		if (_view_mode) {
			return;
		}

		int INSPECTOR_MENU_WIDTH = _main_window->INSPECTOR_MENU_WIDTH;
		int STATUS_BAR_HEIGHT = _main_window->STATUS_BAR_HEIGHT;
		int BOTTOM_BAR_HEIGHT = _main_window->BOTTOM_BAR_HEIGHT;

		// Resize status bar.
		ax::Size top_menu_size(_main_window->_statusBar->GetWindow()->dimension.GetSize());
		top_menu_size.w = size.w;
		_main_window->_statusBar->GetWindow()->dimension.SetSize(top_menu_size);

		bool widget_menu = _main_window->_left_menu->GetWindow()->IsShown();
		bool inspector = _main_window->_right_menu->GetWindow()->IsShown();
		bool code_editor = _main_window->_bottom_section->GetWindow()->IsShown();

		int editor_height = 0;

		if (code_editor) {
			editor_height = _main_window->_bottom_section->GetWindow()->dimension.GetSize().h;
			if (editor_height > size.h - _main_window->STATUS_BAR_HEIGHT) {
				editor_height = size.h - _main_window->STATUS_BAR_HEIGHT;
			}
		}

		int grid_height
			= size.h - _main_window->STATUS_BAR_HEIGHT - editor_height - _main_window->BOTTOM_BAR_HEIGHT;

		int widget_menu_width = _main_window->_left_menu->GetWindow()->dimension.GetRect().size.w;

		if (widget_menu && inspector) {
			ax::Size widget_menu_size(widget_menu_width,
				size.h - _main_window->STATUS_BAR_HEIGHT - _main_window->BOTTOM_BAR_HEIGHT);
			_main_window->_left_menu->GetWindow()->dimension.SetSize(widget_menu_size);

			ax::Rect grid_rect(widget_menu_width, _main_window->STATUS_BAR_HEIGHT,
				size.w - widget_menu_width - _main_window->INSPECTOR_MENU_WIDTH, grid_height);
			_main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect);

			ax::Rect info_rect(size.w - _main_window->INSPECTOR_MENU_WIDTH, _main_window->STATUS_BAR_HEIGHT,
				_main_window->INSPECTOR_MENU_WIDTH,
				size.h - _main_window->STATUS_BAR_HEIGHT - _main_window->BOTTOM_BAR_HEIGHT);
			_main_window->_right_menu->GetWindow()->dimension.SetRect(info_rect);

			if (code_editor) {
				ax::Rect editor_rect(widget_menu_width + 1,
					size.h - editor_height - _main_window->BOTTOM_BAR_HEIGHT,
					size.w - widget_menu_width - _main_window->INSPECTOR_MENU_WIDTH, editor_height);
				_main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect);
			}
		}
		else if (widget_menu) {
			ax::Size widget_menu_size(widget_menu_width, size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);
			_main_window->_left_menu->GetWindow()->dimension.SetSize(widget_menu_size);

			ax::Rect grid_rect(
				widget_menu_width, _main_window->STATUS_BAR_HEIGHT, size.w - widget_menu_width, grid_height);
			_main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect);

			if (code_editor) {
				ax::Rect editor_rect(widget_menu_width + 1, size.h - editor_height - BOTTOM_BAR_HEIGHT,
					size.w - widget_menu_width, editor_height);

				_main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect);
			}
		}
		else if (inspector) {
			ax::Rect grid_rect(0, STATUS_BAR_HEIGHT, size.w - INSPECTOR_MENU_WIDTH, grid_height);
			_main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect);

			ax::Rect info_rect(size.w - INSPECTOR_MENU_WIDTH, STATUS_BAR_HEIGHT, INSPECTOR_MENU_WIDTH,
				size.h - STATUS_BAR_HEIGHT - BOTTOM_BAR_HEIGHT);
			_main_window->_right_menu->GetWindow()->dimension.SetRect(info_rect);

			if (code_editor) {
				ax::Rect editor_rect(1, size.h - editor_height - BOTTOM_BAR_HEIGHT,
					size.w - INSPECTOR_MENU_WIDTH, editor_height);

				_main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect);
			}
		}
		else {
			ax::Rect grid_rect(0, STATUS_BAR_HEIGHT, size.w, grid_height);
			_main_window->_gridWindow->GetWindow()->dimension.SetRect(grid_rect);

			if (code_editor) {
				ax::Rect editor_rect(1, size.h - editor_height - BOTTOM_BAR_HEIGHT, size.w, editor_height);

				_main_window->_bottom_section->GetWindow()->dimension.SetRect(editor_rect);
			}
		}

		// Midi feedback.
		_main_window->_midi_feedback->GetWindow()->dimension.SetPosition(ax::Point(size.w - 17, size.h - 15));

		AttachHelpInfo(_main_window->_midi_feedback->GetWindow(), "Midi input activity.");
	}