本文整理汇总了C++中Tool类的典型用法代码示例。如果您正苦于以下问题:C++ Tool类的具体用法?C++ Tool怎么用?C++ Tool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tool类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
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: PointTranslate
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: EmergencyStop
// 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);
}
}
}
示例4: render
/**
* 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: GrabTool
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: Widget
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: outputLine
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
示例8: ToolClick
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: gettool
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: ClearTemperatureFault
void Tool::ClearTemperatureFault(int8_t heater)
{
Tool* n = this;
while (n != nullptr)
{
n->ResetTemperatureFault(heater);
n = n->Next();
}
}
示例11: main
/*
* 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;
}
示例12: update
/**
* 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: SCASSERT
//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: create_tool
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: getToolById
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;
}