#include "commondata.h" #include #include #include #include #include #include #include #include #include #include CommonData::CommonData() { m_pLogFile = NULL; if(m_pLogFile==NULL) { QDir dirLog("/home/birdhead/Log"); if(dirLog.exists()==false) { QDir().mkdir("/home/birdhead/Log"); } QString strLogFile = QString("/home/birdhead/Log/%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss")); m_pLogFile = new QFile(strLogFile); m_pLogFile->open(QFile::ReadWrite | QFile::Unbuffered); } /* #ifdef _SAVE_LOG QDir().mkdir("Log"); QString strLogFile = QString("Log/%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss")); m_pLogFile = new QFile(strLogFile); m_pLogFile->open(QFile::ReadWrite | QFile::Unbuffered); #endif */ m_bConnectHDMI = false; #ifdef _4K m_nVideoWidth = 3840; m_nVideoHeight = 2160; #else m_nVideoWidth = 1920; m_nVideoHeight = 1080; #endif m_pBitmapData = new uint8_t[m_nVideoWidth*m_nVideoHeight*3+1000]; m_nGPIO_Buzzer = 0; m_nVideoMode = 0; m_nCropMode = 0; m_nUseFixWidthLevel = 0; m_nUseLogLevel = 0; m_nScreenSaverTime = 0; m_pSambaClient = NULL; m_bAutoExitCaptureSendDICOM = false; m_bAutoCaptureSendDICOM = false; m_bAutoVideoCapture = false; m_bAutoLogin = false; m_bActiveDetect = false; m_bAutoCloseSendFinish = false; m_nGPIO_HandSwitch = 0; m_nSearchItemHistoryStudyIndex = -1; m_bIsCapturing = false; //m_strImageExtension = "jpg"; m_strImageExtension = "bmp"; m_pDatabase = new SDatabase(); m_pDCMWorklist = new SDCMWorklist; m_pListHistorySearch = new vector; m_pListHistoryImage = new vector; m_pWorklistData = new vector; m_pDCMDumpList = new vector; m_pFindSCUDataCallback = new SDCMFindSCUDataCallback(m_pDCMWorklist->GetExtractMode(), m_pDCMWorklist->GetCancelAfterNResponses()); m_pFindSCUDataCallback->SetWorklistData(m_pWorklistData); m_pFindSCUDataCallback->SetWorklistDump(m_pDCMDumpList); m_pCurrentWorklist = NULL; m_pRTSPThread = NULL; m_pListCaptureImage = new vector; m_pImageCapture = new RGB_Data[m_nVideoWidth*m_nVideoHeight]; memset(m_pImageCapture, 0, sizeof(RGB_Data)*m_nVideoWidth*m_nVideoHeight); m_strStorageDirectory = "/home/birdhead/test_save"; m_pCurrentHistoryStudy = NULL; m_bVideoEncoding = false; m_pWorklistTableHeader = new STableHeader; m_pHistoryTableHeader = new STableHeader; QDate dt = QDate::currentDate(); SetDateSearchWorklistStart(dt); SetDateSearchWorklistEnd(dt); SetDateSearchHistoryStart(dt); SetDateSearchHistoryEnd(dt); InitWorklistIndex(); InitHistoryIndex(); InitSetting(); //m_pWorklistTableHeader->UpdateTableHeaderInfo(m_MapWorklistIndex); #ifdef _XAVIER_NX //m_nGPIO_Buzzer = open("/sys/class/gpio/gpio393/value", O_WRONLY); m_strGPIOBeep = "/sys/class/gpio/gpio393/value"; m_strGPIOHandSwitch = "/sys/class/gpio/gpio271/value"; #endif #ifdef _JETSON_TX2_NX m_strGPIOBeep = "/sys/class/gpio/gpio269/value"; m_strGPIOHandSwitch = "/sys/class/gpio/gpio341/value"; #endif if(m_strGPIOBeep.size()>0) { m_nGPIO_Buzzer = open(m_strGPIOBeep.toUtf8(), O_WRONLY); if(m_nGPIO_Buzzer==-1) { } } ComputeStorageSize(); } CommonData::~CommonData() { SAFE_ARRAY_DELETE(m_pBitmapData); SAFE_ARRAY_DELETE(m_pImageCapture); SAFE_DELETE(m_pDatabase); SAFE_DELETE(m_pWorklistTableHeader); SAFE_DELETE(m_pHistoryTableHeader); ClearHistorySearchResult(); SAFE_DELETE(m_pListHistorySearch); ClearHistoryImage(); SAFE_DELETE(m_pListHistoryImage); ClearCaptureImage(); SAFE_DELETE(m_pListCaptureImage); SAFE_DELETE(m_pFindSCUDataCallback); SAFE_DELETE(m_pDCMWorklist); SAFE_DELETE(m_pWorklistData); SAFE_DELETE(m_pDCMDumpList); if(m_nGPIO_Buzzer>0) { close(m_nGPIO_Buzzer); } if(m_pLogFile!=NULL) { m_pLogFile->flush(); m_pLogFile->close(); SAFE_DELETE(m_pLogFile); } STableHeader::ClearMapData(); } QDate CommonData::GetDateSearchWorklistStart() { return m_SearchDateWorklist.m_DateStart; } QDate CommonData::GetDateSearchWorklistEnd() { return m_SearchDateWorklist.m_DateEnd; } void CommonData::SetDateSearchWorklistStart(QDate date) { m_SearchDateWorklist.m_DateStart = date; } void CommonData::SetDateSearchWorklistEnd(QDate date) { m_SearchDateWorklist.m_DateEnd = date; } QString CommonData::GetStorageDirectory() { return m_strStorageDirectory; } QDate CommonData::GetDateSearchHistoryStart() { return m_SearchDateHistory.m_DateStart; } QDate CommonData::GetDateSearchHistoryEnd() { return m_SearchDateHistory.m_DateEnd; } void CommonData::SetDateSearchHistoryStart(QDate date) { m_SearchDateHistory.m_DateStart = date; } void CommonData::SetDateSearchHistoryEnd(QDate date) { m_SearchDateHistory.m_DateEnd = date; } SEARCH_ITEM* CommonData::GetSearchItemWorklist() { return &m_SearchItemWorklist; } SDCMFindSCUDataCallback* CommonData::GetFindSCUDataCallback() { return m_pFindSCUDataCallback; } vector* CommonData::GetWorklistData() { m_LockWorklistData.lock(); return m_pWorklistData; } void CommonData::ReleaseWorklistData() { m_LockWorklistData.unlock(); } vector* CommonData::GetWorklistDump() { return m_pDCMDumpList; } void CommonData::SetRTSPThread(QRTSPThread* pThread) { m_pRTSPThread = pThread; } QRTSPThread* CommonData::GetThreadRTSP() { return m_pRTSPThread; } void CommonData::SetThreadCaptureImage(SThreadImageSave* pThread) { m_pThreadCaptureImage = pThread; } void CommonData::SetThreadSendDICOM(SThreadSendDICOM* pThread) { m_pThreadSendDICOM = pThread; } SThreadImageSave* CommonData::GetThreadCaptureImage() { return m_pThreadCaptureImage; } SThreadSendDICOM* CommonData::GetThreadSendDICOM() { return m_pThreadSendDICOM; } void CommonData::AddCaptureImageWithHistory() { int i=0; ClearCaptureImage(); int nImages = m_pListHistoryImage->size(); QImage* pImageTmp = NULL; m_LockAddHistory.lock(); for(i=0 ; im_strDate; QString strTime = pImageHistory->m_strTime; int nWidth = pImageHistory->GetWidth(); int nHeight = pImageHistory->GetHeight(); QImage::Format fmt = (QImage::Format)pImageHistory->GetFormat(); int nType = pImageHistory->m_nType; QString strFilename = pImageHistory->m_strFile; bool bDelete = pImageHistory->m_bDelete; QString strTimeFormat = "yyyyMMdd HHmmss"; QString strDateTime = QString("%1 %2").arg(strDate).arg(strTime); QDateTime dtCapture = QDateTime::fromString(strDateTime, strTimeFormat); CAPTURE_IMAGE* pImageNew = new CAPTURE_IMAGE; pImageNew->m_pImageSmall = new QImage(nWidth/4, nHeight/4, fmt); if(pImageTmp==NULL) { pImageTmp = new QImage(nWidth, nHeight, fmt); } else { if(pImageTmp->width()!=nWidth || pImageTmp->height()!=nHeight || pImageTmp->format()!=fmt) { SAFE_DELETE(pImageTmp); pImageTmp = new QImage(nWidth, nHeight, fmt); } } { uint8_t* pImageData = pImageTmp->bits(); memcpy(pImageData, pImageHistory->m_pImageData, nWidth*nHeight*3); // QImage imgSmall = pImageTmp->scaled(nWidth/4, nHeight/4); *pImageNew->m_pImageSmall = imgSmall.copy(); SAFE_ARRAY_DELETE(pImageNew->m_pImageCaptureRaw); SAFE_ARRAY_DELETE(pImageNew->m_pImageCaptureColor); imgSmall.detach(); } bool bTest = true; if(bTest==true) { //CAPTURE_IMAGE* pImageNew = AddCaptureImage(pImageOri->bits(), nWidth, nHeight, pImageHistory->m_nType); pImageNew->m_DateTime = dtCapture;//QDateTime::currentDateTime(); pImageNew->m_nType = (DISPLAY_TYPE)nType; pImageNew->m_strImageFilename = strFilename; if(pImageNew->m_nType==DISPLAY_VIDEO) { pImageNew->m_strVideoFilename = strFilename; pImageNew->m_strVideoFilename.replace(".bmp", ".mkv"); pImageNew->m_strVideoFilename.replace(".jpg", ".mkv"); pImageNew->m_strVideoFilename.replace(".png", ".mkv"); } pImageNew->m_bCheck = true; pImageNew->m_nType = (DISPLAY_TYPE)nType; pImageNew->m_bDelete = bDelete; pImageNew->m_bSaveFile = true; pImageNew->m_nIndex = i; m_LockAddCapture.lock(); m_pListCaptureImage->push_back(pImageNew); m_LockAddCapture.unlock(); } } SAFE_DELETE(pImageTmp); m_LockAddHistory.unlock(); ClearHistoryImage(); } vector* CommonData::GetListCaptureImage() { m_LockAddCapture.lock(); return m_pListCaptureImage; } void CommonData::ReleaseListCaptureImage() { m_LockAddCapture.unlock(); } void CommonData::ClearCaptureImage() { m_LockAddCapture.lock(); { int i=0; for(i=0 ; isize() ; i++) { CAPTURE_IMAGE* pCaptureImage = (*m_pListCaptureImage)[i]; if(pCaptureImage!=NULL) { if(pCaptureImage->m_pImage!=NULL) { //pCaptureImage->m_pImage->detach(); } if(pCaptureImage->m_pImageSmall!=NULL) { //pCaptureImage->m_pImageSmall->detach(); } SAFE_DELETE(pCaptureImage->m_pImage); SAFE_DELETE(pCaptureImage->m_pImageSmall); SAFE_ARRAY_DELETE(pCaptureImage->m_pImageCaptureRaw); SAFE_ARRAY_DELETE(pCaptureImage->m_pImageCaptureColor); SAFE_ARRAY_DELETE(pCaptureImage->m_pImageData); SAFE_DELETE(pCaptureImage); } } m_pListCaptureImage->clear(); //SAFE_DELETE(m_pListCaptureImage); //m_pListCaptureImage = new vector; } m_LockAddCapture.unlock(); } CAPTURE_IMAGE* CommonData::AddCaptureImage(uint8_t* pData, int nWidth, int nHeight, int nCaptureType) { CAPTURE_IMAGE* pCaptureImage = NULL; m_LockAddCapture.lock(); { pCaptureImage = new CAPTURE_IMAGE; pCaptureImage->m_DateTime = QDateTime::currentDateTime(); pCaptureImage->m_nType = (DISPLAY_TYPE)nCaptureType; if(nWidth>0 && nHeight>0 && pData!=NULL) { pCaptureImage->m_pImageCaptureRaw = NULL; pCaptureImage->m_pImageCaptureRaw = new uint8_t[nWidth*nHeight*2]; memset(pCaptureImage->m_pImageCaptureRaw, 0, sizeof(uint8_t)*nWidth*nHeight*2); memcpy(pCaptureImage->m_pImageCaptureRaw, pData, sizeof(uint8_t)*nWidth*nHeight*2); } else { pCaptureImage->m_pImageCaptureRaw = NULL; } { m_pListCaptureImage->push_back(pCaptureImage); } } m_LockAddCapture.unlock(); return pCaptureImage; } uint8_t* CommonData::ConvertColor(uint8_t* pData, int nWidth, int nHeight) { int i=0; int j=0; for(i=0 ; iGetPatientInfo(); QString strPatientID = pPatientInfo->strPatientID; ReleaseAcquisitionInfo(); //QString strStorageDirectory = pMainWindow->GetStorageDirectory(); QString strStorageDirectory = "/data"; QString strDirectoryImage; QString strImageExtention; if(nType==DISPLAY_IMAGE) { strDirectoryImage = QString("%1/image").arg(strStorageDirectory); strImageExtention = m_strImageExtension; } else if(nType==DISPLAY_VIDEO) { strDirectoryImage = QString("%1/video").arg(strStorageDirectory); strImageExtention = "mkv"; } QString strDirectoryDate = QString("%1/%2%3%4").arg(strDirectoryImage).arg(QString::number(nYear).rightJustified(4, '0')).arg(QString::number(nMonth).rightJustified(2, '0')) .arg(QString::number(nDay).rightJustified(2, '0')); if(strPatientID.size()<1) { strPatientID = "unknown"; } QString strDirectoryPatient = QString("%1/%2").arg(strDirectoryDate).arg(strPatientID); uint captureTime = dt.toMSecsSinceEpoch(); QDir().mkdir(strDirectoryImage); QDir().mkdir(strDirectoryDate); QDir().mkdir(strDirectoryPatient); vector::iterator it; strFile = QString("%1/%2.%3").arg(strDirectoryPatient).arg(QString::number(captureTime)).arg(strImageExtention); m_LockAddCapture.lock(); int nCheckCount = -1; for(it=m_pListCaptureImage->begin() ; it!=m_pListCaptureImage->end() ; ++it) { CAPTURE_IMAGE* pCheckImage = *it; if(pCheckImage->m_strImageFilename==strFile) { nCheckCount++; strFile = QString("%1/%2_%4.%3").arg(strDirectoryPatient).arg(QString::number(captureTime)).arg(strImageExtention).arg(QString::number(nCheckCount)); } } m_LockAddCapture.unlock(); return strFile; } void CommonData::ConvertCaptureImage(CAPTURE_IMAGE* pCaptureImage, int nWidth, int nHeight) { //ConvertCaptureImageRGBA(pCaptureImage, nWidth, nHeight); //return; int i=0; int j=0; if(pCaptureImage->m_pImageCaptureRaw==NULL) { pCaptureImage->m_pImageCaptureRaw = new uint8_t[m_nVideoWidth*m_nVideoHeight*2]; } uint8_t* pData = pCaptureImage->m_pImageCaptureRaw; bool bSaveOri = false; if(bSaveOri==true) { QFile file("save_ori.data"); file.open(QFile::ReadWrite); file.write((char*)pData, nWidth*2*nHeight); file.close(); } memset(m_pImageCapture, 0, sizeof(RGB_Data)*m_nVideoWidth*m_nVideoHeight); for(i=0 ; im_pImageCaptureRaw); QString strFile = GetNewFilename(DISPLAY_IMAGE); SAFE_ARRAY_DELETE(pCaptureImage->m_pImageCaptureColor); //pCaptureImage->m_pImage = new QImage((uchar*)m_pImageCapture, nWidth, nHeight, QImage::Format_RGB888); pCaptureImage->m_pImage = new QImage(nWidth, nHeight, QImage::Format_RGB888); { uint8_t* pImageDest = pCaptureImage->m_pImage->bits(); memcpy(pImageDest, m_pImageCapture, nWidth*nHeight*3); } pCaptureImage->m_bCheck = true; pCaptureImage->m_strImageFilename = strFile; if(pCaptureImage->m_nType==DISPLAY_VIDEO) { QString strVideo = pCaptureImage->m_strVideoFilename; QString strImageExtention = m_strImageExtension; if(strVideo.size()==0) { strVideo = GetNewFilename(DISPLAY_VIDEO); pCaptureImage->m_strVideoFilename = strVideo; } strFile = strVideo.replace("mkv", strImageExtention); pCaptureImage->m_strImageFilename = strFile; } pCaptureImage->m_bSaveFile = false; m_pThreadCaptureImage->AddCaptureSaveToFile(pCaptureImage); QImage image = pCaptureImage->m_pImage->scaled(nWidth/4, nHeight/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); pCaptureImage->m_pImageSmall = new QImage(nWidth/4, nHeight/4, image.format()); //*pCaptureImage->m_pImageSmall = image.rgbSwapped(); *pCaptureImage->m_pImageSmall = image.copy(); ACQUISITION_INFO* pAcquisitionInfo = GetAcquisitionInfo(); if(pAcquisitionInfo->GetPatientInfo()->strPatientID.length() > 0 && pAcquisitionInfo->GetPatientInfo()->strPatientName.length() >0) { pAcquisitionInfo->m_strImageFilename = pCaptureImage->m_strImageFilename; pAcquisitionInfo->m_strVideoFilename = pCaptureImage->m_strVideoFilename; if(pCaptureImage->m_nType==DISPLAY_IMAGE) { m_pDatabase->InsertImage(pAcquisitionInfo); } else if(pCaptureImage->m_nType==DISPLAY_VIDEO) { m_pDatabase->InsertVideo(pAcquisitionInfo); } } ReleaseAcquisitionInfo(); usleep(100); } void CommonData::ConvertCaptureImageRGBA(CAPTURE_IMAGE* pCaptureImage, int nWidth, int nHeight) { //uint8_t* pData = pCaptureImage->m_pImageCaptureRaw; //int nYear = pCaptureImage->m_DateTime.date().year(); //int nMonth = pCaptureImage->m_DateTime.date().month(); //int nDay = pCaptureImage->m_DateTime.date().day(); //int nHour = pCaptureImage->m_DateTime.time().hour(); //int nMinute = pCaptureImage->m_DateTime.time().minute(); //int nSec = pCaptureImage->m_DateTime.time().second(); //QString strStorageDirectory = GetStorageDirectory(); //QString strDirectoryImage = QString("%1").arg(strStorageDirectory); //QString strPatientID = "123"; QString strImageExtention = m_strImageExtension; pCaptureImage->m_pImage = new QImage((uchar*)pCaptureImage->m_pImageCaptureRaw, nWidth, nHeight, QImage::Format_RGB32); *pCaptureImage->m_pImage = pCaptureImage->m_pImage->convertToFormat(QImage::Format_RGB888); *pCaptureImage->m_pImage = pCaptureImage->m_pImage->rgbSwapped(); //QString strFile = QString("%1/%2%3%4.%5").arg(strDirectoryImage).arg(QString::number(nHour).rightJustified(2, '0')).arg(QString::number(nMinute).rightJustified(2, '0')).arg(QString::number(nSec).rightJustified(2, '0')).arg(strImageExtention); QString strFile = GetNewFilename(DISPLAY_IMAGE); { /* vector::iterator it; int nCheckCount = -1; for(it=m_pListCaptureImage->begin() ; it!=m_pListCaptureImage->end() ; ++it) { CAPTURE_IMAGE* pCheckImage = *it; if(pCheckImage->m_strImageFilename==strFile) { nCheckCount++; strFile = QString("%1/%2%3%4_%5.%6").arg(strDirectoryImage).arg(QString::number(nHour).rightJustified(2, '0')).arg(QString::number(nMinute).rightJustified(2, '0')).arg(QString::number(nSec).rightJustified(2, '0')).arg(QString::number(nCheckCount)).arg(strImageExtention); } } */ } pCaptureImage->m_strImageFilename = strFile; if(pCaptureImage->m_nType==DISPLAY_VIDEO) { QString strVideo = strFile; strVideo = strVideo.replace(strImageExtention, "mkv"); //QString strVideo = QString("%1/%2%3%4.mkv").arg(strDirectoryImage).arg(QString::number(nHour).rightJustified(2, '0')).arg(QString::number(nMinute).rightJustified(2, '0')).arg(QString::number(nSec).rightJustified(2, '0')); pCaptureImage->m_strVideoFilename = strVideo; } pCaptureImage->m_bSaveFile = false; m_pThreadCaptureImage->AddCaptureSaveToFile(pCaptureImage); QImage image = pCaptureImage->m_pImage->scaled(nWidth/4, nHeight/4, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); pCaptureImage->m_pImageSmall = new QImage(nWidth/4, nHeight/4, image.format()); *pCaptureImage->m_pImageSmall = image; SAFE_ARRAY_DELETE(pCaptureImage->m_pImageCaptureRaw); if(m_AcquisitionInfo.GetPatientInfo()->strPatientID.length() > 0 && m_AcquisitionInfo.GetPatientInfo()->strPatientName.length() >0) { m_AcquisitionInfo.m_strImageFilename = pCaptureImage->m_strImageFilename; m_AcquisitionInfo.m_strVideoFilename = pCaptureImage->m_strVideoFilename; if(pCaptureImage->m_nType==DISPLAY_IMAGE) { m_pDatabase->InsertImage(&m_AcquisitionInfo); } else if(pCaptureImage->m_nType==DISPLAY_VIDEO) { m_pDatabase->InsertVideo(&m_AcquisitionInfo); } } usleep(10*1000); } SDatabase* CommonData::GetDatabase() { return m_pDatabase; } ACQUISITION_INFO* CommonData::GetAcquisitionInfo() { m_LockAcquisitionInfo.lock(); return &m_AcquisitionInfo; } void CommonData::ReleaseAcquisitionInfo() { m_LockAcquisitionInfo.unlock(); } vector* CommonData::GetListHistoryImage() { m_LockAddHistory.lock(); return m_pListHistoryImage; } void CommonData::ReleaseListHistoryImage() { m_LockAddHistory.unlock(); } void CommonData::ClearHistoryImage() { m_LockAddHistory.lock(); int i=0; for(i=0 ; isize() ; i++) { ImageSelect* pHistoryImage = (*m_pListHistoryImage)[i]; if(pHistoryImage!=NULL) { SAFE_ARRAY_DELETE(pHistoryImage->m_pImageData); } SAFE_DELETE(pHistoryImage); } m_pListHistoryImage->clear(); SAFE_DELETE(m_pListHistoryImage); m_pListHistoryImage = new vector; m_LockAddHistory.unlock(); } vector* CommonData::GetHistorySearchResult() { return m_pListHistorySearch; } void CommonData::ClearHistorySearchResult() { m_LockCurrentHistoryStudy.lock(); int i=0; for(i=0 ; isize() ; i++) { HISTORY_STUDY* pHistoryStudy = (*m_pListHistorySearch)[i]; SAFE_DELETE(pHistoryStudy); } m_pListHistorySearch->clear(); m_pCurrentHistoryStudy = NULL; m_LockCurrentHistoryStudy.unlock(); } HISTORY_STUDY* CommonData::GetCurrentHistoryStudy() { m_LockCurrentHistoryStudy.lock(); return m_pCurrentHistoryStudy; } void CommonData::ReleaseCurrentHistoryStudy() { m_LockCurrentHistoryStudy.unlock(); } void CommonData::SetCurrentHistoryStudy(int nIndex) { m_LockCurrentHistoryStudy.lock(); if(nIndex < m_pListHistorySearch->size()) { m_pCurrentHistoryStudy = (*m_pListHistorySearch)[nIndex]; } else { m_pCurrentHistoryStudy = NULL; } m_LockCurrentHistoryStudy.unlock(); } bool CommonData::IsEncodingVideo() { return m_bVideoEncoding; } void CommonData::SetEncodingVideo(bool bEncoding) { m_bVideoEncoding = bEncoding; } STableHeader* CommonData::GetWorklistTableHeader() { return m_pWorklistTableHeader; } STableHeader* CommonData::GetHistoryTableHeader() { return m_pHistoryTableHeader; } void CommonData::Exit() { if(m_pRTSPThread!=NULL) { m_pRTSPThread->ChangeState(1000); while(m_pRTSPThread->isRunning()==true) { usleep(10*1000); } m_pRTSPThread->stop(); } if(m_pThreadCaptureImage!=NULL) { m_pThreadCaptureImage->ChangeState(1000); while(m_pThreadCaptureImage->isRunning()==true) { usleep(10*1000); } } } int CommonData::GetDisplayType() { return m_nDisplayType; } void CommonData::SetDisplayType(int nType) { m_nDisplayType = nType; } SDCMWorklist* CommonData::GetWorklistClass() { return m_pDCMWorklist; } #define pp pair bool cmp(const pp& a, const pp& b) { //if(a.second==b.second) return a.first < b.first; //return a.second < b.second; return a.first > b.first; } void CommonData::InitWorklistIndex() { QList* pResult = m_pDatabase->QueryWorklistTableHeader(); m_pWorklistTableHeader->SetDataWorklist(pResult); } void CommonData::UpdateWorklistIndex() { int i=0; vector* pListActivate = m_pWorklistTableHeader->GetListActive(); vector* pListInactivate = m_pWorklistTableHeader->GetListInactive(); QString strUpdate; int nIndex = 0; for(i=0 ; isize() ; i++) { TableHeader* pTableHeader = (*pListActivate)[i]; pTableHeader->m_nIndex = nIndex; strUpdate = QString("update WorklistTableHeader SET `DisplayIndex`='%1' , `Visible`='%2' where `DefaultIndex`='%3';").arg(QString::number(nIndex)).arg(QString::number(1)).arg(QString::number(pTableHeader->m_nIndexDefault)); m_pDatabase->Execute(strUpdate); nIndex++; } for(i=0 ; isize() ; i++) { TableHeader* pTableHeader = (*pListInactivate)[i]; pTableHeader->m_nIndex = nIndex; strUpdate = QString("update WorklistTableHeader SET DisplayIndex='%1' , Visible='%2' where DefaultIndex='%3';").arg(QString::number(nIndex)).arg(QString::number(0)).arg(QString::number(pTableHeader->m_nIndexDefault)); m_pDatabase->Execute(strUpdate); nIndex++; } } void CommonData::InitHistoryIndex() { QList* pResult = m_pDatabase->QueryHistoryTableHeader(); m_pHistoryTableHeader->SetDataHistory(pResult); } void CommonData::UpdateHistoryIndex() { int i=0; vector* pListActivate = m_pHistoryTableHeader->GetListActive(); vector* pListInactivate = m_pHistoryTableHeader->GetListInactive(); QString strUpdate; int nIndex = 0; for(i=0 ; isize() ; i++) { TableHeader* pTableHeader = (*pListActivate)[i]; pTableHeader->m_nIndex = nIndex; strUpdate = QString("update HistoryTableHeader SET `DisplayIndex`='%1' , `Visible`='%2' where `DefaultIndex`='%3';").arg(QString::number(nIndex)).arg(QString::number(1)).arg(QString::number(pTableHeader->m_nIndexDefault)); m_pDatabase->Execute(strUpdate); nIndex++; } for(i=0 ; isize() ; i++) { TableHeader* pTableHeader = (*pListInactivate)[i]; pTableHeader->m_nIndex = nIndex; strUpdate = QString("update HistoryTableHeader SET DisplayIndex='%1' , Visible='%2' where DefaultIndex='%3';").arg(QString::number(nIndex)).arg(QString::number(0)).arg(QString::number(pTableHeader->m_nIndexDefault)); m_pDatabase->Execute(strUpdate); nIndex++; } } SDCM_SERVER_INFO* CommonData::GetServerWorklistInfo() { return &m_ServerWorklistInfo; } SDCM_SERVER_INFO* CommonData::GetServerStorageInfo() { return &m_ServerStorageInfo; } void CommonData::UpdateSetting() { QString strEnableLog = "Disabled"; QString strQuery = QString("update ConnectionInfo SET WorklistServerIP='%1', WorklistPort='%2', WorklistServerTitle='%3', WorklistClientTitle='%4', StorageServerIP='%5', StoragePort='%6', StorageServerTitle='%7', StorageClientTitle='%8', Modality='%9', HospitalName='%10', StationName='%11', EnableLog='%12', LocalImageFolder='%13', LocalLogFolder='%14', LocalHistoryFolder='%15' where ID=1") .arg(m_ServerWorklistInfo.m_strServer_IP) .arg(m_ServerWorklistInfo.m_nServer_Port) .arg(m_ServerWorklistInfo.m_strServer_AETitle) .arg(m_ServerWorklistInfo.m_strClient_AETitle). arg(m_ServerStorageInfo.m_strServer_IP). arg(m_ServerStorageInfo.m_nServer_Port). arg(m_ServerStorageInfo.m_strServer_AETitle). arg(m_ServerStorageInfo.m_strClient_AETitle). arg(m_strModality). arg(m_strInstitutionName). arg(m_strStationName). arg(strEnableLog). arg(m_strLocalImageFolder). arg(m_strLogFolder). arg(m_strLocalHistoryFolder); qDebug() << strQuery; m_pDatabase->Execute(strQuery); } void CommonData::UpdateAdvancedSetting() { QString strEnableNetworkShare = "Disabled"; if(m_NetworkShareInfo.m_bEnable==true) { strEnableNetworkShare = "Enabled"; } QString strNetworkAutoSend = "Disabled"; if(m_NetworkShareInfo.m_bAutoSend==true) { strNetworkAutoSend = "Enabled"; } int nAutoExitCaptureSendDICOM = 0; int nAutoCaptureSendDICOM = 0; int nAutoVideoCapture = 0; int nAutoCloseSendFinish = 0; int nAutoLogin = 0; int nDICOMCompress = 0; int nVideoMode = 0; int nCropMode = 0; int nUseFixWidthLevel = 0; int nUseLogLevel = 0; int nScreenSaverTime = 0; if(m_bAutoExitCaptureSendDICOM==true) { nAutoExitCaptureSendDICOM = 1; } if(m_bAutoCaptureSendDICOM==true) { nAutoCaptureSendDICOM = 1; } if(m_bAutoVideoCapture==true) { nAutoVideoCapture = 1; } if(m_bAutoCloseSendFinish==true) { nAutoCloseSendFinish = 1; } if(m_bAutoLogin==true) { nAutoLogin = 1; } if(m_nTransferSyntax==1) { nDICOMCompress = 1; } if(m_nVideoMode==1) { nVideoMode = 1; } if(m_nCropMode==1) { nCropMode = 1; } if(m_nUseFixWidthLevel==1) { nUseFixWidthLevel = 1; } if(m_nUseLogLevel>0) { nUseLogLevel = m_nUseLogLevel; } if(m_nScreenSaverTime>0) { nScreenSaverTime = m_nScreenSaverTime; } QString strQuery = QString("update AdvancedSetting SET EnableNetworkShare='%1', NetworkShareIP='%2', NetworkShareFolder='%3', NetworkShareID='%4', NetworkSharePassword='%5', " "NetworkSMBVersion='%6', NetworkAutoSend='%7', AutoExitCaptureSendDICOM='%8', AutoCaptureSendDICOM='%9', AutoVideoCapture='%10', " "DICOMCharacterSet='%11', AutoCloseSendFinish='%12', AutoLogin='%13', DICOMCompress='%14', VideoMode='%15', CropMode='%16', " "UseFixWidthLevel='%17', UseLogLevel='%18', ScreenSaverTime='%19' where ID=1") .arg(strEnableNetworkShare) .arg(m_NetworkShareInfo.m_strIP) .arg(m_NetworkShareInfo.m_strShareFolder) .arg(m_NetworkShareInfo.m_strID) .arg(m_NetworkShareInfo.m_strPassword) .arg(m_NetworkShareInfo.m_strVersion) .arg(strNetworkAutoSend) .arg(nAutoExitCaptureSendDICOM) .arg(nAutoCaptureSendDICOM) .arg(nAutoVideoCapture) .arg(m_strDICOMCharacterSet) .arg(nAutoCloseSendFinish) .arg(nAutoLogin) .arg(nDICOMCompress) .arg(nVideoMode) .arg(nCropMode) .arg(nUseFixWidthLevel) .arg(nUseLogLevel) .arg(nScreenSaverTime); qDebug() << strQuery; m_pDatabase->Execute(strQuery); if(m_nUseLogLevel==0) { if(m_pLogFile!=NULL) { m_pLogFile->flush(); m_pLogFile->close(); SAFE_DELETE(m_pLogFile); } } } void CommonData::InitSetting() { QString strQuery = QString("select WorklistServerIP, WorklistPort, WorklistServerTitle, WorklistClientTitle, StorageServerIP, StoragePort, StorageServerTitle, StorageClientTitle, Modality, HospitalName, StationName, EnableLog, LocalImageFolder, LocalLogFolder, LocalHistoryFolder from ConnectionInfo;"); m_pDatabase->ExecuteQuery(strQuery); QList* pResult = m_pDatabase->GetResult(); QStringList* pListData = (*pResult)[0]; int nIndex = 0; QString strWorklistServerIP = (*pListData)[nIndex]; nIndex++; QString strWorklistPort = (*pListData)[nIndex]; nIndex++; QString strWorklistServerTitle = (*pListData)[nIndex]; nIndex++; QString strWorklistClientTitle = (*pListData)[nIndex]; nIndex++; QString strStorageServerIP = (*pListData)[nIndex]; nIndex++; QString strStoragePort = (*pListData)[nIndex]; nIndex++; QString strStorageServerTitle = (*pListData)[nIndex]; nIndex++; QString strStorageClientTitle = (*pListData)[nIndex]; nIndex++; QString strModality = (*pListData)[nIndex]; nIndex++; QString strHospitalName = (*pListData)[nIndex]; nIndex++; QString strStationName = (*pListData)[nIndex]; nIndex++; QString strEnableLog = (*pListData)[nIndex]; nIndex++; QString strLocalImageFolder = (*pListData)[nIndex]; nIndex++; QString strLocalLogFolder = (*pListData)[nIndex]; nIndex++; QString strLocalHistoryFolder = (*pListData)[nIndex]; nIndex++; strQuery = QString("select EnableNetworkShare, NetworkShareIP, NetworkShareFolder, NetworkShareID, " "NetworkSharePassword, NetworkSMBVersion, NetworkAutoSend, AutoExitCaptureSendDICOM, " "AutoCaptureSendDICOM, AutoVideoCapture, DICOMCharacterSet, AutoCloseSendFinish, AutoLogin, " "DICOMCompress, VideoMode, CropMode, UseFixWidthLevel, UseLogLevel, ScreenSaverTime from AdvancedSetting where ID=1;"); m_pDatabase->ExecuteQuery(strQuery); pResult = m_pDatabase->GetResult(); pListData = (*pResult)[0]; nIndex = 0; QString strEnableNetworkShare = (*pListData)[nIndex]; nIndex++; QString strNetworkShareIP = (*pListData)[nIndex]; nIndex++; QString strNetworkShareFolder = (*pListData)[nIndex]; nIndex++; QString strNetworkShareID = (*pListData)[nIndex]; nIndex++; QString strNetworkSharePassword = (*pListData)[nIndex]; nIndex++; QString strSMBVersion = (*pListData)[nIndex]; nIndex++; QString strNetworkAutoSend = (*pListData)[nIndex]; nIndex++; QString strAutoExitCaptureSendDICOM = (*pListData)[nIndex]; nIndex++; QString strAutoCaptureSendDICOM = (*pListData)[nIndex]; nIndex++; QString strAutoVideoCapture = (*pListData)[nIndex]; nIndex++; QString strDICOMCharacterSet = (*pListData)[nIndex]; nIndex++; QString strAutoCloseSendFinish = (*pListData)[nIndex]; nIndex++; QString strAutoLogin = (*pListData)[nIndex]; nIndex++; QString strDICOMCompress = (*pListData)[nIndex]; nIndex++; QString strVideoMode = (*pListData)[nIndex]; nIndex++; QString strCropMode = (*pListData)[nIndex]; nIndex++; QString strUseFixWidthLevel = (*pListData)[nIndex]; nIndex++; QString strUseLogLevel = (*pListData)[nIndex]; nIndex++; QString strScreenSaverTime = (*pListData)[nIndex]; nIndex++; m_ServerWorklistInfo.m_strServer_IP = strWorklistServerIP; m_ServerWorklistInfo.m_nServer_Port = strWorklistPort.toInt(); m_ServerWorklistInfo.m_strServer_AETitle = strWorklistServerTitle; m_ServerWorklistInfo.m_strClient_AETitle = strWorklistClientTitle; m_ServerStorageInfo.m_strServer_IP = strStorageServerIP; m_ServerStorageInfo.m_nServer_Port = strStoragePort.toInt(); m_ServerStorageInfo.m_strServer_AETitle = strStorageServerTitle; m_ServerStorageInfo.m_strClient_AETitle = strStorageClientTitle; m_strModality = strModality; m_strInstitutionName = strHospitalName; m_strStationName = strStationName; m_nTransferSyntax = 0; m_NetworkShareInfo.m_bEnable = true; if(strEnableNetworkShare=="Disabled") { m_NetworkShareInfo.m_bEnable = false; } m_NetworkShareInfo.m_strIP = strNetworkShareIP; m_NetworkShareInfo.m_strShareFolder = strNetworkShareFolder; m_NetworkShareInfo.m_strID = strNetworkShareID; m_NetworkShareInfo.m_strPassword = strNetworkSharePassword; m_NetworkShareInfo.m_strVersion = strSMBVersion; m_NetworkShareInfo.m_bAutoSend = true; if(strNetworkAutoSend=="Disabled") { m_NetworkShareInfo.m_bAutoSend = false; } m_bAutoExitCaptureSendDICOM = false; if(strAutoExitCaptureSendDICOM=="1") { m_bAutoExitCaptureSendDICOM = true; } m_bAutoCaptureSendDICOM = false; if(strAutoCaptureSendDICOM=="1") { m_bAutoCaptureSendDICOM = true; } m_bAutoVideoCapture = false; if(strAutoVideoCapture=="1") { m_bAutoVideoCapture = true; } m_bAutoCloseSendFinish = false; if(strAutoCloseSendFinish=="1") { m_bAutoCloseSendFinish = true; } m_bAutoLogin = false; if(strAutoLogin=="1") { m_bAutoLogin = true; } m_strDICOMCharacterSet = strDICOMCharacterSet; m_nTransferSyntax = strDICOMCompress.toInt(); m_nVideoMode = strVideoMode.toInt(); SetVideoMode(m_nVideoMode); m_nCropMode = strCropMode.toInt(); SetCropMode(m_nCropMode); m_nUseFixWidthLevel = strUseFixWidthLevel.toInt(); SetUseFixWidthLevel(m_nUseFixWidthLevel); m_nUseLogLevel = strUseLogLevel.toInt(); SetLogLevel(m_nUseLogLevel); m_nScreenSaverTime = strScreenSaverTime.toInt(); SetScreenSaverTime(m_nScreenSaverTime); if(m_nUseLogLevel>0) { if(m_pLogFile==NULL) { QDir().mkdir("Log"); QString strLogFile = QString("Log/%1.log").arg(QDateTime::currentDateTime().toString("yyyyMMdd_HHmmss")); m_pLogFile = new QFile(strLogFile); m_pLogFile->open(QFile::ReadWrite | QFile::Unbuffered); } } //test code //m_bAutoExitCaptureSendDICOM = true; //m_bAutoVideoCapture = true; m_pDCMWorklist->SetWorklistInfo(strWorklistServerIP, strWorklistPort, strWorklistServerTitle, strWorklistClientTitle); } QString CommonData::GetModality() { return m_strModality; } QString CommonData::GetInstitutionName() { return m_strInstitutionName; } QString CommonData::GetStationName() { return m_strStationName; } int CommonData::GetTransferSyntax() { return m_nTransferSyntax; } void CommonData::SetModality(QString strModality) { m_strModality = strModality; } void CommonData::SetInstitutionName(QString strInstitutionName) { m_strInstitutionName = strInstitutionName; } void CommonData::SetStationName(QString strStationName) { m_strStationName = strStationName; } void CommonData::SetTransferSyntax(int nTransferSyntax) { m_nTransferSyntax = nTransferSyntax; } bool CommonData::GetEnableLog() { return m_bEnableLog; } QString CommonData::GetLocalImageFolder() { return m_strLocalImageFolder; } QString CommonData::GetLogFolder() { return m_strLogFolder; } QString CommonData::GetLocalHistoryFolder() { return m_strLocalHistoryFolder; } void CommonData::SetEnableLog(int bEnable) { m_bEnableLog = bEnable; } void CommonData::SetLocalImageFolder(QString strLocalImageFolder) { m_strLocalImageFolder = strLocalImageFolder; } void CommonData::SetLogFolder(QString strLogFolder) { m_strLogFolder = strLogFolder; } void CommonData::SetLocalHistoryFolder(QString strLocalHistoryFolder) { m_strLocalHistoryFolder = strLocalHistoryFolder; } void CommonData::Beep(bool bSound) { if(m_nGPIO_Buzzer<=0) { return; } if(bSound==true) { m_bIsCapturing = true; if(write(m_nGPIO_Buzzer, "1", 1) != 1) { } } else { m_bIsCapturing = false; if(write(m_nGPIO_Buzzer, "0", 1) != 1) { } } } int CommonData::GetHandSwitchValue() { char cRead = 0; int nReadCount = 0; if(m_nGPIO_HandSwitch>0) { nReadCount = read(m_nGPIO_HandSwitch, &cRead, sizeof(char)); } if(nReadCount==0) { close(m_nGPIO_HandSwitch); //m_nGPIO_HandSwitch = open("/sys/class/gpio/gpio271/value", O_RDONLY); m_nGPIO_HandSwitch = open(m_strGPIOHandSwitch.toUtf8(), O_RDONLY); } if(m_nGPIO_HandSwitch==-1) { qDebug() << "271 Open Failed"; } else { //qDebug() << "271 Open success"; nReadCount = read(m_nGPIO_HandSwitch, &cRead, sizeof(char)); if(nReadCount>0) { //qDebug() << cRead; if(cRead=='1') { return 1; } return 0; } //close(m_nGPIO_HandSwitch); } //m_nGPIO_HandSwitch = 0; return -1; } bool CommonData::IsCapturing() { return m_bIsCapturing; } WorklistResponseData CommonData::GetCurrentHistoryWorklistData() { WorklistResponseData rd; //rd.m_Patient = m_pCurrentHistoryStudy->pStrPatientName->toStdString().c_str(); rd.m_Patient.strPatientID = m_pCurrentHistoryStudy->pStrPatientID->toStdString().c_str(); rd.m_Patient.strPatientName = m_pCurrentHistoryStudy->pStrPatientName->toStdString().c_str(); rd.m_Patient.strPatientWeight = m_pCurrentHistoryStudy->pStrPatientWeight->toStdString().c_str(); rd.m_Patient.strPatientSex = m_pCurrentHistoryStudy->pStrPatientSex->toStdString().c_str(); rd.m_Patient.strPatientBirthDate = m_pCurrentHistoryStudy->pStrPatientBirthDate->toStdString().c_str(); rd.m_Study.strStudyInstanceUID = m_pCurrentHistoryStudy->pStrStudyInstanceUID->toStdString().c_str(); rd.m_Study.strStudyDescription = m_pCurrentHistoryStudy->pStrStudyDescription->toStdString().c_str(); rd.m_Study.strStudyDate = m_pCurrentHistoryStudy->pStrStudyDate->toStdString().c_str(); rd.m_Study.strStudyTime = m_pCurrentHistoryStudy->pStrStudyTime->toStdString().c_str(); rd.m_ScheduledData.strScheduledCodeValue = m_pCurrentHistoryStudy->pStrStudyCodeValue->toStdString().c_str(); rd.m_Study.strReferringPhysiciansName = m_pCurrentHistoryStudy->pStrReferringPhysiciansName->toStdString().c_str(); rd.m_Study.strAccessionNumber = m_pCurrentHistoryStudy->pStrAccessionNumber->toStdString().c_str(); rd.m_Series.strSeriesInstanceUID = m_pCurrentHistoryStudy->pStrSeriesInstanceUID->toStdString().c_str(); rd.m_Series.strSeriesDescription = m_pCurrentHistoryStudy->pStrSeriesDescription->toStdString().c_str(); rd.m_Series.strModality = m_pCurrentHistoryStudy->pStrModality->toStdString().c_str(); rd.m_Series.strSeriesDate = m_pCurrentHistoryStudy->pStrSeriesDate->toStdString().c_str(); rd.m_Series.strSeriesTime = m_pCurrentHistoryStudy->pStrSeriesTime->toStdString().c_str(); //rd.m_Series.strBodyPartExamined; rd.m_Series.strOperatorsName = m_pCurrentHistoryStudy->pStrOperatorsName->toStdString().c_str(); return rd; } WorklistResponseData CommonData::GetCurrentWorklistData() { WorklistResponseData rd; m_LockAcquisitionInfo.lock(); rd.m_Patient = *m_AcquisitionInfo.GetPatientInfo(); rd.m_Study = *m_AcquisitionInfo.GetStudyInfo(); rd.m_Series = *m_AcquisitionInfo.GetSeriesInfo(); rd.m_Image = *m_AcquisitionInfo.GetImageInfo(); rd.m_ScheduledData = *m_AcquisitionInfo.GetScheduledDataInfo(); return rd; } void CommonData::ReleaseCurrentWorklistData() { m_LockAcquisitionInfo.unlock(); } qint64 CommonData::ComputeStorageSize() { foreach (const QStorageInfo &storage, QStorageInfo::mountedVolumes()) { QString strRootPath = storage.rootPath(); qDebug() << strRootPath; if(strRootPath=="/data") { if (storage.isReadOnly()) qDebug() << "isReadOnly:" << storage.isReadOnly(); qDebug() << "name:" << storage.name(); qDebug() << "fileSystemType:" << storage.fileSystemType(); qDebug() << "size:" << storage.bytesTotal()/1000/1000 << "MB"; qDebug() << "availableSize:" << storage.bytesAvailable()/1000/1000 << "MB"; m_nStorageFreeSize = storage.bytesAvailable(); m_nStorageSize = storage.bytesTotal(); } } return m_nStorageSize; QString strDirectory = "/data"; QFileInfo pathInfo(strDirectory); if(pathInfo.isDir()==false) { return 0; } QDirIterator it(strDirectory, QDirIterator::Subdirectories); qint64 total = 0; while(it.hasNext()==true) { it.next(); QFileInfo fi = it.fileInfo(); if(fi.isFile()==true && fi.isSymLink()==false && fi.isAbsolute()==true) { total += fi.size(); } } qDebug() << "/data size: " << total; m_nStorageSize = total; return total; } int CommonData::GetStorageSize() { return (int)(m_nStorageSize/(1000*1000)); } int CommonData::GetStorageFreeSize() { return (int)(m_nStorageFreeSize/(1000*1000)); } vector* CommonData::GetExportList() { return &m_ListExport; } QString* CommonData::GetExternalDiskPath() { return &m_strExternalDiskPath; } QString* CommonData::GetImageExtension() { return &m_strImageExtension; } void CommonData::SetSearchItemHistory(SEARCH_ITEM si) { m_SearchItemHistory = si; } void CommonData::SetHistorySearchStudyIndex(int nStudyIndex) { m_nSearchItemHistoryStudyIndex = nStudyIndex; } SEARCH_ITEM* CommonData::GetSearchItemHistory() { return &m_SearchItemHistory; } int CommonData::GetHistorySearchStudyIndex() { return m_nSearchItemHistoryStudyIndex; } void CommonData::ClearHistorySearchItem() { m_SearchItemHistory.Clear(); } void CommonData::ClearHistorySearchStudyIndex() { m_nSearchItemHistoryStudyIndex = -1; } bool CommonData::IsAutoCloseSendFinish() { return m_bAutoCloseSendFinish; } bool CommonData::IsAutoLogin() { return m_bAutoLogin; } void CommonData::SetAutoLogin(bool bEnable) { m_bAutoLogin = bEnable; } QString CommonData::GetBeepGPIONumber() { return m_strGPIOBeep; } QString CommonData::GetHandswitchGPIONumber() { return m_strGPIOHandSwitch; } bool CommonData::IsActiveDetect() { return m_bActiveDetect; } void CommonData::SetActiveDetect(bool bActive) { m_bActiveDetect = bActive; } void CommonData::SetUseNetworkBackupVideo(bool bUse) { m_NetworkShareInfo.m_bEnable = bUse; } bool CommonData::IsUseNetworkBackupVideo() { return m_NetworkShareInfo.m_bEnable; } NetworkShareInfo* CommonData::GetNetworkShareInfo() { return &m_NetworkShareInfo; } bool CommonData::IsAutoExitCaptureSendDICOM() { return m_bAutoExitCaptureSendDICOM; } bool CommonData::IsAutoCaptureSendDICOM() { return m_bAutoCaptureSendDICOM; } bool CommonData::IsAutoVideoCapture() { return m_bAutoVideoCapture; } void CommonData::SetAutoExitCaptureSendDICOM(bool bEnable) { m_bAutoExitCaptureSendDICOM = bEnable; } void CommonData::SetAutoCaptureSendDICOM(bool bEnable) { m_bAutoCaptureSendDICOM = bEnable; } void CommonData::SetAutoVideoCapture(bool bEnable) { m_bAutoVideoCapture = bEnable; } SambaClient* CommonData::GetSambaClient() { return m_pSambaClient; } void CommonData::CreateSambaClient() { m_pSambaClient = new SambaClient; } QString CommonData::GetDICOMCharacterSet() { return m_strDICOMCharacterSet; } void CommonData::SetDICOMCharacterSet(QString strCharacterSet) { m_strDICOMCharacterSet = strCharacterSet; } void CommonData::SetAutoCloseSendComplete(bool bEnable) { m_bAutoCloseSendFinish = bEnable; } void CommonData::WriteLog(QString strLog) { if(m_nUseLogLevel>0) { m_LockLog.lock(); m_ListLog.push_back(strLog); m_LockLog.unlock(); } } void CommonData::WriteLogFile(QString strLog) { m_LockLog.lock(); m_pLogFile->write(strLog.toStdString().c_str()); m_LockLog.unlock(); fsync(m_pLogFile->handle()); } QStringList* CommonData::GetListLog() { m_LockLog.lock(); return &m_ListLog; } void CommonData::ReleaseListLog() { m_LockLog.unlock(); } void CommonData::SetVideoMode(int nMode) { nMode = 0; m_nVideoMode = nMode; if(m_nVideoMode==0) { #ifdef _4K m_nVideoWidth = 3840; m_nVideoHeight = 2160; #else m_nVideoWidth = 1920; m_nVideoHeight = 1080; #endif } else if(m_nVideoMode==1) { m_nVideoWidth = 1280; m_nVideoHeight = 720; } } int CommonData::GetVideoMode() { return m_nVideoMode; } void CommonData::SetCropMode(int bCropMode) { m_nCropMode = bCropMode; } int CommonData::GetCropMode() { return m_nCropMode; } void CommonData::SetUseFixWidthLevel(int bFixWidthLevel) { m_nUseFixWidthLevel = bFixWidthLevel; } int CommonData::GetUseFixWidthLevel() { return m_nUseFixWidthLevel; } void CommonData::SetLogLevel(int nLevel) { m_nUseLogLevel = nLevel; } int CommonData::GetLogLevel() { return m_nUseLogLevel; } int CommonData::GetVideoWidth() { return m_nVideoWidth; } int CommonData::GetVideoHeight() { return m_nVideoHeight; } void CommonData::MakeBitmapHeader(int nWidth, int nHeight) { memset(m_pBitmapData, 0, m_nVideoWidth*m_nVideoHeight*3+1000); int nSizeBitmapHeader = sizeof(BITMAPFILEHADER); int nSizeBitmapInfoHeader = sizeof(BITMAPINFOHEADER); memset(&m_bf, 0, sizeof(&m_bf)); m_bf.bfType = 0x4d42; m_bf.bfOffBits = nSizeBitmapHeader + nSizeBitmapInfoHeader; m_bf.bfSize = m_bf.bfOffBits + nWidth*nHeight*3; m_bf.bfReserved1 = 0; m_bf.bfReserved2 = 0; memcpy(&m_pBitmapData[0], &m_bf, nSizeBitmapHeader); memset(&m_bi, 0, sizeof(&m_bi)); m_bi.biSize = sizeof(BITMAPINFOHEADER); m_bi.biWidth = nWidth; m_bi.biHeight = -1* nHeight; m_bi.biPlanes = 1; m_bi.biBitCount = 24; m_bi.biCompression = 0; m_bi.biSizeImage = nWidth*nHeight*3; m_bi.biXPelsPerMeter = 2835; m_bi.biYPelsPerMeter = 2835; m_bi.biClrUsed = 0; m_bi.biClrImportant = 0; memcpy(&m_pBitmapData[nSizeBitmapHeader], &m_bi, nSizeBitmapInfoHeader); } void CommonData::WriteBitmapFile(QString strFile, QImage* pImage) { int nWidth = pImage->width(); int nHeight = pImage->height(); MakeBitmapHeader(nWidth, nHeight); QImage tmpImage = pImage->rgbSwapped(); memcpy(&m_pBitmapData[m_bf.bfOffBits], tmpImage.bits(), nWidth*nHeight*3); //MakeBitmapHeader(1920, 1080); QFile t2(strFile); if(t2.exists()==true) { t2.remove(); } t2.open(QFile::ReadWrite); t2.write((const char*)m_pBitmapData, m_bf.bfSize); t2.flush(); //t2.write((const char*)&m_bf, sizeof(BITMAPFILEHADER)); //t2.write((const char*)&m_bi, sizeof(BITMAPINFOHEADER)); //t2.write((const char*)tmpImage.bits(), 1920*1080*3); //t2.flush(); fsync(t2.handle()); t2.close(); } void CommonData::SetScreenSaverTime(int nMinutes) { m_nScreenSaverTime = nMinutes; } int CommonData::GetScreenSaverTime() { return m_nScreenSaverTime; } void CommonData::SetConnectHDMI(bool bConnect) { m_bConnectHDMI = bConnect; } bool CommonData::IsConnectHDMI() { return m_bConnectHDMI; }