[commit] r85 - in sofaswitch/trunk/callflow: . src
Author: derek Date: Mon Sep 11 00:20:15 2006 New Revision: 85 Removed: sofaswitch/trunk/callflow/example_correct.py Modified: sofaswitch/trunk/callflow/src/canvas.cpp sofaswitch/trunk/callflow/src/dnd.cpp sofaswitch/trunk/callflow/src/eventer.cpp sofaswitch/trunk/callflow/src/shapelist.cpp sofaswitch/trunk/callflow/src/timer.cpp Log: Fixes, updates, correctly processes Eventer node. Modified: sofaswitch/trunk/callflow/src/canvas.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/canvas.cpp (original) +++ sofaswitch/trunk/callflow/src/canvas.cpp Mon Sep 11 00:20:15 2006 @@ -63,50 +63,49 @@ // Called when window needs to be repainted. void MyCanvas::OnPaint(wxPaintEvent& event) { - activeShapes.ClearConnectionPoints(); - activeShapes.MarkConnectionPoints(); - - wxPaintDC dc(this); - PrepareDC(dc); - - // Find Out where the window is scrolled to - int vbX,vbY; // Top left corner of client - GetViewStart(&vbX,&vbY); - wxRegionIterator upd(GetUpdateRegion()); // get the update rect list - - wxRect nrect; - while (upd) - { - wxRect rect(upd.GetRect()); - wxPoint tl(rect.x, rect.y); - wxPoint ntl; - CalcUnscrolledPosition(tl.x, tl.y, &ntl.x, &ntl.y); - wxSize updateSize(upd.GetWidth(), upd.GetHeight()); - nrect= wxRect(ntl, updateSize); - - MyListShapes::iterator it = activeShapes.begin(); - while (it != activeShapes.end()) { - DndShape *oneShape = it->second; - if (oneShape != NULL) { - if (oneShape->Intersects(nrect)) - oneShape->Draw(dc); + activeShapes.ClearConnectionPoints(); + activeShapes.MarkConnectionPoints(); + + wxPaintDC dc(this); + PrepareDC(dc); + + // Find Out where the window is scrolled to + int vbX,vbY; // Top left corner of client + GetViewStart(&vbX,&vbY); + wxRegionIterator upd(GetUpdateRegion()); // get the update rect list + + wxRect nrect; + while (upd) { + wxRect rect(upd.GetRect()); + wxPoint tl(rect.x, rect.y); + wxPoint ntl; + CalcUnscrolledPosition(tl.x, tl.y, &ntl.x, &ntl.y); + wxSize updateSize(upd.GetWidth(), upd.GetHeight()); + nrect= wxRect(ntl, updateSize); + + MyListShapes::iterator it = activeShapes.begin(); + while (it != activeShapes.end()) { + DndShape *oneShape = it->second; + if (oneShape != NULL) { + if (oneShape->Intersects(nrect)) + oneShape->Draw(dc); + } + it++; + } + upd ++ ; + } + + if (selectingRegion.IsSelected()) { + selectingRegion.Draw(dc); + } + + if (GetEditingMode() == PlaceJoinBlocks) { + wxPoint last; + if (joinBlocks.GetLastPoint(last)) { + dc.DrawLine(last, lastMousePoint); + joinBlocks.Draw(dc); } - it++; - } - upd ++ ; - } - - if (selectingRegion.IsSelected()) { - selectingRegion.Draw(dc); - } - - if (GetEditingMode() == PlaceJoinBlocks) { - wxPoint last; - if (joinBlocks.GetLastPoint(last)) { - dc.DrawLine(last, lastMousePoint); - joinBlocks.Draw(dc); } - } } wxPoint MyCanvas::GetUnscrolledPosition(wxMouseEvent & event) @@ -157,10 +156,12 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { DndShape *oneShape = it->second; - if (oneShape->Intersects(pt)) { - oneShape->SetSelected(); - Refresh(); - return; + if (oneShape != NULL) { + if (oneShape->Intersects(pt)) { + oneShape->SetSelected(); + Refresh(); + return; + } } it++; } @@ -242,9 +243,11 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { DndShape *oneShape = it->second; - if (oneShape->IsSelected()) { - oneShape->AdjustPosition(delta); - } + if (oneShape != NULL) { + if (oneShape->IsSelected()) { + oneShape->AdjustPosition(delta); + } + } it++; } @@ -264,14 +267,16 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { DndShape *oneShape = it->second; - bool isSelected = oneShape->Intersects(selectingRegion.GetRect()); - oneShape->SetSelected(isSelected); + if (oneShape != NULL) { + bool isSelected = oneShape->Intersects(selectingRegion.GetRect()); + oneShape->SetSelected(isSelected); + } it++; - } - Refresh(); - return; + } + Refresh(); + return; } - + // printf("On mouse move at %d, %d %s\n", // event.GetX(), event.GetY(), // (event.LeftIsDown() ? "is down" : "is up")); @@ -325,8 +330,10 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { DndShape *oneShape = it->second; - if (oneShape->Intersects(pt)) - oneShape->ProcessRightMouseButton(pFrame); + if (oneShape != NULL) { + if (oneShape->Intersects(pt)) + oneShape->ProcessRightMouseButton(pFrame); + } it++; } } @@ -338,8 +345,10 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { DndShape *oneShape = it->second; - if (oneShape->IsSelected()) - toCopy += oneShape->GetShapeInfo(); + if (oneShape != NULL) { + if (oneShape->IsSelected()) + toCopy += oneShape->GetShapeInfo(); + } it++; } @@ -406,12 +415,15 @@ MyListShapes::iterator it = activeShapes.begin(); while (it != activeShapes.end()) { - data += it->second->GetShapeInfo(); - it++; + DndShape *oneShape = it->second; + if (oneShape != NULL) { + data += oneShape->GetShapeInfo(); + } + it++; } - + wxTextFile file(fileName); - + if (!file.Exists()) file.Create(); file.Open(); Modified: sofaswitch/trunk/callflow/src/dnd.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.cpp (original) +++ sofaswitch/trunk/callflow/src/dnd.cpp Mon Sep 11 00:20:15 2006 @@ -218,6 +218,8 @@ while (node != NULL) { LabelledPoint *thisLabel = (LabelledPoint *)node->GetData(); + if (!thisLabel->LinksToShape()) + return false; if (!thisLabel->SetKindValue(activeShapes)) return false; node = node->GetNext(); @@ -465,7 +467,9 @@ { switch (shapeRequired) { - case None: return NULL; + case None: + printf("Construct a shape of null\n"); + return NULL; case StartHere: return new DndShapeStartHere(); case EndHere: return new DndShapeEndHere(); case StartFor: return new DndShapeStartFor(); Modified: sofaswitch/trunk/callflow/src/eventer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/eventer.cpp (original) +++ sofaswitch/trunk/callflow/src/eventer.cpp Mon Sep 11 00:20:15 2006 @@ -29,7 +29,7 @@ AdjustIoPoints(); displayData[displayData.size()] = - InformationSection(wxT("Event"), wxT("timer1")); + InformationSection(wxT("Event sought"), wxT("incoming")); } void DndShapeEventer::Draw(wxDC& dc) @@ -39,15 +39,26 @@ wxPoint p1(m_rect.GetPosition()); wxPoint pA(p1.x + 13, p1.y + 0); - wxPoint pB(p1.x + 13, p1.y + 15); + wxPoint pB(p1.x + 13, p1.y + 10); wxPoint pC(p1.x + 13, p1.y + 35); wxPoint pD(p1.x + 13, p1.y + 50); dc.DrawLine(pA, pB); dc.DrawLine(pC, pD); - DrawBox(dc, 0, 15, 30, 15); + DrawBox(dc, 0, 10, 30, 20); + wxPoint polygon[10]; + + for (int i = 0; i < 10; i++) { + int radius = (i % 2) == 0 ? 9 : 4; + double theta = (270 + (36 * i)) * M_PI * 2.0/360.0; + int xx = 3 + (int)(radius * cos(theta)); + int yy = 39 + (int)(radius * sin(theta)); + polygon[i] = wxPoint(xx, yy); + } + dc.DrawPolygon(10, polygon, m_rect.x, m_rect.y); + wxPoint pI(p1.x + 30, p1.y + 17); wxPoint pJ(p1.x + 35, p1.y + 22); wxPoint pK(p1.x + 30, p1.y + 27); @@ -82,29 +93,29 @@ bool DndShapeEventer::WriteThisShapeInfo(wxTextFile & file) { - file.AddLine(wxString::Format("\"%s\" : { ", GetKey().c_str())); + file.AddLine(wxString::Format(" \"%s\" : { ", GetKey().c_str())); wxNode *inputNode = (wxNode *)GetInputPoints().GetFirst(); const wxString & inputLabel = ((LabelledPoint *)inputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"Input\" : ")); - file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); + file.AddLine(wxString::Format(" \"Input\" : ")); + file.AddLine(wxString::Format(" %s, ", inputLabel.c_str())); wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"OutputFromEvent\" : ")); - file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); + file.AddLine(wxString::Format(" \"OutputFromEvent\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); outputNode = outputNode->GetNext(); const wxString & outputLabel2 = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); - file.AddLine(wxString::Format(" \"OutputKeepGoing\" : ")); - file.AddLine(wxString::Format(" %s, ", outputLabel2.c_str())); + file.AddLine(wxString::Format(" \"OutputKeepGoing\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel2.c_str())); - file.AddLine(wxString::Format(" \"Event\" : ")); - file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + file.AddLine(wxString::Format(" \"Event\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); - file.AddLine(wxString::Format(" },")); + file.AddLine(wxString::Format(" },")); return true; } Modified: sofaswitch/trunk/callflow/src/shapelist.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/shapelist.cpp (original) +++ sofaswitch/trunk/callflow/src/shapelist.cpp Mon Sep 11 00:20:15 2006 @@ -34,16 +34,17 @@ } } - void MyListShapesExtended::RemoveSelectedShapes() { MyListShapes::iterator it = begin(); while (it != end()) { MyListShapes::iterator it_del = it; it++; - - if (it_del->second->IsSelected()) { - delete it_del->second; + + if (it_del->second != NULL) { + if (it_del->second->IsSelected()) { + delete it_del->second; + } erase (it_del); } } @@ -65,7 +66,8 @@ { MyListShapes::iterator it = begin(); while (it != end()) { - it->second->SetSelected(false); + if (it->second != NULL) + it->second->SetSelected(false); it++; } } @@ -197,9 +199,11 @@ MyListShapes::iterator it = begin(); while (it != end()) { DndShape *thisShape = it->second; - bool writeOk = thisShape->WriteThisShapeInfo(graphFile); - if (!writeOk) - return false; + if (thisShape != NULL) { + bool writeOk = thisShape->WriteThisShapeInfo(graphFile); + if (!writeOk) + return false; + } it++; } graphFile.AddLine("}"); @@ -234,6 +238,7 @@ pointsLinked = pointsLinked && thisLinked; it++; } + if (!pointsLinked) return false; @@ -249,31 +254,17 @@ it++; } - /**third, go through and set the kind variable on all input&output points */ it = begin(); - pointsLinked = true; while (it != end()) { DndShape *thisShape = it->second; if (thisShape != NULL) { - - bool linksOk = - thisShape->GetOutputPoints().SetKindValue(*this) && - thisShape->GetInputPoints().SetKindValue(*this); - if (linksOk) { - it ++; - } else{ - printf("Failed in links on %s\n", thisShape->GetName().c_str()); - thisShape->SetCompileError("Not all output points are linked"); - it = end(); - pointsLinked = false; - } - } - } - if (!pointsLinked) - return false; + thisShape->GetOutputPoints().SetKindValue(*this); + thisShape->GetInputPoints().SetKindValue(*this); + } + it++; + } - /*** Completed all initialisation tasks. Now, we have enough information to write to disk @@ -283,95 +274,103 @@ file.Clear(); - file.AddLine("#!/usr/bin/python"); - file.AddLine(" "); - file.AddLine("import sys"); - file.AddLine("import os"); - file.AddLine("import time"); - file.AddLine("import socket"); - file.AddLine("import Queue"); - file.AddLine("import distutils"); - file.AddLine("import thread"); - file.AddLine("from twisted.internet import reactor, protocol"); - file.AddLine(" "); + file.AddLine("#!/usr/bin/python "); + file.AddLine(" "); + file.AddLine("import sys "); + file.AddLine("import os "); + file.AddLine("import time "); + file.AddLine("import socket "); + file.AddLine("import Queue "); + file.AddLine("import distutils "); + file.AddLine("import thread "); + file.AddLine("from twisted.internet import reactor, protocol "); + file.AddLine(" "); - file.AddLine("class Controller(protocol.Protocol): "); - file.AddLine(" def __init__(self): "); - file.AddLine(" self.graphSet = False "); - file.AddLine(" self.connectionIsMade = False "); - file.AddLine(" self.endProgramNow = False "); + file.AddLine("class Controller(protocol.Protocol): "); + file.AddLine(" def __init__(self): "); + file.AddLine(" self.graphSet = False "); + file.AddLine(" self.connectionIsMade = False "); + file.AddLine(" self.endProgramNow = False "); char c= 34; wxString tString = wxString::Format(" self.quote = \"\\%c\"", c); file.AddLine(tString.c_str()); - file.AddLine(" "); - file.AddLine(" def setGraphData(self, graphFile): "); - file.AddLine(" self.gd=open(graphFile, \"r\"); "); - file.AddLine(" self.gdc=self.gd.read() "); - file.AddLine(" self.data = eval(self.gdc) "); - file.AddLine(" self.gd.close() "); - file.AddLine(" "); - file.AddLine(" self.firstNode = None "); - file.AddLine(" for k,v in self.data.iteritems(): "); - file.AddLine(" if k[:16] == \"Start_Processing\": "); - file.AddLine(" self.firstNode = k "); - file.AddLine(" print \"first node is \", k "); - file.AddLine(" break "); + file.AddLine(" "); + file.AddLine(" def setGraphData(self, graphFile): "); + file.AddLine(" self.gd=open(graphFile, \"r\"); "); + file.AddLine(" self.gdc=self.gd.read() "); + file.AddLine(" self.data = eval(self.gdc) "); + file.AddLine(" self.gd.close() "); + file.AddLine(" "); + file.AddLine(" self.firstNode = None "); + file.AddLine(" for k,v in self.data.iteritems(): "); + file.AddLine(" if k[:16] == \"Start_Processing\": "); + file.AddLine(" self.firstNode = k "); + file.AddLine(" print \"first node is \", k "); + file.AddLine(" break "); file.AddLine(" self.timeout = reactor.callLater(0, self.startTimerExpired, \"graph\")"); file.AddLine(" "); file.AddLine(" def startTimerExpired(self, data): "); file.AddLine(" if data == \"graph\": "); - file.AddLine(" self.connectionIsMade = True "); - file.AddLine(" if data == \"connected\": "); file.AddLine(" self.graphSet = True "); + file.AddLine(" if data == \"connected\": "); + file.AddLine(" self.connectionIsMade = True "); file.AddLine(" if self.graphSet and self.connectionIsMade:"); file.AddLine(" print \"start processing now \" "); file.AddLine(" "); file.AddLine(" def startWorkNow(): "); file.AddLine(" sTuple = \"(\" + self.quote + self.firstNode + self.quote + \", 0, \" +self.quote + \"Start_Processing\" + self.quote + \")\""); - file.AddLine(" self.DoWork(eval(sTuple))"); - file.AddLine(" "); - file.AddLine(" def DoWork(self, sTuple): "); - file.AddLine(" a,b,c = sTuple"); - file.AddLine(" "); - file.AddLine(" self.keepGoing = True "); - file.AddLine(" "); - file.AddLine(" while self.keepGoing:"); + file.AddLine(" self.DoWork(eval(sTuple)) "); + file.AddLine(" "); + file.AddLine(" def DoWork(self, sTuple): "); + file.AddLine(" a,b,c = sTuple "); + file.AddLine(" "); + file.AddLine(" self.keepGoing = True "); + file.AddLine(" "); + file.AddLine(" while self.keepGoing: "); file.AddLine(" command = \"self.\" + str(c) + \"(\" + str(sTuple) + \")\""); - file.AddLine(" a,b,c = sTuple = eval(command)"); - file.AddLine(" "); - file.AddLine(" def makeConnection(self, transport): "); - file.AddLine(" self.connected = 1 "); - file.AddLine(" self.transport = transport "); - file.AddLine(" self.connectionMade() "); - file.AddLine(" "); - file.AddLine(" def connectionMade(self): "); - file.AddLine(" self.myId = \"\" "); - file.AddLine(" self.countReceived = 0 "); - file.AddLine(" self.transport.write(\"?\\0\") "); - file.AddLine(" self.transport.write(\"whoami\\0\");"); - file.AddLine(" self.colonChar = \':\' "); - file.AddLine(" "); - file.AddLine(" def connectionLost(self, reason): "); - file.AddLine(" print \"connection lost\" "); - file.AddLine(" "); - file.AddLine(" def dataReceived(self, data): "); - file.AddLine(" ssdata = str(data).split(\'\\0\') "); - file.AddLine(" for oneMessage in ssdata: "); - file.AddLine(" self.countReceived = self.countReceived + 1"); - file.AddLine(" if self.countReceived == 1: "); - file.AddLine(" self.myId = oneMessage; "); + file.AddLine(" a,b,c = sTuple = eval(command) "); + file.AddLine(" "); + file.AddLine(" def makeConnection(self, transport): "); + file.AddLine(" self.connected = 1 "); + file.AddLine(" self.transport = transport "); + file.AddLine(" self.connectionMade() "); + file.AddLine(" "); + file.AddLine(" def connectionMade(self): "); + file.AddLine(" self.myId = \"\" "); + file.AddLine(" self.countReceived = 0 "); + file.AddLine(" self.transport.write(\"?\\0\") "); + file.AddLine(" self.transport.write(\"whoami\\0\"); "); + file.AddLine(" self.colonChar = \':\' "); + file.AddLine(" "); + file.AddLine(" def connectionLost(self, reason): "); + file.AddLine(" print \"connection lost\" "); + file.AddLine(" "); + file.AddLine(" def dataReceived(self, data): "); + file.AddLine(" ssdata = str(data).split(\'\\0\') "); + file.AddLine(" for oneMessage in ssdata: "); + file.AddLine(" self.countReceived += 1 "); + file.AddLine(" if self.countReceived == 1: "); + file.AddLine(" self.myId = oneMessage; "); file.AddLine(" self.timeout2 = reactor.callLater(0, self.startTimerExpired, \"connected\")"); - file.AddLine(" else: "); + file.AddLine(" else: "); file.AddLine(" self.processReceivedMessage(oneMessage)"); - file.AddLine(" "); + file.AddLine(" "); file.AddLine(" def replyNow(self, data):"); - file.AddLine(" self.transport.write(self.tstring) "); - file.AddLine(" "); - file.AddLine(" "); + file.AddLine(" self.transport.write(self.tstring) "); + file.AddLine(" "); + file.AddLine(" def processReceivedMessage(self, thisMessage): "); + file.AddLine(" print \"Received \", thisMessage "); + file.AddLine(" "); + file.AddLine(" "); - for (int i = 0; i < DndShape::KnownShapes; i++) { - DndShape *thisShape = DndShape::Construct((DndShape::Kind)i); + for (int i = 0; i < DndShape::KnownShapes; i++) { + DndShape *thisShape; + if (i == DndShape::None) + thisShape = NULL; + else + thisShape = DndShape::Construct((DndShape::Kind)i); + if (thisShape == NULL) continue; bool writeOk = thisShape->WriteSystemCode(file); @@ -381,9 +380,6 @@ } file.AddLine(" "); - file.AddLine(" def processReceivedMessage(self, thisMessage): "); - file.AddLine(" print \"Received \", thisMessage "); - file.AddLine(" "); file.AddLine("class MyFactory(protocol.ClientFactory): "); file.AddLine(" protocol = Controller "); file.AddLine(" "); Modified: sofaswitch/trunk/callflow/src/timer.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/timer.cpp (original) +++ sofaswitch/trunk/callflow/src/timer.cpp Mon Sep 11 00:20:15 2006 @@ -47,7 +47,6 @@ { DrawCompileError(dc); - wxPoint p1(m_rect.GetPosition()); wxPoint pA(p1.x + 25, p1.y + 0); wxPoint pE(p1.x + 25, p1.y + 10);
participants (1)
-
SofaSWITCH SVN