From: Matthew G. <mat...@us...> - 2007-03-03 13:08:16
|
Update of /cvsroot/jsbsimcommander/src/gui In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv22204/src/gui Modified Files: shape.cpp shape.h Log Message: Now we can insert a single shape into tow connected shapes. Correct the function ComponentShape::GetOutputName. Index: shape.cpp =================================================================== RCS file: /cvsroot/jsbsimcommander/src/gui/shape.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** shape.cpp 2 Mar 2007 03:26:59 -0000 1.12 --- shape.cpp 3 Mar 2007 13:08:12 -0000 1.13 *************** *** 296,300 **** wxNode * last = first; first = first->GetNext(); ! unsigned int i=1; while (first) { --- 296,300 ---- wxNode * last = first; first = first->GetNext(); ! unsigned int i=0; while (first) { *************** *** 320,334 **** { //TODO now we can insert the ComponentShape into the two MISOShape. - std::cout << "MyEvtHandler::OnEndDragLeft for ComponentShape without lines and find the line" << std::endl; - MISOShape * from = wxDynamicCast(current->GetFrom(), MISOShape); - if (from) { ! std::cout << "From:" << from->GetName() << ", Type:" << from->GetType() << endl; } ! MISOShape * to = wxDynamicCast(current->GetTo(), MISOShape); ! if (to) { ! std::cout << "To:" << to->GetName() << ", Type:" << to->GetType() << endl; } break; } --- 320,409 ---- { //TODO now we can insert the ComponentShape into the two MISOShape. { ! std::cout << "MyEvtHandler::OnEndDragLeft for ComponentShape without lines and find the line" << std::endl; ! MISOShape * from = wxDynamicCast(current->GetFrom(), MISOShape); ! if (from) ! { ! std::cout << "From:" << from->GetName() << ", Type:" << from->GetType() << endl; ! } ! MISOShape * to = wxDynamicCast(current->GetTo(), MISOShape); ! if (to) ! { ! std::cout << "To:" << to->GetName() << ", Type:" << to->GetType() << endl; ! } } ! wxShape *from = current->GetFrom(); ! wxShape *to = current->GetTo(); ! int attachFrom = current->GetAttachmentFrom(); ! int attachTo = current->GetAttachmentTo(); ! from->RemoveLine(current); ! cshape->AddLine(current, to, 0, attachTo); ! ! wxNode * start = cp->Item(i); ! ! wxLineShape * theShape; ! theShape = new wxLineShape; ! theShape->AssignNewIds (); ! theShape->SetEventHandler(new MyEvtHandler(theShape, theShape)); ! theShape->SetPen (wxBLACK_PEN); ! theShape->SetBrush (wxRED_BRUSH); ! wxLineShape *lineShape = theShape; ! // Yes, you can have more than 2 control points, in which case ! // it becomes a multi-segment line. ! lineShape->MakeLineControlPoints (i+2); ! lineShape->AddArrow (ARROW_ARROW, ARROW_POSITION_END, 10.0, 0.0, ! _T ("Normal arrowhead")); ! diagram->AddShape (theShape); ! from->AddLine ((wxLineShape *) theShape, cshape, attachFrom, 1); ! first = cp->GetFirst(); ! for (int j=0; j<i+2; ++j) { ! *((wxRealPoint *) lineShape->GetLineControlPoints ()->Item (j)-> ! GetData ()) = *((wxRealPoint *) first->GetData()); ! first = first->GetNext(); } + cshape->GetAttachmentPosition(1, &(((wxRealPoint *) lineShape->GetLineControlPoints ()->GetLast()-> GetData ())->x), &(((wxRealPoint *) lineShape->GetLineControlPoints ()->GetLast()-> GetData ())->y)); + lineShape->Straighten(); + MISOShape::NormalizeLine(lineShape); + theShape->Show (true); + + wxRealPoint* startp = (wxRealPoint*)cp->Item(i)->GetData(); + cshape->GetAttachmentPosition (0, &(startp->x), &(startp->y)); + first = cp->GetFirst(); + while(first != start) + { + last = first; + first = first->GetNext(); + cp->DeleteNode(last); + } + current->Straighten(); + + { + ComponentShape * cfrom = wxDynamicCast(from, ComponentShape); + ComponentShape * cto = wxDynamicCast(to, ComponentShape); + if (cfrom) + { + long int f = cfrom->GetOrder(); + if (cto) + { + long int t = cto->GetOrder(); + cshape->SetOrder((t+f)/2, false); + } + else + { + cshape->SetOrder(f+10, false); + } + } + else + { + if (cto) + { + long int t = cto->GetOrder(); + cshape->SetOrder(t-10, false); + } + } + } + canvas->Refresh(); + canvas->Update(); break; } *************** *** 1098,1109 **** void ! ComponentShape::SetOrder(long int & o) { if ( order == o ) return; ! wxDiagram *diagram = GetCanvas()->GetDiagram (); ! wxObjectList::compatibility_iterator node = diagram->GetShapeList ()->GetFirst (); ! while (node) { wxShape *eachShape = (wxShape *) node->GetData (); --- 1173,1186 ---- void ! ComponentShape::SetOrder(const long int & o, bool exchange) { if ( order == o ) return; ! if (exchange) ! { ! wxDiagram *diagram = GetCanvas()->GetDiagram (); ! wxObjectList::compatibility_iterator node = diagram->GetShapeList ()->GetFirst (); ! while (node) { wxShape *eachShape = (wxShape *) node->GetData (); *************** *** 1119,1123 **** --- 1196,1202 ---- } node = node->GetNext (); + } + } order = o; } *************** *** 1320,1324 **** ComponentShape::GetOutputName() const { ! wxString rslt = wxT("NULL"); wxNode * node = GetLines().GetFirst(); while (node) --- 1399,1403 ---- ComponentShape::GetOutputName() const { ! wxString rslt = _("NULL"); wxNode * node = GetLines().GetFirst(); while (node) *************** *** 1342,1345 **** --- 1421,1432 ---- rslt = result->GetName(); } + else if (shape->IsKindOf(CLASSINFO(MISOShape))) + { + rslt = mkName(wxDynamicCast(shape, MISOShape)->GetName(), true); + } + else if (shape->IsKindOf(CLASSINFO(SIMOShape))) + { + rslt = _("Multiple Outputs"); + } break; //only one output } Index: shape.h =================================================================== RCS file: /cvsroot/jsbsimcommander/src/gui/shape.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** shape.h 2 Mar 2007 03:26:59 -0000 1.7 --- shape.h 3 Mar 2007 13:08:12 -0000 1.8 *************** *** 91,95 **** //called after addline or move to adjust the line(s) to the shape ! void NormalizeLine (wxLineShape * line); void NormalizeLines (); --- 91,95 ---- //called after addline or move to adjust the line(s) to the shape ! static void NormalizeLine (wxLineShape * line); void NormalizeLines (); *************** *** 308,312 **** //check and set void SetOrder(); ! void SetOrder(long int & o); }; --- 308,312 ---- //check and set void SetOrder(); ! void SetOrder(const long int & o, bool exchange= true); }; |