示例#1
0
void GLWidget::mousePressEvent(QMouseEvent *event)
{
    if(!_isActive) Workspace::setActiveWidget(this);

    if(!toolIsOn) startPosition = lastPosition = QVector2D(event->x() - _width / 2, _height / 2 - event->y());
    if(quickAccess) return;

    switch(event->buttons())
    {
    case Qt::LeftButton:
    {
        Tool *aT = activeTool();
        //  ! stage2     hasStage2 == true && stage2 == false
        //               hasStage2 == false
        //  hasStage2 ? !stage2 : true
        if(aT->hasStage2() ? !aT->stage2() : true) aT->function(START, event);

        break;
    }
    case Qt::RightButton:
    {
        quickAccessToolOrbit();
        quickAccess = true;
        break;
    }
    case Qt::MiddleButton:
    {
        quickAccessToolPan();
        quickAccess = true;
    }
    }
}
示例#2
0
void GameController::Update()
{
	ui::Point pos = gameView->GetMousePosition();
	gameModel->GetRenderer()->mousePos = PointTranslate(pos);
	if (pos.X < XRES && pos.Y < YRES)
		gameView->SetSample(gameModel->GetSimulation()->GetSample(PointTranslate(pos).X, PointTranslate(pos).Y));
	else
		gameView->SetSample(gameModel->GetSimulation()->GetSample(pos.X, pos.Y));

	Simulation * sim = gameModel->GetSimulation();
	sim->update_particles();

	//if either STKM or STK2 isn't out, reset it's selected element. Defaults to PT_DUST unless right selected is something else
	//This won't run if the stickmen dies in a frame, since it respawns instantly
	if (!sim->player.spwn || !sim->player2.spwn)
	{
		int rightSelected = PT_DUST;
		Tool * activeTool = gameModel->GetActiveTool(1);
		if (activeTool->GetIdentifier().find("DEFAULT_PT_") != activeTool->GetIdentifier().npos)
		{
			int sr = activeTool->GetToolID();
			if ((sr>0 && sr<PT_NUM && sim->elements[sr].Enabled && sim->elements[sr].Falldown>0) || sr==SPC_AIR || sr == PT_NEUT || sr == PT_PHOT || sr == PT_LIGH)
				rightSelected = sr;
		}

		if (!sim->player.spwn)
			sim->player.elem = rightSelected;
		if (!sim->player2.spwn)
			sim->player2.elem = rightSelected;
	}
	if(renderOptions && renderOptions->HasExited)
	{
		delete renderOptions;
		renderOptions = NULL;
	}

	if(search && search->HasExited)
	{
		delete search;
		search = NULL;
	}

	if(activePreview && activePreview->HasExited)
	{
		delete activePreview;
		activePreview = NULL;
	}

	if(loginWindow && loginWindow->HasExited)
	{
		delete loginWindow;
		loginWindow = NULL;
	}

	if(localBrowser && localBrowser->HasDone)
	{
		delete localBrowser;
		localBrowser = NULL;
	}
}
示例#3
0
// Turn off the heaters, disable the motors, and deactivate the Heat and Move classes. Leave everything else working.
void RepRap::EmergencyStop()
{
	stopped = true;

	// Do not turn off ATX power here. If the nozzles are still hot, don't risk melting any surrounding parts...
	//platform->SetAtxPower(false);

	Tool* tool = toolList;
	while (tool != nullptr)
	{
		tool->Standby();
		tool = tool->Next();
	}

	heat->Exit();
	for(size_t heater = 0; heater < HEATERS; heater++)
	{
		platform->SetHeater(heater, 0.0);
	}

	// We do this twice, to avoid an interrupt switching a drive back on. move->Exit() should prevent interrupts doing this.
	for(int i = 0; i < 2; i++)
	{
		move->Exit();
		for(size_t drive = 0; drive < DRIVES; drive++)
		{
			platform->SetMotorCurrent(drive, 0.0, false);
			platform->DisableDrive(drive);
		}
	}
}
/**
 *	This method renders the terrain texture tool, by projecting the texture 
 *	onto the relevant terrain chunks as indicated in tool.relevantChunks().
 *
 *	@param	tool	The tool that we are viewing.
 */
void TerrainTextureToolView::render( const Tool & tool )
{
	EditorChunkTerrainPtrs spChunks;

	ChunkPtrVector::const_iterator it  = tool.relevantChunks().begin();
	ChunkPtrVector::const_iterator end = tool.relevantChunks().end();

	while (it != end)
	{
		Chunk * pChunk = *it++;
		
		EditorChunkTerrain * pChunkTerrain = 
			static_cast<EditorChunkTerrain*>(
				ChunkTerrainCache::instance( *pChunk ).pTerrain());

		if (pChunkTerrain != NULL)
		{
			spChunks.push_back( pChunkTerrain );
		}
	}

	EditorChunkTerrainProjector::instance().projectTexture(
			pTexture_,
			tool.size(),
			rotation_,			
			tool.locator()->transform().applyToOrigin(),
			D3DTADDRESS_BORDER,
			spChunks,
			showHoles_ );
}
示例#5
0
文件: P_UIVR.C 项目: tmd-gpat/MOLding
Tool *UIVR::create_tool(const char *type) {
  Displayable *parent = &(app->scene->root);
  Tool *newtool = NULL;
  if(!strupncmp(type, "grab", 10)) 
    newtool = new GrabTool(tool_serialno++, app, parent);
  else if(!strupncmp(type, "joystick", 10)) 
    newtool = new JoystickTool(tool_serialno++, app, parent);
  else if(!strupncmp(type, "tug", 10)) 
    newtool = new TugTool(tool_serialno++,app, parent);
  else if(!strupncmp(type, "pinch", 10)) 
    newtool = new PinchTool(tool_serialno++,app, parent);
  else if(!strupncmp(type, "spring", 10)) 
    newtool = new SpringTool(tool_serialno++,app, parent);
  else if(!strupncmp(type, "print", 10)) 
    newtool = new PrintTool(tool_serialno++, app, parent);
  
#ifdef VMDVRPN
  // XXX why is only this tool protected by the ifdef??
  else if(!strupncmp(type, "rotate", 10)) 
    newtool = new RotateTool(tool_serialno++,app, parent);
#endif
  else {
    msgErr << "Unrecognized tool type " << type << sendmsg;
    msgErr << "possiblities are:";
    for(int i=0;i<num_tool_types();i++) msgErr << " " << tool_types.name(i);
    msgErr << sendmsg;
    return NULL;
  }
  newtool->On();
  newtool->grabs = 0;
  return newtool;
}
示例#6
0
ToolBar::ToolBar()
  : Widget(kGenericWidget)
  , m_openedRecently(false)
  , m_tipTimer(300, this)
{
  m_instance = this;

  this->border_width.l = 1*jguiscale();
  this->border_width.t = 0;
  this->border_width.r = 1*jguiscale();
  this->border_width.b = 0;

  m_hotTool = NULL;
  m_hotIndex = NoneIndex;
  m_openOnHot = false;
  m_popupWindow = NULL;
  m_currentStrip = NULL;
  m_tipWindow = NULL;
  m_tipOpened = false;

  ToolBox* toolbox = App::instance()->getToolBox();
  for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
    Tool* tool = *it;
    if (m_selectedInGroup.find(tool->getGroup()) == m_selectedInGroup.end())
      m_selectedInGroup[tool->getGroup()] = tool;
  }
}
示例#7
0
void outputLine( ostream &output, const Tool &record )
{
   output << left << setw( 10 ) << record.getRec()
      << setw( 16 ) << record.getTool()
      << setw( 5 ) << record.getQuant()
      << setw( 10 ) << setprecision( 2 ) << right << fixed
      << showpoint << record.getPrice()<<"$" << endl;
} // end function outputLine
void GameController::ToolClick(int toolSelection, ui::Point point)
{
	Simulation * sim = gameModel->GetSimulation();
	Tool * activeTool = gameModel->GetActiveTool(toolSelection);
	Brush * cBrush = gameModel->GetBrush();
	if(!activeTool || !cBrush)
		return;
	activeTool->Click(sim, cBrush, point);
}
示例#9
0
文件: P_UIVR.C 项目: tmd-gpat/MOLding
int UIVR::set_buttons(int toolnum, const char *device) {
  Tool *tool = gettool(toolnum);
  if (!tool) return FALSE;
  if (device == NULL) {
    tool->add_buttons(NULL, NULL);
    return TRUE;
  }
  return add_device_to_tool(device, tool);
}
示例#10
0
void Tool::ClearTemperatureFault(int8_t heater)
{
	Tool* n = this;
	while (n != nullptr)
	{
		n->ResetTemperatureFault(heater);
		n = n->Next();
	}
}
示例#11
0
/*
 * Main will run auDiskTool. This tool will
 * scan disk data and send records to a report.
 * Configuration may be manipulated.
 */
int main()
{
	Tool auDiskTool;
	
	auDiskTool.init();
	auDiskTool.menu();
	auDiskTool.exit();
	return 0;
}
/**
 *	Update method
 */
void MatrixPositioner::update( float dTime, Tool& tool )
{
	// see if we want to commit this action
	if (!InputDevices::isKeyDown( KeyEvent::KEY_LEFTMOUSE ))
	{
		if (matrix_->hasChanged())
		{
			// set its transform permanently
			matrix_->commitState( false );
		}
		else
		{
			matrix_->commitState( true );
		}


		// and this tool's job is over
		ToolManager::instance().popTool();
		return;
	}

	// figure out movement
	if (tool.locator())
	{
		if (!gotInitialLocatorPos_)
		{
			lastLocatorPos_ = tool.locator()->transform().applyToOrigin();
			gotInitialLocatorPos_ = true;
		}

		totalLocatorOffset_ += tool.locator()->transform().applyToOrigin() - lastLocatorPos_;
		lastLocatorPos_ = tool.locator()->transform().applyToOrigin();


		// reset the last change we made
		matrix_->commitState( true );


		Matrix m;
		matrix_->getMatrix( m );

		Vector3 newPos = m.applyToOrigin() + totalLocatorOffset_;

		SnapProvider::instance()->snapPosition( newPos );

		m.translation( newPos );

		Matrix worldToLocal;
		matrix_->getMatrixContextInverse( worldToLocal );

		m.postMultiply( worldToLocal );


		matrix_->setMatrix( m );
	}
}
示例#13
0
//cppcheck-suppress unusedFunction
void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
{
    QHash<quint32, VDataTool*>* tools = doc->getTools();
    SCASSERT(tools != nullptr);
    Tool *tool = qobject_cast<Tool*>(tools->value(node.getId()));
    SCASSERT(tool != nullptr);
    connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
    tool->setParentItem(this);
    doc->IncrementReferens(node.getId());
}
示例#14
0
文件: P_UIVR.C 项目: tmd-gpat/MOLding
int UIVR::change_type(int toolnum, const char *type) {
  if (toolnum < 0 || toolnum >= tools.num()) return FALSE;
  Tool *newtool = create_tool(type);
  if (!newtool) return FALSE;
  Tool *oldtool = tools[toolnum];
  newtool->steal_sensor(oldtool);
  delete oldtool;
  tools[toolnum] = newtool;
  return TRUE;
}
示例#15
0
文件: P_UIVR.C 项目: tmd-gpat/MOLding
int UIVR::set_spring_scale(int toolnum, float newval) {
  if (newval >= 0) {
    Tool *tool = gettool(toolnum);
    if (tool) {
      tool->setspringscale(newval);
      return TRUE;
    }
  }
  return FALSE;
}
示例#16
0
Tool* ToolBox::getToolById(const std::string& id)
{
  for (ToolIterator it = begin(), end = this->end(); it != end; ++it) {
    Tool* tool = *it;
    if (tool->getId() == id)
      return tool;
  }
  // PRINTF("Error get_tool_by_name() with '%s'\n", name.c_str());
  // ASSERT(false);
  return NULL;
}
void GameController::DrawFill(int toolSelection, ui::Point point)
{
	Simulation * sim = gameModel->GetSimulation();
	Tool * activeTool = gameModel->GetActiveTool(toolSelection);
	gameModel->SetLastTool(activeTool);
	Brush * cBrush = gameModel->GetBrush();
	if(!activeTool || !cBrush)
		return;
	activeTool->SetStrength(gameModel->GetToolStrength());
	activeTool->DrawFill(sim, cBrush, point);
}
示例#18
0
void RepRap::PrintTool(int toolNumber, StringRef& reply) const
{
	Tool* tool = GetTool(toolNumber);
	if (tool != nullptr)
	{
		tool->Print(reply);
	}
	else
	{
		reply.copy("Error: Attempt to print details of non-existent tool.\n");
	}
}
示例#19
0
文件: styles.cpp 项目: libai245/wht1
void Style::Unload()
{
    for( unsigned int i = 0; i < tools.Count(); i++ ) {
        Tool* tool = (Tool*) tools.Item( i );
        tool->Unload();
    }

    for( unsigned int i = 0; i < icons.Count(); i++ ) {
        Icon* icon = (Icon*) icons.Item( i );
        icon->Unload();
    }
}
示例#20
0
void RepRap::SetToolVariables(int toolNumber, const float* standbyTemperatures, const float* activeTemperatures)
{
	Tool* tool = GetTool(toolNumber);
	if (tool != nullptr)
	{
		tool->SetVariables(standbyTemperatures, activeTemperatures);
	}
	else
	{
		platform->MessageF(GENERIC_MESSAGE, "Error: Attempt to set variables for a non-existent tool: %d.\n", toolNumber);
	}
}
示例#21
0
Tool* RepRap::GetTool(int toolNumber) const
{
	Tool* tool = toolList;
	while(tool != nullptr)
	{
		if (tool->Number() == toolNumber)
		{
			return tool;
		}
		tool = tool->Next();
	}
	return nullptr; // Not an error
}
示例#22
0
Command* TextFileView::InterpretManipulator (Manipulator* m) {
    Viewer* v = m->GetViewer();
    Editor* ed = v->GetEditor();
    Tool* tool = m->GetTool();
    Command* cmd = nil;

    if (tool->IsA(GRAPHIC_COMP_TOOL) || tool->IsA(RESHAPE_TOOL)) {
	// do nothing
    } else {
        cmd = TextOvView::InterpretManipulator(m);
    }

    return cmd;
}
示例#23
0
void HudLayer::addTool() {
	Tool *tool = (Tool *) _tools->objectAtIndex(_tools->count() - 1);
	int width = CCDirector::sharedDirector()->getWinSize().width;
	int toolX = width - ((width / 6) / 2);
	int toolY;
	if (tool->getType() == "Bridge") {
		toolY = 550;
		tool->setScale(0.5f);
		_numBridges++;
		sprintf(_bridges,"x %i",_numBridges);
		_bridgeLabel->setString(_bridges);
	} else if (tool->getType() == "Spring") {
		toolY = 400;
		_numSprings++;
		sprintf(_springs,"x %i",_numSprings);
		_springLabel->setString(_springs);
	} else if (tool->getType() == "Pole") {
		toolY = 220;
		_numPoles++;
		sprintf(_poles,"x %i",_numPoles);
		_poleLabel->setString(_poles);
	} else if (tool->getType() == "Catapult") {
		toolY = 0;
		_numCatapults++;
		sprintf(_catapults,"x %i",_numCatapults);
		_catapultLabel->setString(_catapults);
	} else if (tool->getType() == "Fan") {
		toolY = 0;
		_numFans++;
		sprintf(_fans,"x %i",_numFans);
		_fanLabel->setString(_fans);
	}
	tool->setPosition(ccp(toolX,toolY));
	this->addChild(tool, 11);
}
示例#24
0
Command* PadView::InterpretManipulator (Manipulator* m) {
    DragManip* dm = (DragManip*) m;
    Tool* tool = dm->GetTool();
    Command* cmd = nil;

    if (tool->IsA(GRAPHIC_COMP_TOOL)) {
        cmd = InterpGraphicCompManip(m);
    } else if (tool->IsA(MOVE_TOOL)) {
        cmd = GraphicView::InterpretManipulator(m);
    } else if (tool->IsA(CONNECT_TOOL)) {
        cmd = InterpConnectManip(m);
    }
    return cmd;
}
示例#25
0
void HudLayer::listTools(CCArray * tools) {
	_tools = tools;
	_tools->retain();
	int width = CCDirector::sharedDirector()->getWinSize().width;
	int toolX = width - ((width / 6) / 2);
	int toolY;
    for (int i = 0; i < tools->count(); i++) {
		Tool *tool = (Tool *) tools->objectAtIndex(i);
		if (tool->getType() == "Bridge") {
			toolY = 550;
			tool->setScale(0.5f);
			_numBridges++;
		} else if (tool->getType() == "Spring") {
			toolY = 400;
			_numSprings++;
		} else if (tool->getType() == "Pole") {
			toolY = 220;
			_numPoles++;
		} else if (tool->getType() == "Catapult") {
			toolY = 0;
			_numCatapults++;
		} else if (tool->getType() == "Fan") {
			toolY = 0;
			_numFans++;
		}
		tool->setPosition(ccp(toolX,toolY));
		this->addChild(tool, 11);
	}
    if (_numBridges > 0) {
		sprintf(_bridges,"x %i",_numBridges);
		_bridgeLabel->setString(_bridges);
		this->addChild(_bridgeLabel);
		_toolLabels->addObject(_bridgeLabel);
    }
    if (_numSprings > 0) {
		sprintf(_springs,"x %i",_numSprings);
		_springLabel->setString(_springs);
		this->addChild(_springLabel);
		_toolLabels->addObject(_springLabel);
    }
    if (_numPoles > 0) {
		sprintf(_poles,"x %i",_numPoles);
		_poleLabel->setString(_poles);
		this->addChild(_poleLabel);
		_toolLabels->addObject(_poleLabel);
    }
    if (_numCatapults > 0) {
		sprintf(_catapults,"x %i",_numCatapults);
		_catapultLabel->setString(_catapults);
		this->addChild(_catapultLabel);
		_toolLabels->addObject(_catapultLabel);
    }
    if (_numFans > 0) {
		sprintf(_fans,"x %i",_numFans);
		_fanLabel->setString(_fans);
		this->addChild(_fanLabel);
		_toolLabels->addObject(_fanLabel);
    }
}
示例#26
0
文件: selstate.cpp 项目: vata/xarino
void SelectionState::DeselectAll(BOOL RenderBlobs)
{
	// Find the selected objects in the tree;
	SelRange* Selected = GetApplication()->FindSelection();
	ERROR3IF( Selected==NULL, "Selection object is null in DeselectAll()");

	// Get the selected spread
 	Spread* pSpread = Document::GetSelectedSpread();
	ERROR3IF(pSpread == NULL,"NULL selected spread");

	// Make sure that we have a spread and a selection
	if (pSpread == NULL || Selected == NULL)
		return;

	// Find first selected node

#if !defined(EXCLUDE_FROM_RALPH)
	Node* pFirstSelectedNode = Selected->FindFirst();
	// If there is a selection, EOR blobs off, deselect nodes, and inform everybody
	if (pFirstSelectedNode != NULL && RenderBlobs)
	{
		// Go though and render all the EOR blobs off the screen

		// Find the Blob Manager
		BlobManager* BlobMgr = GetApplication()->GetBlobManager();
		ENSURE( BlobMgr!=NULL, "Blob Manager unexpectedly not there.");

		// Render all the blobs
		BlobMgr->RenderOff(NULL, pFirstSelectedNode->FindParentSpread());

		Tool* pTool = Tool::GetCurrent();
			
		// Get the tool to remove all its blobs before we deselect the nodes.
		// Only do this if the current tool dosent update itself on sel changed messages
		if (pSpread!=NULL && pTool!=NULL && !pTool->AreToolBlobsRenderedOnSelection())
			pTool->RenderToolBlobs(pSpread,NULL);
	}
#endif

	DeselectAll(pSpread->FindFirstChild());

	// Selection cache is no longer valid, so update and tell everyone that it has changed

	// *Note*, This used to be 'Selected->Update(TRUE)', but I (Will) removed the TRUE, so
	// that a message is NOT broadcast.  This should only be called from an operation,
	// and the op will send a message when it ends.

	Selected->Update();
}
示例#27
0
void ToolBar::ToolStrip::onPreferredSize(PreferredSizeEvent& ev)
{
  ToolBox* toolbox = App::instance()->getToolBox();
  int c = 0;

  for (ToolIterator it = toolbox->begin(); it != toolbox->end(); ++it) {
    Tool* tool = *it;
    if (tool->getGroup() == m_group) {
      ++c;
    }
  }

  Size iconsize = getToolIconSize(this);
  ev.setPreferredSize(Size(iconsize.w * c, iconsize.h));
}
示例#28
0
void HudLayer::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent) {
	if (Utils::gameLayer()->getState() == kEditMode) {
		if (_movingTool >= 0) {
			CCTouch *touch = (CCTouch*)_touches->objectAtIndex(0);
			CCPoint curTouchPosition = CCDirector::sharedDirector()->convertToGL(touch->getLocationInView());
			CCPoint screenLocation = this->getPosition();
			int gridX = (int) Utils::gameLayer()->getPosition().x % 50;
			int gridY = (int) Utils::gameLayer()->getPosition().y % 50;
			CCPoint newItemLocation = ccp(curTouchPosition.x - screenLocation.x, curTouchPosition.y - screenLocation.y);
			Tool *tool = (Tool *) _tools->objectAtIndex(_movingTool);
			tool->setScale(1.0f);
			tool->setGridPosition(newItemLocation, gridX, gridY);
		}
	}
}
示例#29
0
void GLWidget::mouseReleaseEvent(QMouseEvent *event)
{
    if(quickAccess)
    {        toolIsOn = false;
        stopQuickAccess();
        quickAccess = false;
    }
    else if(event->button() == Qt::LeftButton)
    {
        toolIsOn = false;
        Tool *aT = activeTool();
        if(aT->hasStage2() && !aT->stage2()) aT->function(STAGE2);
        else aT->function(STOP);
    }
}
示例#30
0
std::string
yexec::FindExecutable (Tool const        &tool,
                       SystemCalls const &system)
{
    std::string const &wrapper (tool.InstrumentationWrapper ());

    if (wrapper.empty ())
        throw std::logic_error ("provided a Tool "
                                "with no InstrumentationWrapper");

    std::string execPath (system.GetExecutablePath ());

    if (execPath.empty ())
        throw std::runtime_error ("system executable path is empty");

    auto execPaths (ysys::SplitPathString (execPath.c_str ()));

    for (std::string const &path : execPaths)
    {
        std::string const executable (path + "/" + wrapper);

        if (system.ExeExists (executable))
            return executable;
    }

    std::stringstream ss;
    ss << "Could not find the executable " << wrapper
       << " anywhere in your executable path" << std::endl
       << "Searched the following paths: " << std::endl;

    for (std::string const &path : execPaths)
        ss << " - " << path << std::endl;

    throw std::runtime_error (ss.str ());
}