Ejemplo n.º 1
0
	MyGUI::IntCoord WidgetCreatorManager::getCoordNewWidget(const MyGUI::IntPoint& _point)
	{
		MyGUI::IntPoint point = _point;
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			point.left += mGridStep / 2;
			point.top += mGridStep / 2;
		}

		MyGUI::Widget* parent = mNewWidget->getParent();
		if (parent != nullptr && !mNewWidget->isRootWidget())
			point -= parent->getAbsolutePosition();

		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			point.left = toGrid(point.left);
			point.top = toGrid(point.top);
		}

		MyGUI::IntCoord coord = MyGUI::IntCoord(
			std::min(mStartPoint.left, point.left),
			std::min(mStartPoint.top, point.top),
			abs(point.left - mStartPoint.left),
			abs(point.top - mStartPoint.top));

		return coord;
	}
Ejemplo n.º 2
0
    void * getDirectedEdge(Vector3 const & e0, Vector3 const & e1) const
    {
      typedef std::pair<EdgeMap::const_iterator, EdgeMap::const_iterator> IteratorRange;
      Long3Pair base_key(toGrid(e0), toGrid(e1));

      // Every edge within welding distance of the given edge must be inside a neighbor of the grid cell containing the edge
      for (int dx0 = -1; dx0 <= 1; ++dx0)
        for (int dy0 = -1; dy0 <= 1; ++dy0)
          for (int dz0 = -1; dz0 <= 1; ++dz0)
            for (int dx1 = -1; dx1 <= 1; ++dx1)
              for (int dy1 = -1; dy1 <= 1; ++dy1)
                for (int dz1 = -1; dz1 <= 1; ++dz1)
                {
                  Long3Pair key(Long3(base_key.first.x + dx0, base_key.first.y + dy0, base_key.first.z + dz0),
                                Long3(base_key.second.x + dx1, base_key.second.y + dy1, base_key.second.z + dz1));
                  IteratorRange nbrs = edge_map.equal_range(key);
                  for (EdgeMap::const_iterator ni = nbrs.first; ni != nbrs.second; ++ni)
                  {
                    if ((ni->second.e0 - e0).squaredLength() <= squared_weld_radius
                     && (ni->second.e1 - e1).squaredLength() <= squared_weld_radius)
                      return ni->second.edge;
                  }
                }

      return NULL;
    }
Ejemplo n.º 3
0
	void StateTextureControl::notifyChangePosition()
	{
		mPointValue = mAreaSelectorControl->getPosition();

		// снапим к гриду
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			MyGUI::IntPoint point = mPointValue;
			MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale();

			if (actionScale.left != 0)
			{
				point.left = toGrid(point.left + (mGridStep / 2));
			}

			if (actionScale.top != 0)
			{
				point.top = toGrid(point.top + (mGridStep / 2));
			}

			if (point != mPointValue)
			{
				mPointValue = point;
				mAreaSelectorControl->setPosition(mPointValue);
			}
		}

		if (getCurrentState() != nullptr)
			getCurrentState()->getPropertySet()->setPropertyValue("Position", mPointValue.print(), mTypeName);
	}
Ejemplo n.º 4
0
//===================================================================================
void EditorState::injectMouseRelease(int _absx, int _absy, MyGUI::MouseButton _id)
{
	selectDepth++;
	if (testMode)
	{
		base::BaseManager::injectMouseRelease(_absx, _absy, _id);
		return;
	}

	if (MyGUI::InputManager::getInstance().isModalAny())
	{
	}
	else
	{
		// align to grid if shift not pressed
		int x2, y2;
		if (MyGUI::InputManager::getInstance().isShiftPressed() == false)
		{
			x2 = toGrid(_absx);
			y2 = toGrid(_absy);
		}
		else
		{
			x2 = _absx;
			y2 = _absy;
		}

		mWidgetsWindow->finishNewWidget(x2, y2);
	}

	um->dropLastProperty();

	base::BaseManager::injectMouseRelease(_absx, _absy, _id);
}
Ejemplo n.º 5
0
//===================================================================================
void EditorState::injectMouseMove(int _absx, int _absy, int _absz)
{
	if (testMode)
	{
		base::BaseManager::injectMouseMove(_absx, _absy, _absz);
		return;
	}

	// drop select depth if we moved mouse
	const int DIST = 2;
	if ((abs(x - _absx) > DIST) || (abs(y - _absy) > DIST))
	{
		selectDepth = 0;
		x = _absx;
		y = _absy;
	}

	// align to grid if shift not pressed
	int x2, y2;
	if (MyGUI::InputManager::getInstance().isShiftPressed() == false)
	{
		x2 = toGrid(_absx);
		y2 = toGrid(_absy);
	}
	else
	{
		x2 = _absx;
		y2 = _absy;
	}

	mWidgetsWindow->createNewWidget(x2, y2);

	base::BaseManager::injectMouseMove(_absx, _absy, _absz);
}
Ejemplo n.º 6
0
	void WidgetCreatorManager::moveNewWidget(const MyGUI::IntPoint& _point)
	{
		if (mNewWidget == nullptr)
		{
			// тип виджета может отсутсвовать
			if (!MyGUI::WidgetManager::getInstance().isFactoryExist(mWidgetType))
				return;

			// выделяем верний виджет
			if (!mPopupMode)
				WidgetSelectorManager::getInstance().selectWidget(mStartPoint);

			MyGUI::Widget* parent = WidgetSelectorManager::getInstance().getSelectedWidget();

			// пока не найдем ближайшего над нами способного быть родителем
			while (parent != nullptr && !WidgetTypes::getInstance().findWidgetStyle(parent->getTypeName())->parent)
				parent = parent->getParent();

			if (!WidgetTypes::getInstance().findWidgetStyle(mWidgetType)->child)
				parent = nullptr;

			if (parent != nullptr)
				mNewWidget = parent->createWidgetT(
					mPopupMode ? MyGUI::WidgetStyle::Popup : MyGUI::WidgetStyle::Child,
					mWidgetType,
					EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
					MyGUI::IntCoord(),
					MyGUI::Align::Default,
					DEFAULT_EDITOR_LAYER);
			else
				mNewWidget = MyGUI::Gui::getInstance().createWidgetT(
					mWidgetType,
					EditorWidgets::getInstance().getSkinReplace(mWidgetSkin),
					MyGUI::IntCoord(),
					MyGUI::Align::Default,
					DEFAULT_EDITOR_LAYER);

			// переводим старт поинт в координаты отца
			if (parent != nullptr && !mNewWidget->isRootWidget())
				mStartPoint -= parent->getAbsolutePosition();

			if (!MyGUI::InputManager::getInstance().isShiftPressed())
			{
				mStartPoint.left = toGrid(mStartPoint.left);
				mStartPoint.top = toGrid(mStartPoint.top);
			}
		}

		MyGUI::IntCoord coord = getCoordNewWidget(_point);
		mNewWidget->setCoord(coord);

		eventChangeSelector(true, mNewWidget->getAbsoluteCoord());
	}
Ejemplo n.º 7
0
	void StateTextureControl::CommandGridMoveBottom(const MyGUI::UString& _commandName, bool& _result)
	{
		if (!checkCommand())
			return;

		mPointValue.top = toGrid(mPointValue.top + mGridStep);
		updateFromPointValue();

		_result = true;
	}
Ejemplo n.º 8
0
	void StateTextureControl::CommandGridMoveLeft(const MyGUI::UString& _commandName, bool& _result)
	{
		if (!checkCommand())
			return;

		mPointValue.left = toGrid(--mPointValue.left);
		updateFromPointValue();

		_result = true;
	}
Ejemplo n.º 9
0
	void WorkspaceControl::Command_GridMoveTop(const MyGUI::UString& _commandName, bool& _result)
	{
		if (!checkCommand())
			return;

		if (!mMoveableWidget)
			return;

		mCoordValue.top = toGrid(--mCoordValue.top);
		updateFromCoordValue();

		UndoManager::getInstance().addValue(PR_KEY_POSITION);

		_result = true;
	}
Ejemplo n.º 10
0
	void WorkspaceControl::Command_GridSizeBottom(const MyGUI::UString& _commandName, bool& _result)
	{
		if (!checkCommand())
			return;

		if (!mMoveableWidget)
			return;

		mCoordValue.height = toGrid(mCoordValue.bottom() + mGridStep) - mCoordValue.top;
		updateFromCoordValue();

		UndoManager::getInstance().addValue(PR_KEY_POSITION);

		_result = true;
	}
Ejemplo n.º 11
0
	void WorkspaceControl::Command_GridSizeLeft(const MyGUI::UString& _commandName, bool& _result)
	{
		if (!checkCommand())
			return;

		if (!mMoveableWidget)
			return;

		mCoordValue.width = toGrid(mCoordValue.right() - 1) - mCoordValue.left;
		updateFromCoordValue();

		UndoManager::getInstance().addValue(PR_KEY_POSITION);

		_result = true;
	}
Ejemplo n.º 12
0
FloorPlaner::FloorPlaner(QWidget *parent)
    : QWidget(parent)
{
    resize(300, 200);
    setWindowTitle("FloorPlanner");

    auto layout = new QVBoxLayout(this);

    for(int i=0; i<4; i++) {

        auto label = new QPushButton("Label");
        label->setStyleSheet("background-color: lightgrey");
        buttons << label;

        layout->addWidget(buttons[i]);
    }

    toGrid();
}
Ejemplo n.º 13
0
void PropertiesPanelView::notifyRectangleResize(MyGUI::WindowPtr _sender)
{
	if (!_sender->isVisible()) return;
	// найдем соответствующий контейнер виджета и переместим/раст¤нем
	WidgetContainer * widgetContainer = EditorWidgets::getInstance().find(current_widget);
	if (WidgetTypes::getInstance().find(current_widget->getTypeName())->resizeable)
	{
		MyGUI::IntCoord coord = convertCoordToParentCoord(_sender->getCoord(), current_widget);
		MyGUI::IntCoord old_coord = current_widget->getCoord();
		// align to grid
		if (!MyGUI::InputManager::getInstance().isShiftPressed() && !arrow_move){
			if ((old_coord.width == coord.width) && (old_coord.height == coord.height)) // если только перемещаем
			{
				coord.left = toGrid(coord.left + grid_step-1 - old_coord.left) + old_coord.left;
				coord.top = toGrid(coord.top + grid_step-1 - old_coord.top) + old_coord.top;
			}
			else // если раст¤гиваем
			{
				if (old_coord.left != coord.left){
					coord.left = toGrid(coord.left + grid_step-1);
					coord.width = old_coord.right() - coord.left;
				}else if (old_coord.width != coord.width){
					coord.width = toGrid(coord.width + old_coord.left) - old_coord.left;
				}

				if (old_coord.top != coord.top){
					coord.top = toGrid(coord.top + grid_step-1);
					coord.height = old_coord.bottom() - coord.top;
				}else if (old_coord.height != coord.height){
					coord.height = toGrid(coord.height + old_coord.top) - old_coord.top;
				}
			}
		}
		arrow_move = false;

		current_widget->setCoord(coord);
		// update coord because of current_widget can have MinMax size
		coord = current_widget->getCoord();
		setPositionText(widgetContainer->position());

		UndoManager::getInstance().addValue(PR_POSITION);
	}
	current_widget_rectangle->setCoord(current_widget->getAbsoluteCoord());
}
Ejemplo n.º 14
0
	void WorkspaceControl::notifyChangePosition()
	{
		if (!mMoveableWidget)
			return;

		mCoordValue = mAreaSelectorControl->getCoord();

		// конвертируем в локальные координаты
		if (mCurrentWidget != nullptr)
		{
			MyGUI::Widget* parent = mCurrentWidget->getParent();
			if (parent != nullptr && !mCurrentWidget->isRootWidget())
				mCoordValue = mCoordValue - parent->getAbsolutePosition();
		}

		// снапим к гриду
		if (!MyGUI::InputManager::getInstance().isShiftPressed())
		{
			MyGUI::IntCoord coord = mCoordValue;
			MyGUI::IntCoord actionScale = mAreaSelectorControl->getActionScale();

			if (actionScale.left != 0 && actionScale.width != 0)
			{
				int right = coord.right();
				coord.width = toGrid(coord.width + (mGridStep / 2));
				coord.left = right - coord.width;
			}
			else if (actionScale.width != 0)
			{
				int right = toGrid(coord.right() + (mGridStep / 2));
				coord.width = right - coord.left;
			}
			else if (actionScale.left != 0)
			{
				coord.left = toGrid(coord.left + (mGridStep / 2));
			}

			if (actionScale.top != 0 && actionScale.height != 0)
			{
				int bottom = coord.bottom();
				coord.height = toGrid(coord.height + (mGridStep / 2));
				coord.top = bottom - coord.height;
			}
			else if (actionScale.height != 0)
			{
				int bottom = toGrid(coord.bottom() + (mGridStep / 2));
				coord.height = bottom - coord.top;
			}
			else if (actionScale.top != 0)
			{
				coord.top = toGrid(coord.top + (mGridStep / 2));
			}

			if (coord != mCoordValue)
			{
				mCoordValue = coord;
				updateSelectionFromValue();
			}
		}

		if (mCurrentWidget != nullptr)
			setWidgetCoord(mCurrentWidget, mCoordValue);

		UndoManager::getInstance().addValue(PR_POSITION);
	}
Ejemplo n.º 15
0
SEXP gridHaveViewers(SEXP Rptr){
  SEXP ans=PROTECT( allocVector(LGLSXP,1) );
  ElGridHaveViewers( toGrid(Rptr), (bool *)LOGICAL(ans) );
  UNPROTECT(1);
  return ans;
}
Ejemplo n.º 16
0
SEXP gridDiagRank( SEXP Rptr, SEXP VCRank){
  SEXP ans= PROTECT( allocVector(INTSXP,1) );
  ElGridDiagRank( toGrid(Rptr), (int)toElInt(VCRank), INTEGER(ans) );
  UNPROTECT(1);
  return ans;
}
Ejemplo n.º 17
0
 void addEdge(void * edge, Vector3 const & e0, Vector3 const & e1)
 {
   WeldableEdge value(edge, e0, e1);
   Long3Pair key(toGrid(e0), toGrid(e1));
   edge_map.insert(EdgeMap::value_type(key, value));
 }
Ejemplo n.º 18
0
SEXP gridVRRank( SEXP Rptr){
  SEXP ans= PROTECT( allocVector(INTSXP,1) );
  ElGridVRRank( toGrid(Rptr), INTEGER(ans) );
  UNPROTECT(1);
  return ans;
}
Ejemplo n.º 19
0
//===================================================================================
void EditorState::injectMousePress(int _absx, int _absy, MyGUI::MouseButton _id)
{
	if (testMode)
	{
		return base::BaseManager::injectMousePress(_absx, _absy, _id);
	}

	if (MyGUI::InputManager::getInstance().isModalAny())
	{
		// if we have modal widgets we can't select any widget
		base::BaseManager::injectMousePress(_absx, _absy, _id);
		return;
	}

	// align to grid if shift not pressed
	int x1, y1;
	if (MyGUI::InputManager::getInstance().isShiftPressed() == false)
	{
		x1 = toGrid(_absx);
		y1 = toGrid(_absy);
	}
	else
	{
		x1 = _absx;
		y1 = _absy;
	}

	// юбилейный комит  =)
	mWidgetsWindow->startNewWidget(x1, y1, _id);

	// это чтобы можно было двигать пр¤моугольник у невидимых виджето (или виджетов за границами)
	//MyGUI::LayerItemInfoPtr rootItem = nullptr;
	//MyGUI::Widget* itemWithRect = static_cast<MyGUI::Widget*>(MyGUI::LayerManager::getInstance().findWidgetItem(_absx, _absy, rootItem));
	// не стал это доделывать, т.к. неоднозначность выбора виджета получаетс¤, если кто скажет как выбирать - сделаю

	MyGUI::Widget* item = MyGUI::LayerManager::getInstance().getWidgetFromPoint(_absx, _absy);

	// не убираем пр¤моугольник если нажали на его раст¤гивалку
	if (item && (item->getParent() != mPropertiesPanelView->getWidgetRectangle()))
	{
		// чтобы пр¤моугольник не мешалс¤
		mPropertiesPanelView->getWidgetRectangle()->setVisible(false);
		item = MyGUI::LayerManager::getInstance().getWidgetFromPoint(_absx, _absy);
	}

	if (nullptr != item)
	{
		// find widget registered as container
		while ((nullptr == ew->find(item)) && (nullptr != item)) item = item->getParent();
		MyGUI::Widget* oldItem = item;

		// try to selectin depth
		int depth = selectDepth;
		while (depth && (nullptr != item))
		{
			item = item->getParent();
			while ((nullptr == ew->find(item)) && (nullptr != item)) item = item->getParent();
			depth--;
		}
		if (nullptr == item)
		{
			item = oldItem;
			selectDepth = 0;
		}

		// found widget
		if (nullptr != item)
		{
			notifySelectWidget(item);
			if (mWidgetsWindow->getCreatingStatus() != 1)
			{
				//FIXME
				getGUI()->injectMouseMove(_absx, _absy, 0);// это чтобы сразу можно было тащить
			}
		}
		//FIXME
		getGUI()->injectMousePress(_absx, _absy, _id);
	}
	else
	{
		//FIXME
		getGUI()->injectMousePress(_absx, _absy, _id);
		notifySelectWidget(nullptr);
	}

	// вернем пр¤моугольник
	if (current_widget && mWidgetsWindow->getCreatingStatus() == 0)
	{
		mPropertiesPanelView->getWidgetRectangle()->setVisible(true);
	}
	else if (mWidgetsWindow->getCreatingStatus())
	{
		mPropertiesPanelView->getWidgetRectangle()->setVisible(false);
	}

	//base::BaseManager::injectMousePress(_absx, _absy, _id);
}