From: <xb...@us...> - 2013-07-17 15:45:41
|
Revision: 1850 http://sourceforge.net/p/scstudio/code/1850 Author: xborza Date: 2013-07-17 15:45:38 +0000 (Wed, 17 Jul 2013) Log Message: ----------- connecting of messages to instance behind coregion area, as well as to wrong (depending on message orientation and coregion's side) side of coregion solved. Modified Paths: -------------- trunk/src/view/visio/addon/document.cpp trunk/src/view/visio/addon/enums.h trunk/src/view/visio/addon/messageJump.cpp trunk/src/view/visio/addon/messageSnapping.cpp trunk/src/view/visio/addon/messageSnapping.h trunk/src/view/visio/addon/pcapSettingADlg.cpp trunk/src/view/visio/addon/pcapSettingGDlg.cpp trunk/src/view/visio/addon/pcapSettingViewDlg.cpp trunk/src/view/visio/addon/shapeutils.cpp trunk/src/view/visio/addon/shapeutils.h Modified: trunk/src/view/visio/addon/document.cpp =================================================================== --- trunk/src/view/visio/addon/document.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/document.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -276,7 +276,7 @@ case ST_BMSC_INSTANCE: if(vsoShape->Text.length() == 0) vsoShape->Text = _T("NAME"); - //Remove blind connection points + //Remove blind connection points - if instance is copied remove_shape_blind_connections(vsoShape); break; Modified: trunk/src/view/visio/addon/enums.h =================================================================== --- trunk/src/view/visio/addon/enums.h 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/enums.h 2013-07-17 15:45:38 UTC (rev 1850) @@ -58,6 +58,13 @@ MSJUMP_RIGHT = 2, }; +typedef enum +{ + COR_NONE, + COR_LEFT, + COR_RIGHT +}CoregionSides; + enum MsgDirection { MSG_RIGHT = 0, Modified: trunk/src/view/visio/addon/messageJump.cpp =================================================================== --- trunk/src/view/visio/addon/messageJump.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/messageJump.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -152,7 +152,7 @@ boost::shared_ptr<MscPoint> intPoint (CMessageSnapping::getIntersectionWithInstance(MscPoint(pointOnShape.get_x()-1, pointOnShape.get_y()), MscPoint(pointOnShape.get_x(), pointOnShape.get_y()), *it)); - if(!intPoint || !CMessageSnapping::isPointOnInstancesLine(*intPoint, *it)) + if(!intPoint || !CShapeUtils::isPointOnInstancesLine(*intPoint, *it)) continue; if(CMessageSnapping::pointsEqual(*intPoint, pointOnShape, 0.001)) return *it; Modified: trunk/src/view/visio/addon/messageSnapping.cpp =================================================================== --- trunk/src/view/visio/addon/messageSnapping.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/messageSnapping.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -140,32 +140,32 @@ //Check whether point is only on instanceLine or on coregion bool mes_in_coreg = false; - - if(!(intPoint && (isPointOnInstancesLine(*intPoint, *it) || isPointOnCoregion(*intPoint, *it)))) + + if(!(intPoint && (CShapeUtils::isPointOnInstancesLine(*intPoint, *it) || CShapeUtils::isPointOnCoregion(*intPoint, *it)))) continue; //check if Message SnapPoints lies in Coregion area MscPoint point; point.set_x(msgSnapPointX); point.set_y(msgSnapPointY); - mes_in_coreg = isPointInCoregionArea(point, *it); + mes_in_coreg = CShapeUtils::isPointInCoregionArea(point, *it); mouseDistX = msgSnapPointX - intPoint->get_x(); distance = sqrt(pow((msgSnapPointX - intPoint->get_x()),2) + pow((msgSnapPointY - intPoint->get_y()),2)); delete intPoint; - if((mouseDistX < 0 && !mes_in_coreg) || (mes_in_coreg && mouseDistX > 0 && !rightClosestInstance)) + if((mouseDistX <= 0 && !mes_in_coreg) || (mes_in_coreg && mouseDistX >= 0 && !rightClosestInstance)) { - if(!rightClosestInstance || distance < rightClosestInstanceDist) + if(!rightClosestInstance || distance <= rightClosestInstanceDist) { rightClosestInstance = (*it); rightClosestInstanceDist = distance; } } - else if((mouseDistX > 0 && !mes_in_coreg) || (mes_in_coreg && mouseDistX < 0 && !leftClosestInstance)) + else if((mouseDistX >= 0 && !mes_in_coreg) || (mes_in_coreg && mouseDistX <= 0 && !leftClosestInstance)) { - if(!leftClosestInstance || distance < leftClosestInstanceDist) + if(!leftClosestInstance || distance <= leftClosestInstanceDist) { leftClosestInstance = (*it); leftClosestInstanceDist = distance; @@ -224,6 +224,9 @@ } MsgDirection msgDir = CShapeUtils::getMsgDirection(msgShape); + // check if message endpoints are glued correctly + unglueWrongConnectedMessage(msgShape, leftInstance); + unglueWrongConnectedMessage(msgShape, rightInstance); //Glue to left instance or to right instance (at least one endpoint must be snapped to return true) if(bLeft && glueMsgToInstance(msgShape, leftInstance, "BeginX", yLeftPos, msgDir, dontGlueIfConnected)) result++; @@ -236,6 +239,7 @@ bool CMessageSnapping::glueMsgToInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, const _bstr_t & msgCell, double yPos, VisUnitCodes units) { + unglueWrongConnectedMessage(msgShape, instanceShape); return glueMsgToInstance(msgShape, instanceShape, msgCell, yPos, CShapeUtils::getMsgDirection(msgShape), true, units); } @@ -244,13 +248,19 @@ { if(!msgShape || !instanceShape) return false; - + + Visio::IVCellPtr thisCell = msgShape->GetCells(msgCell); bool isBegin = _tcsicmp(msgCell,_T("BeginX")) == 0; //NOTE: If user snap message by himself (using red rectangle), we are done + // !! check if msgCell is not wrong connected -- on instance behind coregion are or on bad side of coregion (from inside) if(dontGlueIfConnected) + { // check if its connected if(msgShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2) - return false; - + { + return false; + } + } + //NOTE: Return if endpoint is found or lost message TShapeType shapeType = get_shape_type(msgShape); if( (shapeType == 2 && _tcsicmp(msgCell,_T("EndX")) == 0) || (shapeType == 3 && isBegin) ) @@ -332,80 +342,6 @@ return getIntersectionWithInstance(p2, p1, instanceShape, units); } -bool CMessageSnapping::isPointInCoregionArea(const MscPoint& point, Visio::IVShapePtr instShape) -{ - double coregBegX, coregEndX, coregBegY, coregEndY; - - std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instShape, ST_BMSC_COREGION); - for(u_int i=0; i<cor.size(); i++) - { - Visio::IVShapePtr coregShape = cor.at(i); - - double dif = CShapeUtils::getCoregionHeight(coregShape); - coregBegX = CShapeUtils::getShapeCell(coregShape, "BeginX") - dif; - coregEndX = CShapeUtils::getShapeCell(coregShape, "EndX") + dif; - coregBegY = CShapeUtils::getShapeCell(coregShape, "BeginY"); - coregEndY = CShapeUtils::getShapeCell(coregShape, "EndY"); - - //check if MscPoint lies on one of the coregion's sides - bool x_coordinate = false, y_coordinate = false; - x_coordinate = point.get_x() > coregBegX && point.get_x() < coregEndX; - y_coordinate = point.get_y() < coregBegY && point.get_y() > coregEndY; - - if(x_coordinate && y_coordinate) - return true; - } - return false; -} - -bool CMessageSnapping::isPointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape) -{ - double coregBegX, coregEndX, coregBegY, coregEndY; - - std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instShape, ST_BMSC_COREGION); - for(u_int i=0; i<cor.size(); i++) - { - Visio::IVShapePtr coregShape = cor.at(i); - - double dif = CShapeUtils::getCoregionHeight(coregShape); - coregBegX = CShapeUtils::getShapeCell(coregShape, "BeginX") - dif; - coregEndX = CShapeUtils::getShapeCell(coregShape, "EndX") + dif; - coregBegY = CShapeUtils::getShapeCell(coregShape, "BeginY"); - coregEndY = CShapeUtils::getShapeCell(coregShape, "EndY"); - - //check if MscPoint lies on one of the coregion's sides - bool x_coordinate = false, y_coordinate = false; - x_coordinate = fabs(point.get_x() - coregBegX) < 0.01 || fabs(point.get_x() - coregEndX) < 0.01; - y_coordinate = point.get_y() <= coregBegY && point.get_y() >= coregEndY; - - if(x_coordinate && y_coordinate) - return true; - } - return false; -} - -bool CMessageSnapping::isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units) -{ - if(!instShape) - return false; - -#define _sp(x) CShapeUtils::getShapeCell(instShape, x, units) - - double InstOffset = 0; - - //Get values from cells - if(instShape->CellExists["Controls.mscHeadWidth"][visExistsAnywhere]) //NOTE: Check if the instance is not headless - InstOffset = _sp("Controls.mscHeadWidth.X"); //NOTE: get width of instances rectangles - - double sizeOfInstance = _sp("Width"); - double msgOffset = sqrt( pow(point.get_x() - _sp("BeginX"),2) + pow(point.get_y() - _sp("BeginY"),2) ); - - //Glue to position, if message is on "rectangles" on the instance it won't be glued - return !((msgOffset < InstOffset) || (msgOffset > (sizeOfInstance - InstOffset))); - -#undef _sp -} - bool CMessageSnapping::getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units) { if(!msgShape || !resultVector || !isMessageShape(msgShape)) @@ -543,9 +479,9 @@ MscPoint* bufferPoint = getIntersectionWithInstance(msgShape,it, (VisUnitCodes)0); if(bufferPoint) { - if(pointsEqual(*bufferPoint, beginPoint, precision) && isPointOnInstancesLine(beginPoint, it, (VisUnitCodes)0)) + if(pointsEqual(*bufferPoint, beginPoint, precision) && CShapeUtils::isPointOnInstancesLine(beginPoint, it, (VisUnitCodes)0)) glueMsgToInstance(msgShape, it, "BeginX", beginPoint.get_y(), (VisUnitCodes)0); - else if(pointsEqual(*bufferPoint, endPoint, precision) && isPointOnInstancesLine(endPoint, it, (VisUnitCodes)0)) + else if(pointsEqual(*bufferPoint, endPoint, precision) && CShapeUtils::isPointOnInstancesLine(endPoint, it, (VisUnitCodes)0)) glueMsgToInstance(msgShape, it, "EndX", endPoint.get_y(), (VisUnitCodes)0); } delete bufferPoint; @@ -679,6 +615,71 @@ return NULL; } +int CMessageSnapping::unglueWrongConnectedMessage(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape) +{ + int res = 0; + if(!msgShape || !instanceShape) + return res; + + if(unglueWrongConnectedMsgCell(msgShape,"BeginX",instanceShape)) + res++; + if(unglueWrongConnectedMsgCell(msgShape,"EndX",instanceShape)) + res++; + return res; +} + +bool CMessageSnapping::unglueWrongConnectedMsgCell(Visio::IVShapePtr msgShape, const _bstr_t & msgCell, Visio::IVShapePtr instanceShape) +{ + int result = 0; + if(!msgShape || !instanceShape) + return false; + + bool isBegin = _tcsicmp(msgCell,_T("BeginX")) == 0; + + if(msgShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->ResultInt[visNone][visTruncate] == 2) + { + MscPoint cellPoint; + cellPoint.set_x(msgShape->GetCells(msgCell)->Result[70]); // 70 = Visio::VisUnitCodes::visMillimeters + + if(isBegin) + cellPoint.set_y(msgShape->GetCells("BeginY")->Result[70]); + else + cellPoint.set_y(msgShape->GetCells("EndY")->Result[70]); + + // check if message is attached to instance behind the coregion + if(CShapeUtils::isPointInCoregionArea(cellPoint, instanceShape)) + { + if(CShapeUtils::unglueShape(msgShape, msgCell, instanceShape)) + result++; + } + // check if message is attached to wrong sides of coregion + CoregionSides cor_side = COR_NONE; + Visio::IVShapePtr coregion = NULL; + + if((cor_side = CShapeUtils::wherePointOnCoregion(cellPoint,instanceShape,coregion)) != COR_NONE) + { + MsgDirection msg_direct = CShapeUtils::getMsgDirection(msgShape); + if(msg_direct == MSG_LEFT) + { + if(!((cor_side == COR_LEFT && isBegin) || (cor_side == COR_RIGHT && !isBegin))) + { + if(CShapeUtils::unglueShape(msgShape,msgCell,coregion)) + result++; + } + } + else + { + if(!((cor_side == COR_RIGHT && isBegin) || (cor_side == COR_LEFT && !isBegin))) + { + if(CShapeUtils::unglueShape(msgShape,msgCell,coregion)) + result++; + } + } + } + } + return (result > 0); +} + bool CMessageSnapping::coregionTreatment(Visio::IVShapePtr& instanceShape, MscPoint& instBegin, MscPoint& instEnd, MsgDirection posToCoregion, bool &xPos, const double &yPos, VisUnitCodes units) { Modified: trunk/src/view/visio/addon/messageSnapping.h =================================================================== --- trunk/src/view/visio/addon/messageSnapping.h 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/messageSnapping.h 2013-07-17 15:45:38 UTC (rev 1850) @@ -67,21 +67,8 @@ static MscPoint* getIntersectionWithInstance(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits); static MscPoint* getIntersectionWithInstance(const MscPoint& beginPoint,const MscPoint& endPoint, Visio::IVShapePtr instanceShape, VisUnitCodes units = visPageUnits); - /** - * - */ - static bool isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape,VisUnitCodes units = visPageUnits); - - /* - * Check all coregions boundaries in instance, if it contains MSCpint - */ - static bool isPointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape); /** - * Check all coregions on instance, if it contains MSCpint - */ - static bool isPointInCoregionArea(const MscPoint& point, Visio::IVShapePtr instShape); - /** * Get Directional vector of given message shape */ static bool getMsgVector(Visio::IVShapePtr msgShape, MscPoint* resultVector, VisUnitCodes units = visMillimeters); @@ -124,6 +111,20 @@ */ static MscPoint* getIntersectionWithCoregion( MscPoint beginPoint, MscPoint endPoint, Visio::IVShapePtr coregionShape, VisUnitCodes units = visPageUnits); + + /** + * Return number of unglued endpoints + */ + static int unglueWrongConnectedMessage(Visio::IVShapePtr msgShape, Visio::IVShapePtr instanceShape); + /** + * Remove all connection points, which are wrong - message is glued to instance behind coregion or wrong to coregion (bottom) + * | + * |<----|---- + * | | and right message + * <-------| + * | + */ + static bool unglueWrongConnectedMsgCell(Visio::IVShapePtr msgShape, const _bstr_t & msgCell, Visio::IVShapePtr instanceShape); private: /** Modified: trunk/src/view/visio/addon/pcapSettingADlg.cpp =================================================================== --- trunk/src/view/visio/addon/pcapSettingADlg.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/pcapSettingADlg.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -148,22 +148,16 @@ void CPcapSettingsADlg::OnDataValidateError(UINT nCtrlID, BOOL bSave, _XData& data) { -CString sMsg = ""; +/*CString sMsg = ""; switch (nCtrlID) { - /*case IDC_HEAD_DIST_VALUE : - sMsg.Format(_T("The distance between the instance begin and the first element must be between %d mm and %d mm."), - (int)data.floatData.nMin, (int)data.floatData.nMax ); - ::SetFocus ( GetDlgItem(nCtrlID) ); - break;*/ - // in case of time precision use case and validate range of values default: sMsg = "Unknown error"; TRACE("CPcapSettingsDlg::OnDataValidateError() does not have a validation error message for a control"); } - MessageBox(sMsg, _T("Setting pcap Error"), MB_ICONEXCLAMATION); + MessageBox(sMsg, _T("Setting pcap Error"), MB_ICONEXCLAMATION);*/ } // HTTP Modified: trunk/src/view/visio/addon/pcapSettingGDlg.cpp =================================================================== --- trunk/src/view/visio/addon/pcapSettingGDlg.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/pcapSettingGDlg.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -176,14 +176,9 @@ void CPcapSettingsGDlg::OnDataValidateError(UINT nCtrlID, BOOL bSave, _XData& data) { -CString sMsg = ""; +/*CString sMsg = ""; switch (nCtrlID) { - /*case IDC_HEAD_DIST_VALUE : - sMsg.Format(_T("The distance between the instance begin and the first element must be between %d mm and %d mm."), - (int)data.floatData.nMin, (int)data.floatData.nMax ); - ::SetFocus ( GetDlgItem(nCtrlID) ); - break;*/ // in case of time precision use case and validate range of values default: @@ -191,7 +186,7 @@ TRACE("CBeautifySettingsDlg::OnDataValidateError() does not have a validation error message for a control"); } - MessageBox(sMsg, _T("Setting Pcap Error"), MB_ICONEXCLAMATION); + MessageBox(sMsg, _T("Setting Pcap Error"), MB_ICONEXCLAMATION);*/ } // TO DO OnFilterValue... Modified: trunk/src/view/visio/addon/pcapSettingViewDlg.cpp =================================================================== --- trunk/src/view/visio/addon/pcapSettingViewDlg.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/pcapSettingViewDlg.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -127,22 +127,16 @@ void CPcapSettingsViewDlg::OnDataValidateError(UINT nCtrlID, BOOL bSave, _XData& data) { -CString sMsg = ""; +/*CString sMsg = ""; switch (nCtrlID) { - /*case IDC_HEAD_DIST_VALUE : - sMsg.Format(_T("The distance between the instance begin and the first element must be between %d mm and %d mm."), - (int)data.floatData.nMin, (int)data.floatData.nMax ); - ::SetFocus ( GetDlgItem(nCtrlID) ); - break;*/ - // in case of time precision use case and validate range of values default: sMsg = "Unknown error"; TRACE("CBeautifySettingsViewDlg::OnDataValidateError() does not have a validation error message for a control"); } - MessageBox(sMsg, _T("Setting pcap Error"), MB_ICONEXCLAMATION); + MessageBox(sMsg, _T("Setting pcap Error"), MB_ICONEXCLAMATION);*/ } //---------------------------------------------------------------------------------------------- Modified: trunk/src/view/visio/addon/shapeutils.cpp =================================================================== --- trunk/src/view/visio/addon/shapeutils.cpp 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/shapeutils.cpp 2013-07-17 15:45:38 UTC (rev 1850) @@ -194,6 +194,143 @@ return (BeginX < EndX) ? MSG_RIGHT : MSG_LEFT; } +CoregionSides CShapeUtils::wherePointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape, Visio::IVShapePtr& coregShape) +{ + double coregBegX, coregEndX, coregBegY, coregEndY; + + std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instShape, ST_BMSC_COREGION); + for(u_int i=0; i<cor.size(); i++) + { + Visio::IVShapePtr m_coregShape = cor.at(i); + + double dif = CShapeUtils::getCoregionHeight(m_coregShape); + coregBegX = CShapeUtils::getShapeCell(m_coregShape, "BeginX") - dif; + coregEndX = CShapeUtils::getShapeCell(m_coregShape, "EndX") + dif; + coregBegY = CShapeUtils::getShapeCell(m_coregShape, "BeginY"); + coregEndY = CShapeUtils::getShapeCell(m_coregShape, "EndY"); + + //check if MscPoint lies on one of the coregion's sides + bool x_left = false, x_right = false, y_coordinate = false; + x_left = fabs(point.get_x() - coregBegX) < 0.01; + x_right = fabs(point.get_x() - coregEndX) < 0.01; + y_coordinate = point.get_y() <= coregBegY && point.get_y() >= coregEndY; + + if(y_coordinate) + { + if(x_left) + { + coregShape = m_coregShape; + return COR_LEFT; + } + if(x_right) + { + coregShape = m_coregShape; + return COR_RIGHT; + } + } + } + return COR_NONE; +} + +bool CShapeUtils::isPointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape) +{ + double coregBegX, coregEndX, coregBegY, coregEndY; + + std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instShape, ST_BMSC_COREGION); + for(u_int i=0; i<cor.size(); i++) + { + Visio::IVShapePtr coregShape = cor.at(i); + + double dif = CShapeUtils::getCoregionHeight(coregShape); + coregBegX = CShapeUtils::getShapeCell(coregShape, "BeginX") - dif; + coregEndX = CShapeUtils::getShapeCell(coregShape, "EndX") + dif; + coregBegY = CShapeUtils::getShapeCell(coregShape, "BeginY"); + coregEndY = CShapeUtils::getShapeCell(coregShape, "EndY"); + + //check if MscPoint lies on one of the coregion's sides + bool x_coordinate = false, y_coordinate = false; + x_coordinate = fabs(point.get_x() - coregBegX) < 0.01 || fabs(point.get_x() - coregEndX) < 0.01; + y_coordinate = point.get_y() <= coregBegY && point.get_y() >= coregEndY; + + if(x_coordinate && y_coordinate) + return true; + } + return false; +} + +bool CShapeUtils::isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape, VisUnitCodes units) +{ + if(!instShape) + return false; + +#define _sp(x) CShapeUtils::getShapeCell(instShape, x, units) + + double InstOffset = 0; + + //Get values from cells + if(instShape->CellExists["Controls.mscHeadWidth"][visExistsAnywhere]) //NOTE: Check if the instance is not headless + InstOffset = _sp("Controls.mscHeadWidth.X"); //NOTE: get width of instances rectangles + + double sizeOfInstance = _sp("Width"); + double msgOffset = sqrt( pow(point.get_x() - _sp("BeginX"),2) + pow(point.get_y() - _sp("BeginY"),2) ); + + //Glue to position, if message is on "rectangles" on the instance it won't be glued + return !((msgOffset < InstOffset) || (msgOffset > (sizeOfInstance - InstOffset))); + +#undef _sp +} + + +bool CShapeUtils::isPointInCoregionArea(const MscPoint& point, Visio::IVShapePtr instShape) +{ + double coregBegX, coregEndX, coregBegY, coregEndY; + + std::vector<Visio::IVShapePtr> cor = CShapeUtils::getConnectedShapes(instShape, ST_BMSC_COREGION); + for(u_int i=0; i<cor.size(); i++) + { + Visio::IVShapePtr coregShape = cor.at(i); + + double dif = CShapeUtils::getCoregionHeight(coregShape); + coregBegX = CShapeUtils::getShapeCell(coregShape, "BeginX") - dif; + coregEndX = CShapeUtils::getShapeCell(coregShape, "EndX") + dif; + coregBegY = CShapeUtils::getShapeCell(coregShape, "BeginY"); + coregEndY = CShapeUtils::getShapeCell(coregShape, "EndY"); + + //check if MscPoint lies on one of the coregion's sides + bool x_coordinate = false, y_coordinate = false; + x_coordinate = point.get_x() > coregBegX && point.get_x() < coregEndX; + y_coordinate = point.get_y() < coregBegY && point.get_y() > coregEndY; + + if(x_coordinate && y_coordinate) + return true; + } + return false; +} + +bool CShapeUtils::unglueShape(Visio::IVShapePtr fromShape, const _bstr_t & fromCell, Visio::IVShapePtr toShape) +{ + Visio::IVCellPtr thisCell = fromShape->GetCells(fromCell); + Visio::IVConnectsPtr toSheets = fromShape->Connects; + Visio::IVCellPtr conPointCell, m_fromCell; + + bool isBegin = _tcsicmp(fromCell,_T("BeginX")) == 0; + int row_index = 0; + for(int i=1; i <= toSheets->Count; i++) + { + m_fromCell = toSheets->Item[i]->FromCell; + conPointCell = toSheets->Item[i]->ToCell; + row_index = conPointCell->Row; + //check if it is the correct connection point + if(m_fromCell->Result[0] == thisCell->Result[0]) + { + conPointCell->GetShape()->DeleteRow(visSectionConnectionPts, row_index); + fromShape->GetCells(isBegin ? "BegTrigger" : "EndTrigger")->Result[0] = 1; + return true; + } + } + return false; +} + bool CShapeComparator::operator()(const Visio::IVShapePtr shapeOne, const Visio::IVShapePtr shapeTwo) { if (direction == ORDER_ASC) Modified: trunk/src/view/visio/addon/shapeutils.h =================================================================== --- trunk/src/view/visio/addon/shapeutils.h 2013-07-13 13:40:24 UTC (rev 1849) +++ trunk/src/view/visio/addon/shapeutils.h 2013-07-17 15:45:38 UTC (rev 1850) @@ -68,7 +68,29 @@ static double getCoregionHeight(Visio::IVShapePtr coregion, VisUnitCodes units = visPageUnits); static void setCoregionWidth(Visio::IVShapePtr coregion, double newWidth, VisUnitCodes units = visPageUnits); + /** + * Check all coregions on instance, if it contains MSCpint + */ + static bool isPointInCoregionArea(const MscPoint& point, Visio::IVShapePtr instShape); + + /** + * + */ + static bool isPointOnInstancesLine(const MscPoint& point, Visio::IVShapePtr instShape,VisUnitCodes units = visPageUnits); + + /* + * Check all coregions boundaries in instance, if it contains MSCpoint + */ + static bool isPointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape); + + /* + * Check all coregions boundaries in instance, if it contains MSCpoint + * The related Coregion is returned as argument + */ + static CoregionSides wherePointOnCoregion(const MscPoint& point, Visio::IVShapePtr instShape, Visio::IVShapePtr& coregShape); + + /** * Get shapes connected to another shape * @param shape shape the other shapes are connected to * @param connectedShapeType filter for connected shapes (e.g. coregions, messages, etc.) @@ -78,6 +100,12 @@ * Returns the direction of given message */ static MsgDirection getMsgDirection(Visio::IVShapePtr msgShape); + + /* + * Remove connection point, to which the given cell is attached and so unglue the shape + */ + static bool unglueShape(Visio::IVShapePtr fromShape, const _bstr_t & fromCell, Visio::IVShapePtr toShape); + }; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |