Download data/core/components/code/Qt/mtsDaVinciEndoscopeFocusQtWidget.cpp from introvoyz045/sawIntuitiveResearchKit: direct link, hf CLI and curl.
- Browser
- Download file 5.54 kB
-
https://huggingface.co/datasets/introvoyz045/sawIntuitiveResearchKit/resolve/main/data/core/components/code/Qt/mtsDaVinciEndoscopeFocusQtWidget.cpp
- Command line
-
hf download hf://datasets/introvoyz045/sawIntuitiveResearchKit/data/core/components/code/Qt/mtsDaVinciEndoscopeFocusQtWidget.cpp
-
curl -L -o mtsDaVinciEndoscopeFocusQtWidget.cpp https://huggingface.co/datasets/introvoyz045/sawIntuitiveResearchKit/resolve/main/data/core/components/code/Qt/mtsDaVinciEndoscopeFocusQtWidget.cpp
5.54 kB
| /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ | |
| /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ | |
| /* | |
| Author(s): Zihan Chen, Anton Deguet | |
| Created on: 2020-02-10 | |
| (C) Copyright 2020-2021 Johns Hopkins University (JHU), All Rights Reserved. | |
| --- begin cisst license - do not edit --- | |
| This software is provided "as is" under an open source license, with | |
| no warranty. The complete license can be found in license.txt and | |
| http://www.cisst.org/cisst/license.txt. | |
| --- end cisst license --- | |
| */ | |
| // system include | |
| // Qt include | |
| // cisst | |
| CMN_IMPLEMENT_SERVICES_DERIVED_ONEARG(mtsDaVinciEndoscopeFocusQtWidget, mtsComponent, std::string); | |
| mtsDaVinciEndoscopeFocusQtWidget::mtsDaVinciEndoscopeFocusQtWidget(const std::string & componentName): | |
| mtsComponent(componentName) | |
| { | |
| // Setup cisst interface | |
| mtsInterfaceRequired * interfaceRequired = AddInterfaceRequired("Endoscope"); | |
| if (interfaceRequired) { | |
| interfaceRequired->AddFunction("lock", Endoscope.lock); | |
| interfaceRequired->AddFunction("focus_in", Endoscope.focus_in); | |
| interfaceRequired->AddFunction("focus_out", Endoscope.focus_out); | |
| // events | |
| interfaceRequired->AddEventHandlerWrite(&mtsDaVinciEndoscopeFocusQtWidget::LockedEventHandler, | |
| this, "locked"); | |
| interfaceRequired->AddEventHandlerWrite(&mtsDaVinciEndoscopeFocusQtWidget::FocusingInEventHandler, | |
| this, "focusing_in"); | |
| interfaceRequired->AddEventHandlerWrite(&mtsDaVinciEndoscopeFocusQtWidget::FocusingOutEventHandler, | |
| this, "focusing_out"); | |
| } | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::Configure(const std::string &filename) | |
| { | |
| CMN_LOG_CLASS_INIT_VERBOSE << "Configure: " << filename << std::endl; | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::Startup(void) | |
| { | |
| setupUi(); | |
| if (!parent()) { | |
| show(); | |
| } | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::Cleanup(void) | |
| { | |
| this->hide(); | |
| CMN_LOG_CLASS_INIT_VERBOSE << "Cleanup" << std::endl; | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotLock(void) | |
| { | |
| const bool isLocked = QPBLock->isChecked(); | |
| Endoscope.lock(isLocked); | |
| UpdateLock(isLocked); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::UpdateLock(const bool & locked) | |
| { | |
| if (locked) { | |
| QPBLock->setText("Unlock"); | |
| } else { | |
| QPBLock->setText("lock"); | |
| } | |
| QPBFocusIn->setEnabled(!locked); | |
| QPBFocusOut->setEnabled(!locked); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotFocusIn(bool focus) | |
| { | |
| Endoscope.focus_in(focus); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotFocusOut(bool focus) | |
| { | |
| Endoscope.focus_out(focus); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotLockedEventHandler(bool locked) | |
| { | |
| QPBLock->setChecked(locked); | |
| UpdateLock(locked); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotFocusingInEventHandler(bool focusing) | |
| { | |
| if (focusing) { | |
| QLFocusingIn->setText("+"); | |
| } else { | |
| QLFocusingIn->setText("o"); | |
| } | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::SlotFocusingOutEventHandler(bool focusing) | |
| { | |
| if (focusing) { | |
| QLFocusingOut->setText("-"); | |
| } else { | |
| QLFocusingOut->setText("o"); | |
| } | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::setupUi(void) | |
| { | |
| // main layout | |
| QHBoxLayout * mainLayout = new QHBoxLayout(); | |
| setLayout(mainLayout); | |
| // from left to right, focus in/+, lock, focus out/- | |
| QPBFocusIn = new QPushButton("Focus In"); | |
| mainLayout->addWidget(QPBFocusIn); | |
| QLFocusingIn = new QLabel("o"); | |
| QLFocusingIn->setAlignment(Qt::AlignCenter); | |
| mainLayout->addWidget(QLFocusingIn); | |
| QPBLock = new QPushButton("Lock"); | |
| QPBLock->setCheckable(true); | |
| mainLayout->addWidget(QPBLock); | |
| QLFocusingOut = new QLabel("o"); | |
| QLFocusingOut->setAlignment(Qt::AlignCenter); | |
| mainLayout->addWidget(QLFocusingOut); | |
| QPBFocusOut = new QPushButton("Focus Out"); | |
| mainLayout->addWidget(QPBFocusOut); | |
| setWindowTitle("da Vinci Endoscope Focus"); | |
| resize(sizeHint()); | |
| // setup Qt Connection | |
| connect(this, SIGNAL(SignalLocked(bool)), | |
| this, SLOT(SlotLockedEventHandler(bool))); | |
| connect(this, SIGNAL(SignalFocusingIn(bool)), | |
| this, SLOT(SlotFocusingInEventHandler(bool))); | |
| connect(this, SIGNAL(SignalFocusingOut(bool)), | |
| this, SLOT(SlotFocusingOutEventHandler(bool))); | |
| connect(QPBLock, SIGNAL(clicked()), | |
| this, SLOT(SlotLock())); | |
| connect(QPBFocusIn, &QPushButton::pressed, | |
| [ = ] { emit SlotFocusIn(true); }); | |
| connect(QPBFocusIn, &QPushButton::released, | |
| [ = ] { emit SlotFocusIn(false); }); | |
| connect(QPBFocusOut, &QPushButton::pressed, | |
| [ = ] { emit SlotFocusOut(true); }); | |
| connect(QPBFocusOut, &QPushButton::released, | |
| [ = ] { emit SlotFocusOut(false); }); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::LockedEventHandler(const bool & locked) | |
| { | |
| emit SignalLocked(locked); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::FocusingInEventHandler(const bool & focusing) | |
| { | |
| emit SignalFocusingIn(focusing); | |
| } | |
| void mtsDaVinciEndoscopeFocusQtWidget::FocusingOutEventHandler(const bool & focusing) | |
| { | |
| emit SignalFocusingOut(focusing); | |
| } | |