• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TTool类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TTool的典型用法代码示例。如果您正苦于以下问题:C++ TTool类的具体用法?C++ TTool怎么用?C++ TTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TTool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: FitnessEvaluation

//---------------------------------------------------------------------------
void TGenotype::FitnessEvaluation(TNet myNet, TEnviroment enviroment, TMyAgent platform, TTool tool, Tifo ifo){
    fitnes = 0; fitnes_temp = 0;
    int steps_per_time = 1;
    vector<double> inputVals;
    vector<double> resultVals;
    vector<double> Weights;
    vector<double> Gains;
    vector<double> T_consts;
    bool turn_left, turn_right;
    PhenotypeConvertion();
    for(unsigned i = 0; i < num_Weights; ++i)
        Weights.push_back(phenotypes[ i]);
    for(unsigned i = 0; i < num_Neurons; ++i){
        Gains.push_back(phenotypes_gain[ i]);
        T_consts.push_back(phenotypes_time_const[ i]);
    }
    myNet.setWeights(Weights);
    myNet.setGains(Gains);
    myNet.setTime_const(T_consts);
    for(int run = 0; run < (13+14*(Form1->steps-1)); ++run){
        tool.setInputValues(inputVals, platform, ifo);
        myNet.feedForward(inputVals);
        myNet.getResults(resultVals);
        tool.output(resultVals, turn_left, turn_right, steps_per_time);
        platform.Move(enviroment, turn_left, turn_right, steps_per_time);
        ifo.Move(enviroment);
        if(ifo.GetPosition_y() == 13)
            platform.FitnessUpdate(ifo);
    }  fitnes = platform.GetFitness();   fitnes_temp = platform.GetFitness();
    platform.setInitialConditions();
}
开发者ID:poqw0912iuer,项目名称:Beer_min_cog,代码行数:32,代码来源:TGenotype.cpp


示例2: changeColorStyle

void StrokeSelection::changeColorStyle(int styleIndex)
{
	TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
	if (!tool)
		return;
	TVectorImageP img(tool->getImage(true));
	if (!img)
		return;
	TPalette *palette = img->getPalette();
	TColorStyle *cs = palette->getStyle(styleIndex);
	if (!cs->isStrokeStyle())
		return;
	if (m_indexes.empty())
		return;

	UndoSetStrokeStyle *undo = new UndoSetStrokeStyle(img, styleIndex);
	std::set<int>::iterator it;
	for (it = m_indexes.begin(); it != m_indexes.end(); ++it) {
		int index = *it;
		assert(0 <= index && index < (int)img->getStrokeCount());
		TStroke *stroke = img->getStroke(index);
		undo->addStroke(stroke);
		stroke->setStyle(styleIndex);
	}

	tool->notifyImageChanged();
	TUndoManager::manager()->add(undo);
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:28,代码来源:strokeselection.cpp


示例3: removeEndpoints

void StrokeSelection::removeEndpoints()
{
	if (!m_vi)
		return;
	if (m_indexes.empty())
		return;

	vector<pair<int, TStroke *>> undoData;

	m_vi->findRegions();
	set<int>::iterator it = m_indexes.begin();
	for (; it != m_indexes.end(); ++it) {
		TStroke *s = m_vi->removeEndpoints(*it);
		if (s)
			undoData.push_back(pair<int, TStroke *>(*it, s));
	}
	TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
	TXshSimpleLevel *level = TTool::getApplication()->getCurrentLevel()->getSimpleLevel();
	if (!undoData.empty())
		TUndoManager::manager()->add(new RemoveEndpointsUndo(level, tool->getCurrentFid(), undoData));

	m_updateSelectionBBox = true;
	tool->notifyImageChanged();
	m_updateSelectionBBox = false;
}
开发者ID:ArseniyShestakov,项目名称:opentoonz,代码行数:25,代码来源:strokeselection.cpp


示例4: UpdateToolsPrices

// ---------------------------------------------------------------------------
void __fastcall TfSbornyZakaz::UpdateToolsPrices() {
	// найдем номеклатуры для оборудования
	for (int i = 0; i < listOfTools->Count; i++) {
		TTool *tool = dynamic_cast<TTool*>(listOfTools->Items[i]);
		tool->ToolFindPrice(agent->typeprice);
	}
}
开发者ID:Zummer,项目名称:calculate1c,代码行数:8,代码来源:UnitFormSborny.cpp


示例5: StrokesData

void StrokeSelection::deleteStrokes() {
  if (!m_vi) return;
  if (m_indexes.empty()) return;
  TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
  if (!tool) return;

  bool isSpline = tool->getApplication()->getCurrentObject()->isSpline();
  TUndo *undo;
  if (isSpline)
    undo = new ToolUtils::UndoPath(
        tool->getXsheet()->getStageObject(tool->getObjectId())->getSpline());

  StrokesData *data = new StrokesData();
  data->setImage(m_vi, m_indexes);
  std::set<int> oldIndexes = m_indexes;
  deleteStrokesWithoutUndo(m_vi, m_indexes);

  if (!isSpline) {
    TXshSimpleLevel *level =
        TTool::getApplication()->getCurrentLevel()->getSimpleLevel();
    TUndoManager::manager()->add(new DeleteStrokesUndo(
        level, tool->getCurrentFid(), oldIndexes, data, m_sceneHandle));
  } else {
    assert(undo);
    if (undo) TUndoManager::manager()->add(undo);
  }
}
开发者ID:luc--,项目名称:opentoonz,代码行数:27,代码来源:strokeselection.cpp


示例6: inputMethodEvent

void SceneViewer::inputMethodEvent(QInputMethodEvent *e) {
  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  if (tool && tool->isEnabled()) {
    tool->onInputText(e->preeditString().toStdWString(),
                      e->commitString().toStdWString(), e->replacementStart(),
                      e->replacementLength());
  }
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:8,代码来源:sceneviewerevents.cpp


示例7: leaveEvent

void SceneViewer::leaveEvent(QEvent *) {
  if (!m_isMouseEntered) return;

  m_isMouseEntered = false;

  if (m_freezedStatus != NO_FREEZED) return;
  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  if (tool && tool->isEnabled()) tool->onLeave();
  update();
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:10,代码来源:sceneviewerevents.cpp


示例8: setUnlinear

void ControlPointSelection::setUnlinear() {
  TTool *tool            = TTool::getApplication()->getCurrentTool()->getTool();
  int currentStrokeIndex = m_controlPointEditorStroke->getStrokeIndex();
  TVectorImageP vi(tool->getImage(false));
  if (!vi || isEmpty() || currentStrokeIndex == -1) return;

  TUndo *undo;
  if (tool->getApplication()->getCurrentObject()->isSpline())
    undo = new UndoPath(
        tool->getXsheet()->getStageObject(tool->getObjectId())->getSpline());
  else {
    TXshSimpleLevel *level =
        tool->getApplication()->getCurrentLevel()->getSimpleLevel();
    UndoControlPointEditor *cpEditorUndo =
        new UndoControlPointEditor(level, tool->getCurrentFid());
    cpEditorUndo->addOldStroke(currentStrokeIndex,
                               vi->getVIStroke(currentStrokeIndex));
    undo = cpEditorUndo;
  }
  if (m_controlPointEditorStroke->getControlPointCount() == 0) return;

  bool isChanged = m_controlPointEditorStroke->setControlPointsLinear(
      m_selectedPoints, false);

  if (!isChanged) return;
  TUndoManager::manager()->add(undo);
  tool->notifyImageChanged();
}
开发者ID:gab3d,项目名称:opentoonz,代码行数:28,代码来源:controlpointselection.cpp


示例9: LockWindowUpdate

double TfSbornyZakaz::Sum() {
	LockWindowUpdate(Handle);
	double sum = 0;

	// здесь сбрасываем использование принтеров
	for (int i = 0; i < listOfTools->Count; i++) {
		TTool *tool = (TTool*)listOfTools->Items[i];
		tool->SetUse(false);
	}

	// чистим
	slgoods->Clear();
	Memo1->Clear();
	sldescription->Clear();

	if (sbForSelFrame->ControlCount == 0) {
		sum = 0;
	}
	else {
		// поищем что есть посчитать, все фреймы, виртуальная функция Sum
		for (int i = 0; i < listOfIzdelies->Count; i++) {
			TfrSelectable *izdelie =
				dynamic_cast<TfrSelectable*>(listOfIzdelies->Items[i]);
			sum += izdelie->Sum();
		}

		double zakazCount = spCount->Value;
		// подсчитаем использование оборудования
		for (int i = 0; i < listOfTools->Count; i++) {
			TToolPrepareTool *tool =
				dynamic_cast<TToolPrepareTool*>(listOfTools->Items[i]);
			if (tool && tool->GetUse() == true) {
				Memo1->Lines->Add(tool->prepareTool->myToString(zakazCount));
				sum += Ceil(tool->prepareTool->price * zakazCount);
			}
		}

	}

	lbAllPrice->Caption = "Сумма: " + FloatToStrF(sum, ffFixed, 10, 2) +
		" руб.";

	allsum = sum;

	LockWindowUpdate(NULL);
	return sum;
}
开发者ID:Zummer,项目名称:calculate1c,代码行数:47,代码来源:UnitFormSborny.cpp


示例10: vi

void ControlPointSelection::deleteControlPoints() {
  TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
  TVectorImageP vi(tool->getImage(false));
  int currentStrokeIndex = m_controlPointEditorStroke->getStrokeIndex();
  if (!vi || isEmpty() || currentStrokeIndex == -1) return;

  // Inizializzo l'UNDO
  TUndo *undo;
  bool isCurrentObjectSpline =
      tool->getApplication()->getCurrentObject()->isSpline();
  if (isCurrentObjectSpline)
    undo = new UndoPath(
        tool->getXsheet()->getStageObject(tool->getObjectId())->getSpline());
  else {
    TXshSimpleLevel *level =
        tool->getApplication()->getCurrentLevel()->getSimpleLevel();
    UndoControlPointEditor *cpEditorUndo =
        new UndoControlPointEditor(level, tool->getCurrentFid());
    cpEditorUndo->addOldStroke(currentStrokeIndex,
                               vi->getVIStroke(currentStrokeIndex));
    undo = cpEditorUndo;
  }

  int i;
  for (i = m_controlPointEditorStroke->getControlPointCount() - 1; i >= 0; i--)
    if (isSelected(i)) m_controlPointEditorStroke->deleteControlPoint(i);

  if (m_controlPointEditorStroke->getControlPointCount() == 0) {
    m_controlPointEditorStroke->setStroke((TVectorImage *)0, -1);
    if (!isCurrentObjectSpline) {
      UndoControlPointEditor *cpEditorUndo =
          dynamic_cast<UndoControlPointEditor *>(undo);
      if (cpEditorUndo) cpEditorUndo->isStrokeDelete(true);
    }
  }

  // La spline non puo' essere cancellata completamente!!!
  if (vi->getStrokeCount() == 0) {
    if (TTool::getApplication()->getCurrentObject()->isSpline()) {
      std::vector<TPointD> points;
      double d = 10;
      points.push_back(TPointD(-d, 0));
      points.push_back(TPointD(0, 0));
      points.push_back(TPointD(d, 0));
      TStroke *stroke = new TStroke(points);
      vi->addStroke(stroke, false);
      m_controlPointEditorStroke->setStrokeIndex(0);
    }
  }
  tool->notifyImageChanged();
  selectNone();
  // Registro l'UNDO
  TUndoManager::manager()->add(undo);
}
开发者ID:gab3d,项目名称:opentoonz,代码行数:54,代码来源:controlpointselection.cpp


示例11: initToonzEvent

void SceneViewer::mouseDoubleClickEvent(QMouseEvent *event) {
  if (m_freezedStatus != NO_FREEZED) return;

  int frame = TApp::instance()->getCurrentFrame()->getFrame();
  if (frame == -1) return;

  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  if (!tool || !tool->isEnabled()) return;
  TMouseEvent toonzEvent;
  initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true);
  TPointD pos              = tool->getMatrix().inv() * winToWorld(event->pos());
  TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
  if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
    pos.x /= m_dpiScale.x;
    pos.y /= m_dpiScale.y;
  }

  if (event->button() == Qt::LeftButton)
    tool->leftButtonDoubleClick(pos, toonzEvent);
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:20,代码来源:sceneviewerevents.cpp


示例12: fakeRelease

void SceneViewer::contextMenuEvent(QContextMenuEvent *e) {
#ifndef _WIN32
  /* On windows the widget receive the release event before the menu
     is shown, on linux and osx the release event is lost, never
     received by the widget */
  QMouseEvent fakeRelease(QEvent::MouseButtonRelease, e->pos(), Qt::RightButton,
                          Qt::NoButton, Qt::NoModifier);

  QApplication::instance()->sendEvent(this, &fakeRelease);
#endif

  if (m_freezedStatus != NO_FREEZED) return;
  if (m_isLocator) return;

  TPoint winPos(e->pos().x(), height() - e->pos().y());
  std::vector<int> columnIndices;
  // enable to select all the columns regardless of the click position
  for (int i = 0;
       i < TApp::instance()->getCurrentXsheet()->getXsheet()->getColumnCount();
       i++)
    columnIndices.push_back(i);

  SceneViewerContextMenu *menu = new SceneViewerContextMenu(this);

  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  TPointD pos =
      ((tool) ? tool->getMatrix().inv() : TAffine()) * winToWorld(e->pos());
  menu->addEnterGroupCommands(pos);

  menu->addLevelCommands(columnIndices);

  ComboViewerPanel *cvp = qobject_cast<ComboViewerPanel *>(
      parentWidget()->parentWidget()->parentWidget());
  if (cvp) {
    menu->addSeparator();
    cvp->addShowHideContextMenu(menu);
  }

  menu->exec(e->globalPos());
  delete menu;
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:41,代码来源:sceneviewerevents.cpp


示例13: enterEvent

void SceneViewer::enterEvent(QEvent *) {
  if (m_isMouseEntered) return;

  m_isMouseEntered = true;

  TApp *app        = TApp::instance();
  modifiers        = 0;
  TTool *tool      = app->getCurrentTool()->getTool();
  TXshLevel *level = app->getCurrentLevel()->getLevel();
  if (level && level->getSimpleLevel())
    m_dpiScale =
        getCurrentDpiScale(level->getSimpleLevel(), tool->getCurrentFid());
  else
    m_dpiScale = TPointD(1, 1);

  if (m_freezedStatus != NO_FREEZED) return;

  invalidateToolStatus();
  if (tool && tool->isEnabled()) {
    tool->setViewer(this);
    tool->updateMatrix();
    tool->onEnter();
  }

  setFocus();
  updateGL();
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:27,代码来源:sceneviewerevents.cpp


示例14: if

void SceneViewer::keyReleaseEvent(QKeyEvent *event) {
  if (m_freezedStatus != NO_FREEZED) return;

  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  if (!tool || !tool->isEnabled()) return;
  tool->setViewer(this);

  int key = event->key();

  if (key == Qt::Key_Shift || key == Qt::Key_Control || key == Qt::Key_Alt ||
      key == Qt::Key_AltGr) {
    if (key == Qt::Key_Shift)
      modifiers &= ~Qt::ShiftModifier;
    else if (key == Qt::Key_Control)
      modifiers &= ~Qt::ControlModifier;
    else if (key == Qt::Key_Alt || key == Qt::Key_AltGr)
      modifiers &= ~Qt::AltModifier;

    // quando l'utente preme shift/ctrl ecc. alcuni tool (es. pinch) devono
    // cambiare subito la forma del cursore, senza aspettare il prossimo move
    TMouseEvent toonzEvent;
    initToonzEvent(toonzEvent, event);
    toonzEvent.m_pos =
        TPoint(m_lastMousePos.x(), height() - 1 - m_lastMousePos.y());

    TPointD pos = tool->getMatrix().inv() * winToWorld(m_lastMousePos);

    TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
    if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
      pos.x /= m_dpiScale.x;
      pos.y /= m_dpiScale.y;
    }

    tool->mouseMove(pos, toonzEvent);
    setToolCursor(this, tool->getCursorId());
  }

  if (tool->getName() == T_Type)
    event->accept();
  else
    event->ignore();
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:42,代码来源:sceneviewerevents.cpp


示例15: execute

  void execute() override {
    TColumnSelection *selection = dynamic_cast<TColumnSelection *>(
        TApp::instance()->getCurrentSelection()->getSelection());
    TXsheet *xsh       = TApp::instance()->getCurrentXsheet()->getXsheet();
    int cc             = TApp::instance()->getCurrentColumn()->getColumnIndex();
    bool sound_changed = false;
    TTool *tool        = TApp::instance()->getCurrentTool()->getTool();
    TTool::Viewer *viewer = tool ? tool->getViewer() : nullptr;
    bool viewer_changed   = false;

    for (int i = 0; i < xsh->getColumnCount(); i++) {
      /*- 空のカラムの場合は飛ばす -*/
      if (xsh->isColumnEmpty(i)) continue;
      /*- カラムが取得できなかったら飛ばす -*/
      TXshColumn *column = xsh->getColumn(i);
      if (!column) continue;
      /*- ターゲットが選択カラムのモードで、選択されていなかった場合は飛ばす -*/
      bool isSelected = selection && selection->isColumnSelected(i);
      if (m_target == TARGET_SELECTED && !isSelected) continue;

      /*-
       * ターゲットが「カレントカラムより右側」のモードで、iがカレントカラムより左の場合は飛ばす
       * -*/
      if (m_target == TARGET_UPPER && i < cc) continue;

      bool negate = m_target == TARGET_CURRENT && cc != i ||
                    m_target == TARGET_OTHER && cc == i ||
                    m_target == TARGET_UPPER && cc == i;

      int cmd = m_cmd;

      if (cmd & (CMD_LOCK | CMD_UNLOCK | CMD_TOGGLE_LOCK)) {
        if (cmd & CMD_LOCK)
          column->lock(!negate);
        else if (cmd & CMD_UNLOCK)
          column->lock(negate);
        else
          column->lock(!column->isLocked());
        viewer_changed = true;
      }
      if (cmd &
          (CMD_ENABLE_PREVIEW | CMD_DISABLE_PREVIEW | CMD_TOGGLE_PREVIEW)) {
        if (cmd & CMD_ENABLE_PREVIEW)
          column->setPreviewVisible(!negate);
        else if (cmd & CMD_DISABLE_PREVIEW)
          column->setPreviewVisible(negate);
        else
          column->setPreviewVisible(!column->isPreviewVisible());
      }
      if (cmd &
          (CMD_ENABLE_CAMSTAND | CMD_DISABLE_CAMSTAND | CMD_TOGGLE_CAMSTAND)) {
        if (cmd & CMD_ENABLE_CAMSTAND)
          column->setCamstandVisible(!negate);
        else if (cmd & CMD_DISABLE_CAMSTAND)
          column->setCamstandVisible(negate);
        else
          column->setCamstandVisible(!column->isCamstandVisible());
        if (column->getSoundColumn()) sound_changed = true;
        viewer_changed                              = true;
      }
      /*TAB
if(cmd & (CMD_ENABLE_PREVIEW|CMD_DISABLE_PREVIEW|CMD_TOGGLE_PREVIEW))
{ //In Tab preview e cameraStand vanno settati entrambi
if(cmd&CMD_ENABLE_PREVIEW)
{
column->setPreviewVisible(!negate);
column->setCamstandVisible(!negate);
}
else if(cmd&CMD_DISABLE_PREVIEW)
{
column->setPreviewVisible(negate);
column->setCamstandVisible(negate);
}
else
{
column->setPreviewVisible(!column->isPreviewVisible());
column->setCamstandVisible(!column->isCamstandVisible());
}
}
      */
    }
    if (sound_changed)
      TApp::instance()->getCurrentXsheet()->notifyXsheetSoundChanged();
    TApp::instance()->getCurrentXsheet()->notifyXsheetChanged();
    TApp::instance()->getCurrentScene()->setDirtyFlag(true);
    if (viewer && viewer_changed) viewer->invalidateToolStatus();
  }
开发者ID:opentoonz,项目名称:opentoonz,代码行数:87,代码来源:columncommand.cpp


示例16: setToolCursor

void SceneViewer::mouseMoveEvent(QMouseEvent *event) {
  if (m_freezedStatus != NO_FREEZED) return;

  QPoint curPos  = event->pos();
  bool cursorSet = false;
  m_lastMousePos = curPos;

  if (m_editPreviewSubCamera) {
    if (!PreviewSubCameraManager::instance()->mouseMoveEvent(this, event))
      return;
  }

  // if the "compare with snapshot" mode is activated, change the mouse cursor
  // on the border handle
  if (m_visualSettings.m_doCompare) {
    if (abs(curPos.x() - width() * m_compareSettings.m_compareX) < 20) {
      cursorSet = true;
      setToolCursor(this, ToolCursor::ScaleHCursor);
    } else if (abs((height() - curPos.y()) -
                   height() * m_compareSettings.m_compareY) < 20) {
      cursorSet = true;
      setToolCursor(this, ToolCursor::ScaleVCursor);
    }
  }

  // control of the border handle when the "compare with snapshot" mode is
  // activated
  if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY) {
    if (m_compareSettings.m_dragCompareX)
      m_compareSettings.m_compareX +=
          ((double)(curPos.x() - m_pos.x())) / width();
    else if (m_compareSettings.m_dragCompareY)
      m_compareSettings.m_compareY -=
          ((double)(curPos.y() - m_pos.y())) / height();
    m_compareSettings.m_compareX =
        tcrop(m_compareSettings.m_compareX, 0.0, 1.0);
    m_compareSettings.m_compareY =
        tcrop(m_compareSettings.m_compareY, 0.0, 1.0);

    update();

    m_pos = curPos;
  } else if (m_mouseButton == Qt::NoButton || m_mouseButton == Qt::LeftButton) {
    if (is3DView() && m_current3DDevice != NONE &&
        m_mouseButton == Qt::LeftButton)
      return;
    else if (is3DView() && m_mouseButton == Qt::NoButton) {
      TRectD rect = TRectD(TPointD(m_topRasterPos.x, m_topRasterPos.y),
                           TDimensionD(20, 20));
      if (rect.contains(TPointD(curPos.x(), curPos.y())))
        m_current3DDevice = TOP_3D;
      else {
        rect = TRectD(TPointD(m_sideRasterPos.x, m_sideRasterPos.y),
                      TDimensionD(20, 20));
        if (rect.contains(TPointD(curPos.x(), curPos.y()))) {
          if (m_phi3D > 0)
            m_current3DDevice = SIDE_RIGHT_3D;
          else
            m_current3DDevice = SIDE_LEFT_3D;
        } else
          m_current3DDevice = NONE;
      }
      if (m_current3DDevice != NONE) {
        cursorSet = true;
        setToolCursor(this, ToolCursor::CURSOR_ARROW);
      }
    }

    // if the middle mouse button is pressed while dragging, then do panning
    Qt::MouseButtons mousebuttons;
    mousebuttons = event->buttons();
    if (mousebuttons & Qt::MidButton) {
      // panning
      QPoint p = curPos - m_pos;
      if (m_pos == QPoint(0, 0) && p.manhattanLength() > 300) return;
      panQt(curPos - m_pos);
      m_pos = curPos;
      return;
    }

    TTool *tool = TApp::instance()->getCurrentTool()->getTool();
    if (!tool || !tool->isEnabled()) {
      m_tabletEvent = false;
      return;
    }
    tool->setViewer(this);
    TMouseEvent toonzEvent;
    initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
                   false);
    TPointD worldPos = winToWorld(curPos);
    TPointD pos      = tool->getMatrix().inv() * worldPos;

    if (m_locator) {
      m_locator->onChangeViewAff(worldPos);
    }

    TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
    if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
      pos.x /= m_dpiScale.x;
      pos.y /= m_dpiScale.y;
//.........这里部分代码省略.........
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:101,代码来源:sceneviewerevents.cpp


示例17: lock

void StrokeSelection::paste() {
  TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
  if (!tool) return;
  if (TTool::getApplication()->getCurrentObject()->isSpline()) {
    const StrokesData *stData = dynamic_cast<const StrokesData *>(
        QApplication::clipboard()->mimeData());
    if (!stData) return;
    TVectorImageP splineImg = tool->getImage(true);
    TVectorImageP img       = stData->m_image;
    if (!splineImg || !img) return;

    QMutexLocker lock(splineImg->getMutex());
    TUndo *undo = new ToolUtils::UndoPath(
        tool->getXsheet()->getStageObject(tool->getObjectId())->getSpline());
    while (splineImg->getStrokeCount() > 0) splineImg->deleteStroke(0);

    TStroke *stroke = img->getStroke(0);
    splineImg->addStroke(new TStroke(*stroke), false);
    TUndoManager::manager()->add(undo);
    tool->notifyImageChanged();
    tool->invalidate();
    return;
  }

  TVectorImageP tarImg = tool->touchImage();
  if (!tarImg) return;
  TPaletteP palette       = tarImg->getPalette();
  TPaletteP oldPalette    = new TPalette();
  if (palette) oldPalette = palette->clone();
  bool isPaste = pasteStrokesWithoutUndo(tarImg, m_indexes, m_sceneHandle);
  if (isPaste) {
    TXshSimpleLevel *level =
        TTool::getApplication()->getCurrentLevel()->getSimpleLevel();
    TUndoManager::manager()->add(new PasteStrokesUndo(
        level, tool->getCurrentFid(), m_indexes, oldPalette, m_sceneHandle));
    m_updateSelectionBBox = isPaste;
  }
  tool->notifyImageChanged();
  tool->getApplication()
      ->getPaletteController()
      ->getCurrentLevelPalette()
      ->notifyPaletteChanged();
  m_updateSelectionBBox = false;
  tool->invalidate();
}
开发者ID:luc--,项目名称:opentoonz,代码行数:45,代码来源:strokeselection.cpp


示例18: ExecuteCommand

bool TMainTool::ExecuteCommand(const std::string& InTarget, std::string& InCommand, std::vector<Environment::VoidPointer>& InOutArguments)
{
	TTool* target = nullptr;
	std::string functionName;
	if (InTarget != "")
	{
		functionName = "cmd_" + InCommand;
		std::string targetName = InTarget;
		target = Container->GetElement<TTool>(targetName);
		if (target)
		{
			auto p_attribute = target->GetAttribute(functionName);
			if (p_attribute && p_attribute->Object().CastTo<RFunction*>())
			{
				//targetArgs = std::vector<VoidPointer>(args.begin() + 2, args.end());
			}
			else
			{
				target = nullptr;
			}
		}
		else
		{
			target = nullptr;
		}
	}
	else
	{
		functionName = "cmd_" + InCommand;
		std::vector<TTool*> targets = Container->GetElementsWithAttribute<TTool, RFunction*>(functionName);
		if (targets.size() == 0)
			Dialogue->WriteLine("Could not find tool with function :" + functionName);
		else if (targets.size() > 1)
		{
			Dialogue->WriteLine("Function name is ambigious. Try to specify your target via: @target " + functionName + '\n'
				+ "Following target are available: ");
			for (auto target : targets)
			{
				Dialogue->WriteLine(target->GetName());
			}
		}
		else
		{
			target = targets[0];
			//targetArgs = std::vector<VoidPointer>(args.begin() + 1, args.end());
		}
	}

	if (target == nullptr)
	{
		Dialogue->WriteLine("Could not find tool");
		return false;
	}
	else
	{
		bool success = target->GetAttribute(functionName)->Object().CastAndDereference<RFunction*>()->CorrectArgsAndExecute(InOutArguments);
		if (!success)
		{
			LOG("Command '" + functionName + "' returned false.", Logger::Severity::Warning);
		}
		return success;
	}
}
开发者ID:zustudio,项目名称:SOIA_OLD,代码行数:63,代码来源:TMainTool.cpp


示例19: set3DLeftSideView

void SceneViewer::mouseReleaseEvent(QMouseEvent *event) {
  // evita i release ripetuti
  if (!m_buttonClicked) return;
  m_buttonClicked = false;

  TTool *tool = TApp::instance()->getCurrentTool()->getTool();
  if (!tool || !tool->isEnabled()) {
    if (!m_toolDisableReason.isEmpty() && m_mouseButton == Qt::LeftButton &&
        !m_editPreviewSubCamera)
      DVGui::warning(m_toolDisableReason);
  }

  if (m_freezedStatus != NO_FREEZED) return;

  if (m_mouseButton != event->button()) return;

  if (m_current3DDevice != NONE) {
    m_mouseButton = Qt::NoButton;
    m_tabletEvent = false;
    m_pressure    = 0;
    if (m_current3DDevice == SIDE_LEFT_3D)
      set3DLeftSideView();
    else if (m_current3DDevice == SIDE_RIGHT_3D)
      set3DRightSideView();
    else if (m_current3DDevice == TOP_3D)
      set3DTopView();
    return;
  }

  if (m_mouseButton == Qt::LeftButton && m_editPreviewSubCamera) {
    if (!PreviewSubCameraManager::instance()->mouseReleaseEvent(this, event))
      goto quit;
  }

  if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY) {
    m_compareSettings.m_dragCompareX = m_compareSettings.m_dragCompareY = false;
    goto quit;
  }

  m_pos = QPoint(0, 0);
  if (!tool || !tool->isEnabled()) goto quit;

  tool->setViewer(this);

  {
    TMouseEvent toonzEvent;
    initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent,
                   false);
    TPointD pos = tool->getMatrix().inv() * winToWorld(event->pos());

    TObjectHandle *objHandle = TApp::instance()->getCurrentObject();
    if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) {
      pos.x /= m_dpiScale.x;
      pos.y /= m_dpiScale.y;
    }

    if (m_mouseButton == Qt::LeftButton) {
      tool->leftButtonUp(pos, toonzEvent);
      TApp::instance()->getCurrentTool()->setToolBusy(false);
    }
  }

quit:

  m_mouseButton = Qt::NoButton;
  m_tabletEvent = false;
  m_pressure    = 0;
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:68,代码来源:sceneviewerevents.cpp


示例20: event

bool SceneViewer::event(QEvent *e) {
  if (e->type() == QEvent::ShortcutOverride || e->type() == QEvent::KeyPress) {
    if (!((QKeyEvent *)e)->isAutoRepeat()) {
      TApp::instance()->getCurrentTool()->storeTool();
    }
  }
  if (e->type() == QEvent::ShortcutOverride) {
    TTool *tool = TApp::instance()->getCurrentTool()->getTool();
    if (tool && tool->isEnabled() && tool->getName() == T_Type &&
        tool->isActive())
      e->accept();
    return true;
  }
  if (e->type() == QEvent::KeyRelease) {
    if (!((QKeyEvent *)e)->isAutoRepeat()) {
      QWidget *focusWidget = QApplication::focusWidget();
      if (focusWidget == 0 ||
          QString(focusWidget->metaObject()->className()) == "SceneViewer")
        TApp::instance()->getCurrentTool()->restoreTool();
    }
  }

  // discard too frequent move events
  static QTime clock;
  if (e->type() == QEvent::MouseButtonPress)
    clock.start();
  else if (e->type() == QEvent::MouseMove) {
    if (clock.elapsed() < 10) {
      e->accept();
      return true;
    }
    clock.start();
  }

  /*
switch(e->type())
{
case QEvent::Enter:
qDebug() << "************************** Enter";
break;
case QEvent::Leave:
qDebug() << "************************** Leave";
break;

case QEvent::TabletPress:
qDebug() << "************************** TabletPress"  << m_pressure;
break;
case QEvent::TabletMove:
qDebug() << "************************** TabletMove";
break;
case QEvent::TabletRelease:
qDebug() << "************************** TabletRelease";
break;


case QEvent::MouseButtonPress:
qDebug() << "**************************MouseButtonPress"  << m_pressure << " "
<< m_tabletEvent;
break;
case QEvent::MouseMove:
qDebug() << "**************************MouseMove" <<  m_pressure;
break;
case QEvent::MouseButtonRelease:
qDebug() << "**************************MouseButtonRelease";
break;

case QEvent::MouseButtonDblClick:
qDebug() << "============================== MouseButtonDblClick";
break;
}
*/

  return QGLWidget::event(e);
}
开发者ID:hvfrancesco,项目名称:opentoonz,代码行数:74,代码来源:sceneviewerevents.cpp



注:本文中的TTool类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TTree类代码示例发布时间:2022-05-31
下一篇:
C++ TTm类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap