| 181 | } |
| 182 | |
| 183 | void QmitkMonaiLabelToolGUI::OnFetchBtnClicked() |
| 184 | { |
| 185 | m_Controls->previewButton->setEnabled(false); |
| 186 | m_Controls->labelListLabel->clear(); |
| 187 | auto reply = QMessageBox::question(this, "Confirm", ::CONFIRM_QUESTION_TEXT, QMessageBox::Yes | QMessageBox::No); |
| 188 | if (reply == QMessageBox::No) |
| 189 | { |
| 190 | MITK_INFO << "Didn't went ahead with Monai Label inferencing"; |
| 191 | return; |
| 192 | } |
| 193 | auto tool = this->GetConnectedToolAs<mitk::MonaiLabelTool>(); |
| 194 | if (nullptr == tool) |
| 195 | { |
| 196 | return; |
| 197 | } |
| 198 | QString urlString = m_Controls->urlBox->text(); |
| 199 | QUrl url(urlString); |
| 200 | if (url.isValid() && !url.isLocalFile() && !url.hasFragment() && !url.hasQuery()) // sanity check |
| 201 | { |
| 202 | std::string hostName = url.host().toStdString(); |
| 203 | int port = url.port(); |
| 204 | try |
| 205 | { |
| 206 | tool->FetchOverallInfo(hostName, port); |
| 207 | bool allowAllModels = m_Preferences->GetBool("monailabel allow all models", false); |
| 208 | this->PopulateUI(allowAllModels); |
| 209 | auto timeout_sec = std::make_unsigned_t<int>(m_Preferences->GetInt("monailabel timeout", 180)); |
| 210 | tool->SetTimeout(timeout_sec); |
| 211 | } |
| 212 | catch (const mitk::Exception &e) |
| 213 | { |
| 214 | m_Controls->appBox->clear(); |
| 215 | m_Controls->modelBox->clear(); |
| 216 | MITK_ERROR << e.GetDescription(); |
| 217 | this->WriteErrorMessage(e.GetDescription()); |
| 218 | } |
| 219 | } |
| 220 | else |
| 221 | { |
| 222 | std::string invalidURLMessage = "Invalid URL entered: " + urlString.toStdString(); |
| 223 | MITK_ERROR << invalidURLMessage; |
| 224 | this->ShowErrorMessage(invalidURLMessage); |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | void QmitkMonaiLabelToolGUI::OnPreviewBtnClicked() |
| 229 | { |
nothing calls this directly
no test coverage detected