DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckRefPresence(UINT32) // DESCRIPTION : Check the dicom attribute against the reference attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { if ((dcmAttributeM_ptr == NULL) && (refAttributeM_ptr == NULL)) { return MSG_NO_VALUE; } if (dcmAttributeM_ptr == NULL) { GetMessages()->AddMessage(VAL_RULE_R_PRESENCE_1, "Reference attribute not present in source object"); return MSG_ERROR; } if (refAttributeM_ptr == NULL) { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_6, "Source attribute not present in reference object"); return MSG_ERROR; } return MSG_OK; }
void GUI::FreeMessages() { if(GetMessages()) { GetMessages()->Clear(); delete GetMessages(); SetMessages(NULL); } }
std::vector<boost::shared_ptr<Message>> IMAPFolder::GetMessagesCopy(bool bReloadIfNeeded) { boost::shared_ptr<Messages> messages = GetMessages(bReloadIfNeeded); return messages->GetCopy(); }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckRefVM(UINT32) // DESCRIPTION : Check the VM of the dicom attribute and the reference attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { if ((dcmAttributeM_ptr == NULL) || (refAttributeM_ptr == NULL)) { return MSG_ERROR; } int dcmVm = dcmAttributeM_ptr->GetNrValues(); int refVm = refAttributeM_ptr->GetNrValues(); if ((dcmVm == 0) && (refVm == 1)) { // special case if the reference is zero length // - it has a single value that is zero-length - consequence of script parser BASE_VALUE_CLASS *value_ptr = refAttributeM_ptr->GetValue(0); if ((value_ptr) && (value_ptr->GetLength() == 0)) { // reference has a zero length - same as source with no value return MSG_OK; } } if (dcmVm != refVm) { char message[128]; sprintf(message, "Number of attribute values (VM) of %d differs from number of reference attribute values of %d", dcmVm, refVm); GetMessages()->AddMessage(VAL_RULE_R_VM_1, message); return MSG_ERROR; } return MSG_OK; }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckVRCompatibility(UINT32) // DESCRIPTION : Check the VR compatibility of the dicom attribute and the // : reference attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { if ((dcmAttributeM_ptr == NULL) || (refAttributeM_ptr == NULL)) { return MSG_ERROR; } ATTR_VR_ENUM dcmVr = dcmAttributeM_ptr->GetVR(); ATTR_VR_ENUM refVr = refAttributeM_ptr->GetVR(); // explicit check on OB / OW - these can be compatible if (((dcmVr == ATTR_VR_OB) && (refVr == ATTR_VR_OW)) || ((dcmVr == ATTR_VR_OW) && (refVr == ATTR_VR_OB))) { return MSG_OK; } // check source vr against reference vr if (dcmVr != refVr) { char message[128]; sprintf (message, "Attribute VR of %s differs from reference attribute VR of %s", stringVr(dcmVr), stringVr(refVr)); GetMessages()->AddMessage(VAL_RULE_R_VR_1, message); return MSG_ERROR; } return MSG_OK; }
bool IMAPFolder::XMLLoadSubItems(XNode *pFolderNode, int iRestoreOptions) { // Should we restore messages as well? if (!GetMessages()->XMLLoad(pFolderNode, iRestoreOptions)) return false; // Load sub folders. if (!GetSubFolders()->XMLLoad(pFolderNode, iRestoreOptions)) return false; // Restore ACL permisisons. if (IsPublicFolder()) { if (!GetPermissions()->XMLLoad(pFolderNode, iRestoreOptions)) return false; } return true; }
bool IMAPFolder::XMLStore(XNode *pParentNode, int iBackupOptions) { XNode *pNode = pParentNode->AppendChild(_T("Folder")); pNode->AppendAttr(_T("Name"), String(folder_name_)); pNode->AppendAttr(_T("Subscribed"), folder_is_subscribed_ ? _T("1") : _T("0")); pNode->AppendAttr(_T("CreateTime"), String(Time::GetTimeStampFromDateTime(create_time_))); pNode->AppendAttr(_T("CurrentUID"), StringParser::IntToString(current_uid_)); if (!GetMessages()->XMLStore(pNode, iBackupOptions)) return false; if (!GetSubFolders()->XMLStore(pNode, iBackupOptions)) return false; if (IsPublicFolder()) { if (!GetPermissions()->XMLStore(pNode, iBackupOptions)) return false; } return true; }
void VAL_QR_ATTRIBUTE_CLASS::CheckAgainstRequested() // DESCRIPTION : Check against the requested attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { if (GetDcmAttribute() != NULL) { if (reqAttributeM_ptr == NULL) { char message[128]; sprintf(message, "Returned attribute (0x%04X%04X) not requested", dcmAttributeM_ptr->GetMappedGroup(), dcmAttributeM_ptr->GetMappedElement()); GetMessages()->AddMessage(VAL_RULE_A_QR_1, message); } } }
void VuMainThread::Update() #endif { #define NEW_MT_UPDATE 1 #if NEW_MT_UPDATE VuGameEntity *game = vuLocalSessionEntity->Game(); // send and get all messages vuTransmitTime = vuxRealTime; //START_PROFILE("RT_UPDATE_PU"); if (game != NULL){ // sfr: send enqueued position updates, before garbage collector to avoid invalid pointers // computes sends allowed and iterate over sessions unsigned int allowed = VuMaster::SendsPerPlayer(); if (vuLocalGame != NULL){ VuSessionsIterator sit(vuLocalGame); for (VuSessionEntity *se = sit.GetFirst();se!=NULL; se = sit.GetNext()){ if (se != vuLocalSessionEntity.get()){ se->SendBestEnqueuedPositionUpdatesAndClear(allowed, vuxGameTime); } } } } //STOP_PROFILE("RT_UPDATE_PU"); // clear garbage collector //START_PROFILE("RT_GC"); vuCollectionManager->CreateEntitiesAndRunGc(); //STOP_PROFILE("RT_GC"); //REPORT_VALUE("messages", nm); //extern int nmsgs; //REPORT_VALUE("message diff", nmsgs); //extern int nSimBase; //REPORT_VALUE("sim base", nSimBase); //extern DWORD SimObjects; //REPORT_VALUE("sim obj", SimObjects); // if no game, do dispatch and quite if (!game){ #if CAP_DISPATCH // send 10 queued messages at most if (sendQueue_){ sendQueue_->DispatchMessages(10, FALSE); } // 10 ms at most VuBaseThread::Update(10); #else if (sendQueue_){ sendQueue_->DispatchMessages(-1, FALSE); } messageQueue_->DispatchMessages(-1, FALSE); #endif return; } //START_PROFILE("VUMAINUP_GROUP"); // Send low priority messages //if (vuLowSendQueue){ // vuLowSendQueue->DispatchMessages(-1, FALSE); //} // our session is dirty, send update if (vuLocalSessionEntity->IsDirty ()){ VuFullUpdateEvent *msg = new VuFullUpdateEvent(vuLocalSessionEntity.get(), vuGlobalGroup); msg->RequestOutOfBandTransmit(); msg->RequestReliableTransmit(); VuMessageQueue::PostVuMessage(msg); vuLocalSessionEntity->ClearDirty(); } // send session and game info every interval // time variables VU_TIME now = vuxRealTime; ///< time now static VU_TIME last_bg = 0; ///< last broadcast time if (now - last_bg > 5000){ last_bg = now; vuLocalSessionEntity->SetTransmissionTime(vuxRealTime); VuBroadcastGlobalEvent *msg = new VuBroadcastGlobalEvent(vuLocalSessionEntity.get(), vuGlobalGroup); msg->RequestOutOfBandTransmit(); VuMessageQueue::PostVuMessage(msg); vuLocalSessionEntity->SetTransmissionTime(vuxRealTime); UpdateGroupData(vuGlobalGroup); VuListIterator grp_iter(vuGameList); for ( VuGameEntity* game = (VuGameEntity*)grp_iter.GetFirst(), *nextGame; game != NULL; game = nextGame ){ nextGame = (VuGameEntity*)grp_iter.GetNext(); // removes empty games that are not player pool if (game->IsLocal() && (game != vuPlayerPoolGroup) && (game->SessionCount() == 0)){ vuDatabase->Remove(game); } // broadcast game data if its our game if (game->IsLocal() && ((game->LastTransmissionTime() + game->UpdateRate()) < vuxRealTime)){ if (game->IsDirty()){ // game dirty, update to everyone VuFullUpdateEvent *msg = new VuFullUpdateEvent(game, vuGlobalGroup); msg->RequestReliableTransmit(); msg->RequestOutOfBandTransmit (); VuMessageQueue::PostVuMessage(msg); game->ClearDirty (); } else { // nothing changed, keep game alive VuBroadcastGlobalEvent *msg = new VuBroadcastGlobalEvent(game, vuGlobalGroup); msg->RequestOutOfBandTransmit (); VuMessageQueue::PostVuMessage(msg); } game->SetTransmissionTime(vuxRealTime); } UpdateGroupData(game); } } //STOP_PROFILE("VUMAINUP_GROUP"); //START_PROFILE("VUMAINUP_SENDDISPATCH"); if (sendQueue_){ #if CAP_DISPATCH // dispatch 10 queued messages at most before sending remotes sendQueue_->DispatchMessages(10, FALSE); #else sendQueue_->DispatchMessages(-1, FALSE); #endif } // send to remotes and SendQueuedMessages(); //STOP_PROFILE("VUMAINUP_SENDDISPATCH"); //START_PROFILE("VUMAINUP_GETDISPATCH"); // get from remotes GetMessages(); #if CAP_DISPATCH // 10 ms at most VuBaseThread::Update(mxTime); #else messageQueue_->DispatchMessages(-1, FALSE); // flush queue #endif //STOP_PROFILE("VUMAINUP_GETDISPATCH"); #else // clear garbage collector vuCollectionManager->CreateEntitiesAndFlushGc(); // zero transmitted bytes //ResetXmit(); // dispatch messages messageQueue_->DispatchMessages(-1, FALSE); if (vuNormalSendQueue){ vuNormalSendQueue->DispatchMessages(-1, FALSE); } // if no game, nothing else VuGameEntity *game = vuLocalSessionEntity->Game(); if (!game){ return; } // Send low priority messages if (vuLowSendQueue){ vuLowSendQueue->DispatchMessages(-1, FALSE); } VuEnterCriticalSection (); SendQueuedMessages(); GetMessages(); VuExitCriticalSection (); messageQueue_->DispatchMessages(-1, FALSE); // flush queue vuTransmitTime = vuxRealTime; // sfr: send enqeued position updates (the ones not sent immediately) // compute sends allowed // iterate sessions unsigned int allowed = VuMaster::SendsPerPlayer(); //TODO if (vuLocalGame != NULL){ VuSessionsIterator sit(vuLocalGame); for (VuSessionEntity *se = sit.GetFirst();se!=NULL; se = sit.GetNext()){ if (se != vuLocalSessionEntity.get()){ se->SendBestEnqueuedPositionUpdatesAndClear(allowed, vuxGameTime); } } } // our session is dirty, send update if (vuLocalSessionEntity->IsDirty ()){ VuFullUpdateEvent *msg = new VuFullUpdateEvent(vuLocalSessionEntity.get(), vuGlobalGroup); msg->RequestOutOfBandTransmit(); msg->RequestReliableTransmit(); VuMessageQueue::PostVuMessage(msg); vuLocalSessionEntity->ClearDirty (); } // send session and game info every interval // time variables VU_TIME now = vuxRealTime; ///< time now static VU_TIME last_bg = 0; ///< last broadcast time if (now - last_bg > 5000){ last_bg = now; vuLocalSessionEntity->SetTransmissionTime(vuxRealTime); VuBroadcastGlobalEvent *msg = new VuBroadcastGlobalEvent(vuLocalSessionEntity.get(), vuGlobalGroup); msg->RequestOutOfBandTransmit(); VuMessageQueue::PostVuMessage(msg); vuLocalSessionEntity->SetTransmissionTime(vuxRealTime); UpdateGroupData(vuGlobalGroup); VuListIterator grp_iter(vuGameList); // sfr: removed loop increment from the for, since remove can kill it for ( VuGameEntity* game = (VuGameEntity*)grp_iter.GetFirst(), *nextGame; game != NULL; game = nextGame ){ nextGame = (VuGameEntity*)grp_iter.GetNext(); // removes empty games that are not player pool if (game->IsLocal() && (game != vuPlayerPoolGroup) && (game->SessionCount() == 0)){ vuDatabase->Remove(game); } // broadcast game data if its our game if (game->IsLocal() && ((game->LastTransmissionTime() + game->UpdateRate()) < vuxRealTime)){ if (game->IsDirty()){ // game dirty, update to everyone VuFullUpdateEvent *msg = new VuFullUpdateEvent(game, vuGlobalGroup); msg->RequestReliableTransmit(); msg->RequestOutOfBandTransmit (); VuMessageQueue::PostVuMessage(msg); game->ClearDirty (); } else { // nothing changed, keep game alive VuBroadcastGlobalEvent *msg = new VuBroadcastGlobalEvent(game, vuGlobalGroup); msg->RequestOutOfBandTransmit (); VuMessageQueue::PostVuMessage(msg); } game->SetTransmissionTime(vuxRealTime); } UpdateGroupData(game); } } #endif }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckAgainstDTAndEV(UINT32) // DESCRIPTION : Check the dicom attribute against any definition attribute // : enumerated values or defined terms. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DVT_STATUS status = MSG_OK; if (dcmAttributeM_ptr == NULL) { return MSG_OK; } // A SQ attribute always has a value list linked. This value list // contains the attributes within the sequence. However, the content // of the SQ is not within the list of Defined Terms. So return with an // ok. if (defAttributeM_ptr->GetVR() == ATTR_VR_SQ) { return MSG_OK; } // TODO: Need to build in a check for comparing the defined terms with the contents of the OB, OF, OW files // Don't check these for now if ((defAttributeM_ptr->GetVR() == ATTR_VR_OB) || (defAttributeM_ptr->GetVR() == ATTR_VR_OF) || (defAttributeM_ptr->GetVR() == ATTR_VR_OW)) { return MSG_OK; } int noOfLists = defAttributeM_ptr->GetNrLists(); if (noOfLists == 0) { // No defined terms or enumerated values are present for the // attribute in the definition component. return MSG_OK; } ATTR_VAL_TYPE_ENUM valueType; if (noOfLists > 1) { // With more than one list of defined terms and/or enumerated // values, it is not allowed that one of those lists are of type // ENUMERATED_LIST or DEFINED_LIST. // NOTE: This check may be obsolete as it may have been done // already in the definition component. for (int i = 0; i < noOfLists; i++) { valueType = defAttributeM_ptr->GetValueList(i)->GetValueType(); if ((valueType == ATTR_VAL_TYPE_ENUMERATED_LIST) || (valueType == ATTR_VAL_TYPE_DEFINED_LIST)) { GetMessages()->AddMessage(VAL_RULE_D_RANGE_3, "Error in definition file, no EL or DL list " \ "allowed with more than one list of defined terms " \ "or enumerated values."); } } } VALUE_LIST_CLASS *valueList_ptr = defAttributeM_ptr->GetValueList(); valueType = valueList_ptr->GetValueType(); if ((noOfLists == 1) && ((valueType == ATTR_VAL_TYPE_ENUMERATED_LIST) || (valueType == ATTR_VAL_TYPE_DEFINED_LIST))) { for (int i = 0; i < dcmAttributeM_ptr->GetNrValues(); i++) { BASE_VALUE_CLASS *value_ptr = dcmAttributeM_ptr->GetValue(i); if (valueList_ptr->HasValue(value_ptr) == false) { char message[256]; string valueString; value_ptr->Get(valueString); if (valueType == ATTR_VAL_TYPE_ENUMERATED_LIST) { sprintf(message, "value \"%s\" not in list of enumerated values list", valueString.c_str()); GetMessages()->AddMessage(VAL_RULE_D_RANGE_1, message); } else // valueType == ATTR_VAL_TYPE_DEFINED_LIST { sprintf(message, "value \"%s\" not in list of defined terms list", valueString.c_str()); GetMessages()->AddMessage(VAL_RULE_D_RANGE_2, message); } status = MSG_ERROR; } } return status; } int noOfIterations; if (noOfLists < dcmAttributeM_ptr->GetNrValues()) { noOfIterations = noOfLists; } else { noOfIterations = dcmAttributeM_ptr->GetNrValues(); } for (int i = 0; i < noOfIterations; i++) { valueList_ptr = defAttributeM_ptr->GetValueList(i); BASE_VALUE_CLASS *value_ptr = dcmAttributeM_ptr->GetValue(i); if (valueList_ptr->HasValue(value_ptr) == false) { char message[256]; string valueString; value_ptr->Get(valueString); if (valueType == ATTR_VAL_TYPE_ENUMERATED) { sprintf(message, "value \"%s\" not in list of enumerated values list", valueString.c_str()); GetMessages()->AddMessage(VAL_RULE_D_RANGE_1, message); } else // valueType == ATTR_VAL_TYPE_DEFINED { sprintf(message, "value \"%s\" not in list of defined terms list", valueString.c_str()); GetMessages()->AddMessage(VAL_RULE_D_RANGE_2, message); } status = MSG_ERROR; } } return status; }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckDefVRCompatibility(UINT32) // DESCRIPTION : Check the compatibility between the definition VR and that of // : the dicom attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DVT_STATUS status = MSG_OK; if ((dcmAttributeM_ptr == NULL) || (defAttributeM_ptr == NULL)) { // Don't perform any further checks. The presense of either the def or // dcm value has already been checked before. Just return. return MSG_OK; } ATTR_VR_ENUM defVr = defAttributeM_ptr->GetVR(); ATTR_VR_ENUM dcmVr = dcmAttributeM_ptr->GetVR(); if (defVr == dcmVr) { // VR is the same. Leave asap. return MSG_OK; } UINT32 tag = (dcmAttributeM_ptr->GetMappedGroup() << 16) + (dcmAttributeM_ptr->GetMappedElement()); if ((((tag & 0xFF00FFFF) == TAG_AUDIO_SAMPLE_DATA) || ((tag & 0xFF00FFFF) == TAG_CURVE_DATA) || ((tag & 0xFF00FFFF) == TAG_OVERLAY_DATA)) && ((dcmVr == ATTR_VR_OB) || (dcmVr == ATTR_VR_OF) || (dcmVr == ATTR_VR_OW))) { return MSG_OK; } switch (tag) { case TAG_PIXEL_DATA: if ((dcmVr == ATTR_VR_OB) || (dcmVr == ATTR_VR_OF) || (dcmVr == ATTR_VR_OW)) { return MSG_OK; } break; case TAG_SMALLEST_IMAGE_PIXEL_VALUE: case TAG_LARGEST_IMAGE_PIXEL_VALUE: case TAG_SMALLEST_PIXEL_VALUE_IN_SERIES: case TAG_LARGEST_PIXEL_VALUE_IN_SERIES: case TAG_SMALLEST_IMAGE_PIXEL_VALUE_IN_PLANE: case TAG_LARGEST_IMAGE_PIXEL_VALUE_IN_PLANE: case TAG_PIXEL_PADDING_VALUE: { DCM_ATTRIBUTE_GROUP_CLASS *parent_ptr = dcmAttributeM_ptr->getParent(); if (parent_ptr != NULL) { UINT16 pixelRepresentation = parent_ptr->getPixelRepresentation(); // Any of the following statements don't actually change // the VR of the dcm value, it just enables to check if the // alternate VR is allowed. if (pixelRepresentation == 0) { dcmVr = ATTR_VR_US; } if (pixelRepresentation == 1) { dcmVr = ATTR_VR_SS; } } } break; case TAG_RED_PALETTE_COLOR_LOOKUP_TABLE_DESCRIPTOR: case TAG_GREEN_PALETTE_COLOR_LOOKUP_TABLE_DESCRIPTOR: case TAG_BLUE_PALETTE_COLOR_LOOKUP_TABLE_DESCRIPTOR: if (dcmVr == ATTR_VR_OW) { return MSG_OK; } // Fall through. Don't add break! case TAG_LUT_DESCRIPTOR: case TAG_LUT_DATA: if ((dcmVr == ATTR_VR_US) || (dcmVr == ATTR_VR_SS)) { return MSG_OK; } break; default: break; } if (defVr != dcmVr) { char message[128]; sprintf (message, "Attribute VR of %s differs from definition VR of %s", stringVr(dcmVr), stringVr(defVr)); GetMessages()->AddMessage(VAL_RULE_D_VR_1, message); status = MSG_ERROR; } return status; }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckDefPresence(UINT32) // DESCRIPTION : Check the presence of the dicom attribute against the definition attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DVT_STATUS status = MSG_OK; ATTR_TYPE_ENUM attrType = defAttributeM_ptr->GetType(); switch (attrType) { case ATTR_TYPE_1: if ((dcmAttributeM_ptr == NULL) || (dcmAttributeM_ptr->getPaddedLength() == 0)) { if ((dcmAttributeM_ptr != NULL) && ((defAttributeM_ptr->GetVR() == ATTR_VR_OB) || (defAttributeM_ptr->GetVR() == ATTR_VR_OF) || (defAttributeM_ptr->GetVR() == ATTR_VR_OW))) { if(dcmAttributeM_ptr->GetNrValues() == 0) { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_13, "OB/OF/OW Data length is zero - Type 1 (mandatory) attribute should have at least one value"); } else { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_13, "Type 1 (mandatory) attribute should have at least one value with non-zero length OB/OF/OW Data"); } } else if (useConditionalTextDuringValidationM) { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_9, "Textual Module/Macro Condition may affect validation result: Type 1 (mandatory) attribute should be present with at least one value"); } else { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_1, "Type 1 (mandatory) attribute should be present with at least one value"); } status = MSG_ERROR; } break; case ATTR_TYPE_2: if (dcmAttributeM_ptr == NULL) { if (useConditionalTextDuringValidationM) { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_9, "Textual Module/Macro Condition may affect validation result: Type 2 attribute should be present with at least a zero-length"); } else { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_1, "Type 2 attribute should be present with at least a zero-length"); } status = MSG_ERROR; } break; case ATTR_TYPE_1C: // Fall through case ATTR_TYPE_2C: // Fall through case ATTR_TYPE_3C: if (defAttributeM_ptr->GetCondition() == NULL) { if (defAttributeM_ptr->GetTextualCondition().length() == 0) { GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_5, "Condition not defined in definition - cannot be further validated"); status = MSG_ERROR; } else { char message[1024]; sprintf(message, "Text Condition - \"%s\"", defAttributeM_ptr->GetTextualCondition().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_12, message); } } else { // define the co-object - for a dataset this may either be the command (for network) or // the file meta information (for media). The co-object may be needed during the condition // evaluation. DCM_ATTRIBUTE_GROUP_CLASS *coObject_ptr = NULL; if (parentM_ptr) { VAL_OBJECT_RESULTS_CLASS *parent_ptr = parentM_ptr->GetParentObject(); if (parent_ptr) { // see if the co-object is the command coObject_ptr = parent_ptr->GetCommand(); if (coObject_ptr == NULL) { // see if the co-object is the file meta information coObject_ptr = parent_ptr->GetFmi(); } } } char message[1024]; CONDITION_RESULT_ENUM conditionResult = CONDITION_FALSE; CONDITION_CLASS *condition_ptr = defAttributeM_ptr->GetCondition(); if (condition_ptr) { // evaluate the condition using the co-object (if present - may be NULL) conditionResult = condition_ptr->Evaluate(parentM_ptr->GetDcmAttributeGroup(), coObject_ptr, NULL); } if (conditionResult == CONDITION_TRUE) { if (dcmAttributeM_ptr == NULL) { // Type 3C attributes are optional - so even though the condition evaluates true the // attribute does not need to be present if (attrType != ATTR_TYPE_3C) { // The attribute should be present, but is not. sprintf(message, "Attribute expected according to condition: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_2, message); status = MSG_ERROR; } } } else if (conditionResult == CONDITION_TRUE_REQUIRES_MANUAL_INTERPRETATION) { if (dcmAttributeM_ptr == NULL) { // The attribute should be present, but is not. sprintf(message, "Attribute expected according to condition: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_2, message); status = MSG_ERROR; } else { // The attribute is present but requires further manual interpretation sprintf(message, "Attribute present - but result requires manual interpretation: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_11, message); } } else if (conditionResult == CONDITION_FALSE) { if (dcmAttributeM_ptr != NULL) { // The attribute should not be present, but it is present. sprintf(message, "Attribute NOT expected according to condition: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_3, message); } } else // condition_result == CONDITION_UNIMPORTANT { // include logging simply for debug purposes for now - should not be in final build if (dcmAttributeM_ptr != NULL) { // The attribute is present - doesn't matter. sprintf(message, "Attribute present - but presence not important: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_7, message); } else { // The attribute is not present - doesn't matter. sprintf(message, "Attribute not present - but presence not important: %s", defAttributeM_ptr->GetConditionResultMessage().c_str()); GetMessages()->AddMessage(VAL_RULE_D_PRESENCE_8, message); } } } break; } if ((status == MSG_OK) && ((attrType == ATTR_TYPE_1 || attrType == ATTR_TYPE_1C) && dcmAttributeM_ptr != NULL)) { if (dcmAttributeM_ptr->GetNrValues() == 0) { if (useConditionalTextDuringValidationM) { GetMessages()->AddMessage(VAL_RULE_D_VM_5, "Textual Module/Macro Condition may affect validation result: Zero-length not allowed for type 1 attribute"); } else { GetMessages()->AddMessage(VAL_RULE_D_VM_1, "Zero-length not allowed for type 1 attribute"); } status = MSG_ERROR; } } return status; }
DVT_STATUS VAL_BASE_VALUE_CLASS::CompareRef() // DESCRIPTION : // PRECONDITIONS : The ref and dcm values are both available. // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { char message[1200]; UINT16 group = TAG_UNDEFINED_GROUP; UINT16 element = TAG_UNDEFINED_ELEMENT; if (parentM_ptr != NULL) { DEF_ATTRIBUTE_CLASS *defAttribute_ptr = parentM_ptr->GetDefAttribute(); DCM_ATTRIBUTE_CLASS *dcmAttribute_ptr = parentM_ptr->GetDcmAttribute(); DCM_ATTRIBUTE_CLASS *refAttribute_ptr = parentM_ptr->GetRefAttribute(); if (dcmAttribute_ptr != NULL) { group = dcmAttribute_ptr->GetGroup(); element = dcmAttribute_ptr->GetElement(); } else if (defAttribute_ptr != NULL) { group = defAttribute_ptr->GetGroup(); element = defAttribute_ptr->GetElement(); } else if (refAttribute_ptr != NULL) { group = refAttribute_ptr->GetGroup(); element = refAttribute_ptr->GetElement(); } } LOG_MESSAGE_CLASS *logMessage_ptr = new LOG_MESSAGE_CLASS(); DVT_STATUS status = dcmValueM_ptr->Compare(logMessage_ptr, refValueM_ptr); if (logMessage_ptr->GetNrMessages() > 0) { for (int i = 0; i < logMessage_ptr->GetNrMessages(); i++) { if (group != TAG_UNDEFINED_GROUP) { char message[1024]; sprintf(message, "Attribute (%04X,%04X) %s", group, element, logMessage_ptr->GetMessage(i).c_str()); GetMessages()->AddMessage(logMessage_ptr->GetMessageId(i), message); } else { GetMessages()->AddMessage(logMessage_ptr->GetMessageId(i), logMessage_ptr->GetMessage(i)); } } } delete logMessage_ptr; if ((status != MSG_OK) && (status != MSG_EQUAL)) { string dcmStringValue; string refStringvalue; dcmValueM_ptr->Get(dcmStringValue); refValueM_ptr->Get(refStringvalue); if (group != TAG_UNDEFINED_GROUP) { if ((dcmStringValue.length() + refStringvalue.length()) < 1024) { sprintf(message, "Attribute (%04X,%04X) value of \"%s\" different from reference value of \"%s\"", group, element, dcmStringValue.c_str(), refStringvalue.c_str()); } else { sprintf(message, "Attribute (%04X,%04X) value is different from reference value", group, element); } } else { if ((dcmStringValue.length() + refStringvalue.length()) < 1024) { sprintf(message, "Attribute value of \"%s\" different from reference value of \"%s\"", dcmStringValue.c_str(), refStringvalue.c_str()); } else { sprintf(message, "Attribute value is different from reference value"); } } GetMessages()->AddMessage(VAL_RULE_R_VALUE_1, message); } return status; }
bool GERBVIEW_FRAME::Read_EXCELLON_File( const wxString& aFullFileName ) { wxString msg; int layerId = GetActiveLayer(); // current layer used in GerbView GERBER_FILE_IMAGE_LIST* images = GetGerberLayout()->GetImagesList(); auto gerber_layer = images->GetGbrImage( layerId ); auto drill_layer = dynamic_cast<EXCELLON_IMAGE*>( gerber_layer ); if( gerber_layer && !drill_layer ) { // The active layer contains old gerber data we have to clear Erase_Current_DrawLayer( false ); } if( drill_layer == nullptr ) { drill_layer = new EXCELLON_IMAGE( layerId ); layerId = images->AddGbrImage( drill_layer, layerId ); } if( layerId < 0 ) { DisplayError( this, _( "No room to load file" ) ); return false; } // Read the Excellon drill file: bool success = drill_layer->LoadFile( aFullFileName ); if( !success ) { msg.Printf( _( "File %s not found" ), GetChars( aFullFileName ) ); DisplayError( this, msg ); return false; } // Display errors list if( drill_layer->GetMessages().size() > 0 ) { HTML_MESSAGE_BOX dlg( this, _( "Error reading EXCELLON drill file" ) ); dlg.ListSet( drill_layer->GetMessages() ); dlg.ShowModal(); } if( success ) { EDA_DRAW_PANEL_GAL* canvas = GetGalCanvas(); if( canvas ) { KIGFX::VIEW* view = canvas->GetView(); for( GERBER_DRAW_ITEM* item = drill_layer->GetItemsList(); item; item = item->Next() ) { view->Add( (KIGFX::VIEW_ITEM*) item ); } } } return success; }
std::vector<int> IMAPFolder::Expunge() { return GetMessages()->Expunge(); }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckDefValueMultiplicity(UINT32) // DESCRIPTION : Check the dicom attribute value multiplicity against the definition // : attribute. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DVT_STATUS status = MSG_OK; char message[128]; if (dcmAttributeM_ptr == NULL) { return MSG_OK; } int noOfValues = dcmAttributeM_ptr->GetNrValues(); if (noOfValues == 0) { // If there are 0 values available, then a possible message has // been generated during the Presence check. return MSG_OK; } UINT vmMin = defAttributeM_ptr->GetVmMin(); UINT vmMax = defAttributeM_ptr->GetVmMax(); // Check VM range. if (((UINT)noOfValues < vmMin) || ((UINT)noOfValues > vmMax)) { sprintf(message, "Number of attribute values %d out of Value Multiplicity range (%d..%d)", noOfValues, vmMin, vmMax); GetMessages()->AddMessage(VAL_RULE_D_VM_2, message); status = MSG_ERROR; } // Check restrictions. switch (defAttributeM_ptr->GetVmRestriction()) { case ATTR_VM_RESTRICT_EVEN: if (noOfValues % 2 != 0) { sprintf(message, "Number of attribute values (VM) of %d expected to be even", noOfValues); GetMessages()->AddMessage(VAL_RULE_D_VM_3, message); status = MSG_ERROR; } break; case ATTR_VM_RESTRICT_TRIPLE: if (noOfValues % 3 != 0) { sprintf(message, "Number of attribute values (VM) of %d expected to be divisible by 3", noOfValues); GetMessages()->AddMessage(VAL_RULE_D_VM_4, message); status = MSG_ERROR; } break; } return status; }
std::vector<int> IMAPFolder::Expunge(const std::set<int> &uids, const boost::function<void()> &func) { return GetMessages()->Expunge(false, uids, func); }
DVT_STATUS VAL_ATTRIBUTE_CLASS::CheckPixelDataLength() // DESCRIPTION : Check the pixel data length is consistent with the image // : dimensions as defined by the rows, columns and bits allocated // : attributes. // : The dimensions should match the pixel data length if the image // : is uncompressed. If the image is compressed we assume that the // : pixel data length will be less than the dimensions. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { char message[512]; // check that we are dealing with the pixel attribute DCM_ATTRIBUTE_CLASS *dcmAttr_ptr = this->GetDcmAttribute(); if (dcmAttr_ptr == NULL) { return MSG_OK; } // check if pixel data is stored if (dcmAttr_ptr->getPaddedLength() == 0) { return MSG_OK; } UINT32 tag = (dcmAttr_ptr->GetMappedGroup() << 16) + (dcmAttr_ptr->GetMappedElement()); if (tag != TAG_PIXEL_DATA) { return MSG_OK; } // get the parent to allow access to the rows, columns and bits allocated attributes DCM_ATTRIBUTE_GROUP_CLASS *parent = dcmAttr_ptr->getParent(); if (parent == NULL) { sprintf(message, "Cannot get the Dataset for the Rows (0028,0010), Columns (0028,0011) and Bits Allocated (0028,0100) Attributes needed for the Pixel Data length validation"); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_1, message); return MSG_ERROR; } // get the image dimensions UINT16 rows; if (!parent->getUSValue(TAG_ROWS, &rows)) { sprintf(message, "Dataset does not contain the Rows (0028,0010) Attribute needed for the Pixel Data length validation"); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_2, message); return MSG_ERROR; } UINT16 columns; if (!parent->getUSValue(TAG_COLUMNS, &columns)) { sprintf(message, "Dataset does not contain the Columns (0028,0011) Attribute needed for the Pixel Data length validation"); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_3, message); return MSG_ERROR; } UINT16 bitsAllocated; if (!parent->getUSValue(TAG_BITS_ALLOCATED, &bitsAllocated)) { sprintf(message, "Dataset does not contain the Bits Allocated (0028,0100) Attribute needed for the Pixel Data length validation"); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_4, message); return MSG_ERROR; } // get optional samples per pixel UINT16 samplesPerPixel; if (!parent->getUSValue(TAG_SAMPLES_PER_PIXEL, &samplesPerPixel)) { // value not present - set default of 1 samplesPerPixel = 1; } // get optional number of frames INT32 noOfFrames; if (!parent->getISValue(TAG_NUMBER_OF_FRAMES, &noOfFrames)) { // value not present - set default of 1 noOfFrames = 1; } // get the pixel value bool compressed = false; if (dcmAttr_ptr->GetNrValues() == 1) { switch(dcmAttr_ptr->GetVR()) { case ATTR_VR_OB: { // check if the data is compressed VALUE_OB_CLASS *obValue_ptr = (VALUE_OB_CLASS*)dcmAttr_ptr->GetValue(0); if (obValue_ptr != NULL) { compressed = obValue_ptr->IsCompressed(); } } break; case ATTR_VR_OF: { // check if the data is compressed VALUE_OF_CLASS *ofValue_ptr = (VALUE_OF_CLASS*)dcmAttr_ptr->GetValue(0); if (ofValue_ptr != NULL) { compressed = ofValue_ptr->IsCompressed(); } } break; case ATTR_VR_OW: { // check if the data is compressed VALUE_OW_CLASS *owValue_ptr = (VALUE_OW_CLASS*)dcmAttr_ptr->GetValue(0); if (owValue_ptr != NULL) { compressed = owValue_ptr->IsCompressed(); } } break; default: break; } } // compute the pixel data length UINT32 computedPixelDataLength = noOfFrames * (UINT32) samplesPerPixel * (UINT32) rows * (UINT32) columns * (UINT32) (bitsAllocated / 8); DVT_STATUS status = MSG_OK; if (compressed) { // pixel data is compressed - so length should be less than (or equal?) if (dcmAttr_ptr->getPaddedLength() > computedPixelDataLength) { sprintf (message, "Compressed Pixel Data Length of %d larger than maximum computed length of %d (from Number Of Frames=%d, Samples Per Pixel=%d, Rows=%d, Columns=%d, Bits Allocated=%d)", dcmAttr_ptr->getPaddedLength(), computedPixelDataLength, noOfFrames, samplesPerPixel, rows, columns, bitsAllocated); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_5, message); status = MSG_ERROR; } } else { // add 1 to computed length if odd if (computedPixelDataLength & 0x1) { computedPixelDataLength++; } // pixel data is not compressed - so lengths should match if (dcmAttr_ptr->getPaddedLength() != computedPixelDataLength) { sprintf (message, "Uncompressed Pixel Data Length of %d does not match computed length of %d (from Number Of Frames=%d, Samples Per Pixel=%d, Rows=%d, Columns=%d, Bits Allocated=%d)", dcmAttr_ptr->getPaddedLength(), computedPixelDataLength, noOfFrames, samplesPerPixel, rows, columns, bitsAllocated); GetMessages()->AddMessage(VAL_RULE_PIXEL_DATA_6, message); status = MSG_ERROR; } } return status; }
DVT_STATUS VAL_BASE_VALUE_CLASS::Check(UINT32 flags, SPECIFIC_CHARACTER_SET_CLASS *specificCharacterSet_ptr) // DESCRIPTION : Check the dicom attribute value. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { DVT_STATUS status = MSG_NO_VALUE; UINT16 group = TAG_UNDEFINED_GROUP; UINT16 element = TAG_UNDEFINED_ELEMENT; if (parentM_ptr != NULL) { DEF_ATTRIBUTE_CLASS *defAttribute_ptr = parentM_ptr->GetDefAttribute(); DCM_ATTRIBUTE_CLASS *dcmAttribute_ptr = parentM_ptr->GetDcmAttribute(); DCM_ATTRIBUTE_CLASS *refAttribute_ptr = parentM_ptr->GetRefAttribute(); if (dcmAttribute_ptr != NULL) { group = dcmAttribute_ptr->GetGroup(); element = dcmAttribute_ptr->GetElement(); } else if (defAttribute_ptr != NULL) { group = defAttribute_ptr->GetGroup(); element = defAttribute_ptr->GetElement(); } else if (refAttribute_ptr != NULL) { group = refAttribute_ptr->GetGroup(); element = refAttribute_ptr->GetElement(); } } if (dcmValueM_ptr != NULL) { LOG_MESSAGE_CLASS *logMessage_ptr = new LOG_MESSAGE_CLASS(); // Perform special validation for Ref File ID //DICOM part 10; 8.5 CHARACTER SET //File IDs and File-set IDs shall be character strings made of characters from a subset //of the G0 repertoire of ISO 8859. The following characters form this subset: //A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z (uppercase) //1, 2, 3, 4, 5, 6, 7, 8, 9, 0 and _ (underscore) //Annex F Basic Directory Information Object Definition (Normative), Table F.3-3 DIRECTORY //INFORMATION MODULE says about attribute Referenced File ID (0004,1500): "A Multiple Value //(See PS 3.5) which represents the ordered components of the File ID containing a "referenced object" //or Referenced SOP Instance. A maximum of 8 components, each from 1 to 8 characters shall be used //(see Section 8.2)." if((group == 0x0004) && (element == 0x1500)) { char message[1024]; UINT length = dcmValueM_ptr->GetLength(); string value; dcmValueM_ptr->Get(value,true); if (length > 0) { // check for A..Z, 0..9, UNDERSCORE for (UINT index = 0; index < length; index++) { if (value[index] == NULLCHAR) { break; } if ( ( (value[index] < 'A') || (value[index] > 'Z') ) && ( (value[index] < '0') || (value[index] > '9') ) && (value[index] != UNDERSCORE) ) { sprintf (message,"unexpected character %c=0x%02X at offset %d", (int) value[index], (int) value[index], index+1); logMessage_ptr->AddMessage (VAL_RULE_D_CS_2, message); status = MSG_ERROR; } } } } else { status = dcmValueM_ptr->Check(flags, NULL, logMessage_ptr, specificCharacterSet_ptr); } if (logMessage_ptr->GetNrMessages() > 0) { for (int i = 0; i < logMessage_ptr->GetNrMessages(); i++) { if (group != TAG_UNDEFINED_GROUP) { char message[1024]; sprintf(message, "Attribute (%04X,%04X) %s", group, element, logMessage_ptr->GetMessage(i).c_str()); GetMessages()->AddMessage(logMessage_ptr->GetMessageId(i), message); } else { GetMessages()->AddMessage(logMessage_ptr->GetMessageId(i), logMessage_ptr->GetMessage(i)); } } } delete logMessage_ptr; } return status; }