Author: derek Date: Sun Sep 24 19:05:05 2006 New Revision: 119 Added: sofaswitch/trunk/callflow/src/loadnewgraph.cpp sofaswitch/trunk/callflow/src/loadnewgraph.h sofaswitch/trunk/callflow/src/transfermedia.cpp sofaswitch/trunk/callflow/src/transfermedia.h Modified: sofaswitch/trunk/callflow/src/callflow.cpp sofaswitch/trunk/callflow/src/callflow.h sofaswitch/trunk/callflow/src/dnd.cpp sofaswitch/trunk/callflow/src/dnd.h Log: Work towards adding transfermedia, and load new graph options. Modified: sofaswitch/trunk/callflow/src/callflow.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.cpp (original) +++ sofaswitch/trunk/callflow/src/callflow.cpp Sun Sep 24 19:05:05 2006 @@ -41,7 +41,9 @@ #include "bitmaps/compile.xpm" #include "bitmaps/eventer.xpm" #include "bitmaps/miniclock.xpm" +#include "bitmaps/newgraph.xpm" #include "bitmaps/stoptimer.xpm" +#include "bitmaps/transfermedia.xpm" class MyFrame ; @@ -303,7 +305,8 @@ toolBar->AddTool(wxH_CONTROLSPYTHON, wxBitmap ( Python_xpm ), wxT("arbitrary python code")); toolBar->AddTool(wxH_CONTROLSCONNECT_OBJECTS, wxBitmap ( JoinObjects ), wxT("Join objects with multi segmented lines")); - + toolBar->AddTool(wxH_CONTROLSTRANSFERMEDIA, wxBitmap ( transfermedia ), wxT("transfer media between workers")); + toolBar->AddTool(wxH_CONTROLSNEWGRAPH, wxBitmap ( newgraph ), wxT("open existing graph file to handle new task")); toolBar->AddSeparator() ; toolBar->AddTool(wxH_HELPMANUAL, wxBitmap ( HelpManual_xpm ), wxT("help on using this program")); @@ -380,6 +383,18 @@ void MyFrame::OnControlspython (wxCommandEvent & WXUNUSED(event)) { imageTypeForPlacing = DndShape::Python; + canvas->SetEditingMode(MyCanvas::PlaceOneShape); +} + +void MyFrame::OnControlsTransferMedia (wxCommandEvent & WXUNUSED(event)) +{ + imageTypeForPlacing = DndShape::TransferMedia; + canvas->SetEditingMode(MyCanvas::PlaceOneShape); +} + +void MyFrame::OnControlsLoadNewGraph (wxCommandEvent & WXUNUSED(event)) +{ + imageTypeForPlacing = DndShape::LoadNewGraph; canvas->SetEditingMode(MyCanvas::PlaceOneShape); } Modified: sofaswitch/trunk/callflow/src/callflow.h ============================================================================== --- sofaswitch/trunk/callflow/src/callflow.h (original) +++ sofaswitch/trunk/callflow/src/callflow.h Sun Sep 24 19:05:05 2006 @@ -29,6 +29,8 @@ wxH_CONTROLSPYTHON, wxH_CONTROLSCONNECT_OBJECTS, wxH_CONTROLSCOMPILE, + wxH_CONTROLSTRANFERMEDIA, + wxH_CONTROLSNEWGRAPH, wxH_HELPMANUAL, wxH_HELPABOUT, wxH_EDITCUT, @@ -133,6 +135,18 @@ current graph. This starts a timer, which will generate an event of the specified name. */ void OnControlsTimer (wxCommandEvent & event); + + /**Called in response to a user comand to add a "transfer media from one + sofaswitch worker to another" widget to the current graph. This is + used, at call setup, to connect a voip node with a sound device.. */ + void OnControlsTransferz,edia(wxCommandEvent & event); + + /**Called in response to a user comand to add a "Load a New Graph" widget + to the current graph. The load new graph causes a new separate stream + of execution to start, where processing is happening at two places at + once. This is used to handle, say, incoming calls, or to make an + outgong call. */ + void OnControlsLoadNewGraph(wxCommandEvent & event); /**Called in response to a user comand to add a "Draw Line Segment" widget to the current graph. The multiple line segment object is used to join Modified: sofaswitch/trunk/callflow/src/dnd.cpp ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.cpp (original) +++ sofaswitch/trunk/callflow/src/dnd.cpp Sun Sep 24 19:05:05 2006 @@ -399,6 +399,12 @@ if (thisKind == Eventer) return DndShapeEventer::GetKindName(); + if (thisKind == TransferMedia) + return DndShapeTransferMedia::GetKindName(); + + if (thisKind == LoadNewGraph) + return DndShapeLoadNewGraph::GetKindName(); + wxString answer = wxString::Format("node kind is %d", thisKind); return answer; } Modified: sofaswitch/trunk/callflow/src/dnd.h ============================================================================== --- sofaswitch/trunk/callflow/src/dnd.h (original) +++ sofaswitch/trunk/callflow/src/dnd.h Sun Sep 24 19:05:05 2006 @@ -265,6 +265,8 @@ /**12*/ Timer /**Initiate a timer, which runs for some specified time interval */, /**13*/ StopTimer /**Stop a running timer, so it will not generate an event etc */, /**14*/ Eventer /**Mark me as registering for an event. Possibly, wait for the registered for event */, + /**15*/ TransferMedia /**Transfer media from one sofaswitch entity to another */, + /**16*/ LoadNewGraph /**Read in an existing graph file (pre compiled) for a new thread of exeuction */, /* 15*/ KnownShapes /**Indicates the number of known shapes we can manage */ }; Added: sofaswitch/trunk/callflow/src/loadnewgraph.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/loadnewgraph.cpp Sun Sep 24 19:05:05 2006 @@ -0,0 +1,104 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "python.h" + + +///////////////////////////////////////////////////////////////////////////// +DndShapePython::DndShapePython() + : DndShape(Python) +{ + wxSize newSize(50, 50); + SetSize(newSize); + + relInputPoints.Add(25, 0); + relOutputPoints.Add(25, 50); + + displayData[displayData.size()] = + InformationSection(wxT("Python Code"), wxT("self.i = 0")); + + AdjustIoPoints(); +} + +void DndShapePython::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); + + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 25, p1.y + 15); + wxPoint pB(p1.x + 25, p1.y + 0); + wxPoint pC(p1.x + 25, p1.y + 50); + + DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + dc.DrawLine(pC, pB); + + DrawBox(dc, 0, 10, 21, 21); + DrawBox(dc, 29, 10, 21, 21); + + wxString text("Pyt"); + dc.SetFont(*wxITALIC_FONT); + wxCoord w, h; + dc.GetTextExtent(text, &w, &h); + int xPos = m_rect.x + 0 + ((21 - w)/2); + int yPos = m_rect.y + 10 + ((21 - h)/2); + dc.DrawText(text, xPos, yPos); + + text = "hon"; + dc.GetTextExtent(text, &w, &h); + xPos = m_rect.x + 29 + ((21 - w)/2); + yPos = m_rect.y + 10 + ((21 - h)/2); + dc.DrawText(text, xPos, yPos); + + + DrawBox(dc, 0, 35, 13, 13); + DrawBox(dc, 37, 35, 13, 13); + + DndShape::Draw(dc); +} + +bool DndShapePython::WriteSystemCode(wxTextFile & file) +{ + file.AddLine(" def Python(self, sTuple): "); + file.AddLine(" a,b,c = sTuple"); + file.AddLine(" exec(self.data[a][\"Python Code\"])"); + file.AddLine(" return self.data[a][\"Output\"]"); + file.AddLine(""); + + return true; +} + +bool DndShapePython::WriteThisShapeInfo(wxTextFile & file) +{ + 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())); + + wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); + const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); + file.AddLine(wxString::Format(" \"Output\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); + + file.AddLine(wxString::Format(" \"Python Code\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + file.AddLine(wxString::Format(" },")); + + return true; +} Added: sofaswitch/trunk/callflow/src/loadnewgraph.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/loadnewgraph.h Sun Sep 24 19:05:05 2006 @@ -0,0 +1,35 @@ +#ifndef SHAPE_PYTHON_H + +#define SHAPE_PYTHON_H + +#include "dnd.h" + +////////////////////////////////////////////////////////////////////////// +/**Define a shape to indicate an arbitrary block of python code. + */ +class DndShapePython : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapePython(); + + /**Destroy this shape, and log it */ + virtual ~DndShapePython() + { + } + + /**Draw this particular shape to the screen..*/ + virtual void Draw(wxDC& dc); + + /** Used to report the name of this particular class. */ + static wxString GetKindName() { return wxString("Python"); } + + /**Write the code generic to this Python code shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + +#endif Added: sofaswitch/trunk/callflow/src/transfermedia.cpp ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/transfermedia.cpp Sun Sep 24 19:05:05 2006 @@ -0,0 +1,104 @@ +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop +#endif + + +#ifndef WX_PRECOMP +#include "wx/wx.h" +#endif +#include <wx/textfile.h> +#include <wx/tokenzr.h> +#include "shapelist.h" + + +#include "python.h" + + +///////////////////////////////////////////////////////////////////////////// +DndShapePython::DndShapePython() + : DndShape(Python) +{ + wxSize newSize(50, 50); + SetSize(newSize); + + relInputPoints.Add(25, 0); + relOutputPoints.Add(25, 50); + + displayData[displayData.size()] = + InformationSection(wxT("Python Code"), wxT("self.i = 0")); + + AdjustIoPoints(); +} + +void DndShapePython::Draw(wxDC& dc) +{ + DrawCompileError(dc); + dc.SetBrush(wxBrush(*wxBLACK, wxSOLID)); + + wxPoint p1(m_rect.GetPosition()); + wxPoint pA(p1.x + 25, p1.y + 15); + wxPoint pB(p1.x + 25, p1.y + 0); + wxPoint pC(p1.x + 25, p1.y + 50); + + DrawArrow(dc, pA, ArrowDown, InputPointConnected(0) ? Connected : Loose); + DrawArrow(dc, pC, ArrowDown, OutputPointConnected(0) ? Connected : Loose); + dc.DrawLine(pC, pB); + + DrawBox(dc, 0, 10, 21, 21); + DrawBox(dc, 29, 10, 21, 21); + + wxString text("Pyt"); + dc.SetFont(*wxITALIC_FONT); + wxCoord w, h; + dc.GetTextExtent(text, &w, &h); + int xPos = m_rect.x + 0 + ((21 - w)/2); + int yPos = m_rect.y + 10 + ((21 - h)/2); + dc.DrawText(text, xPos, yPos); + + text = "hon"; + dc.GetTextExtent(text, &w, &h); + xPos = m_rect.x + 29 + ((21 - w)/2); + yPos = m_rect.y + 10 + ((21 - h)/2); + dc.DrawText(text, xPos, yPos); + + + DrawBox(dc, 0, 35, 13, 13); + DrawBox(dc, 37, 35, 13, 13); + + DndShape::Draw(dc); +} + +bool DndShapePython::WriteSystemCode(wxTextFile & file) +{ + file.AddLine(" def Python(self, sTuple): "); + file.AddLine(" a,b,c = sTuple"); + file.AddLine(" exec(self.data[a][\"Python Code\"])"); + file.AddLine(" return self.data[a][\"Output\"]"); + file.AddLine(""); + + return true; +} + +bool DndShapePython::WriteThisShapeInfo(wxTextFile & file) +{ + 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())); + + wxNode *outputNode = (wxNode *)GetOutputPoints().GetFirst(); + const wxString & outputLabel = ((LabelledPoint *)outputNode->GetData())->GetFullLabel(); + file.AddLine(wxString::Format(" \"Output\" : ")); + file.AddLine(wxString::Format(" %s, ", outputLabel.c_str())); + + file.AddLine(wxString::Format(" \"Python Code\" : ")); + file.AddLine(wxString::Format(" \"%s\", ", displayData[1].data.c_str())); + + file.AddLine(wxString::Format(" },")); + + return true; +} Added: sofaswitch/trunk/callflow/src/transfermedia.h ============================================================================== --- (empty file) +++ sofaswitch/trunk/callflow/src/transfermedia.h Sun Sep 24 19:05:05 2006 @@ -0,0 +1,35 @@ +#ifndef SHAPE_PYTHON_H + +#define SHAPE_PYTHON_H + +#include "dnd.h" + +////////////////////////////////////////////////////////////////////////// +/**Define a shape to indicate an arbitrary block of python code. + */ +class DndShapePython : public DndShape +{ +public: + /**Construtor, Define this shape in terms of size and points etc */ + DndShapePython(); + + /**Destroy this shape, and log it */ + virtual ~DndShapePython() + { + } + + /**Draw this particular shape to the screen..*/ + virtual void Draw(wxDC& dc); + + /** Used to report the name of this particular class. */ + static wxString GetKindName() { return wxString("Python"); } + + /**Write the code generic to this Python code shape */ + virtual bool WriteSystemCode(wxTextFile & file); + + /**Write the dictionary containing relevant points for this shape */ + virtual bool WriteThisShapeInfo(wxTextFile & file); +}; + + +#endif