width=800;
}
function init() {
$this->graph = new stdClass();
$this->graph->htmlID = 'graph_proces_id_' . $id_proces;
$this->graph->procesTreeFlat = array();
$this->graph->procesTreeGoto = array();
$this->graph->treeItems = array();
$this->graph->elements = new stdClass();
$this->graph->elements->nodes = array();
$this->graph->elements->edges = array();
}
function set_mysql_zas_id($mysql_zas_id) {
$this->mysql_zas_id=$mysql_zas_id;
}
function set_gis_zas_id($gis_zas_id) {
$this->gis_zas_id=$gis_zas_id;
$this->gdb=DB::getDB($this->gis_zas_id);
}
function get_opt_objects($src_table,$src_index,$src_name,$map_table_id,$map_table_name,$parent_table_id,$parent_table,$limit=null,$ids_ok) {
$sql='select \''.$src_table.'\' as src_table , "'.$src_index.'" as src_index ';
if(!empty($src_name)) $sql.=', "'.$src_name.'" as src_name ';
$sql.=', "'.$parent_table_id.'" as parent_table_id , \''.$parent_table.'\' as parent_table from "'.$src_table.'" '.$limit.' ;';
$res=$this->gdb->query($sql);
while($h=$this->gdb->fetch($res)) {
if(!empty($limit)) {
//bierzemy wszystkie rekordy bo byl limit
$arr[]=$h;
$this->tables->$src_table->src_index[]=$h->src_index;
$this->tables->$src_table->data[$h->src_index]=$h;
} else {
//tylko te rekordy dla ktorych byly powiazania
if(in_array($h->parent_table_id, $this->tables->$parent_table->src_index)) {
$this->tables->$src_table->src_index[]=$h->src_index;
// echo " id ".$h->parent_table_id." IS found in ".$parent_table." parent table";
$arr[]=$h;
$this->tables->$src_table->data[$h->src_index]=$h;
// $this->tables->$src_table->childs[$h->src_index]=array();
if(!in_array($h->src_index, $this->tables->$parent_table->childs[$h->parent_table_id]->tables[$src_table])) {
$this->tables->$parent_table->childs[$h->parent_table_id]->tables[$src_table][]=$h->src_index;
$this->tables->$parent_table->childs[$h->parent_table_id]->objects[]=$src_table."_".$h->src_index;
$this->tables->$parent_table->child_recurs[$h->parent_table_id]->tables[$src_table][]=$h->src_index;
// echo " Table to ".$src_table." a parent to ".$parent_table;
}
} //else echo " id ".$h->parent_table_id." not found in ".$parent_table." parent table";
}
}
return $arr;
}
function get_opt_objects_parent($src_table,$src_index,$src_name,$map_table_id,$map_table_name,$parent_table_id,$parent_table,$limit=null,$child_table,$child_joinfield,$child_index){
$i=0;
$where_in=implode(",", $this->tables->$child_table->src_index);
$sql='select \''.$src_table.'\' as src_table , t1."'.$src_index.'" as src_index ';
if(!empty($src_name)) $sql.=', t1."'.$src_name.'" as src_name ';
$sql.=', t1."'.$parent_table_id.'" as parent_table_id , \''.$parent_table.'\' as parent_table from "'.$src_table.'" as t1
inner join "'.$child_table.'" as t2 on t1."'.$src_index.'"=t2."'.$child_joinfield.'"
where t2."'.$child_index.'" in ('.$where_in.') ;';
// echo " sql: ".$sql;
$res=$this->gdb->query($sql);
while($h=$this->gdb->fetch($res)) {
$i++;
// if($i>5) continue;
if(!in_array($h->src_index, $this->tables->$src_table->src_index)) {
$this->tables->$src_table->src_index[]=$h->src_index;
$this->tables->$src_table->data[$h->src_index]=$h;
$arr[]=$h;
}
if($h->parent_table_id)
if(!in_array($h->src_index, $this->tables->$parent_table->childs[$h->parent_table_id]->tables[$src_table])) {
$this->tables->$parent_table->childs[$h->parent_table_id]->tables[$src_table][]=$h->src_index;
$this->tables->$parent_table->childs[$h->parent_table_id]->objects[]=$src_table."_".$h->src_index;
}
// echo " (".$src_table.") child_joinfield is ".$child_joinfield." from ".$parent_table." val is ".$h->parent_table_id;
}
return $arr;
}
function set_layer_deepth($src_table,$deepth) {
$this->tables->$src_table->deepth=$deepth;
}
function get_layer_deepth($src_table) {
return $this->tables->$src_table->deepth;
}
function invert_layer_deepth() {
$deepth=0;
foreach($this->tables as $src_table=>$obj_data) {
if($obj_data->deepth>$deepth) $deepth=$obj_data->deepth;
}
foreach($this->tables as $src_table=>$obj_data) {
$this->tables->$src_table->deepth=$deepth-$this->tables->$src_table->deepth;
//echo " 182 Deepht".$deepth." w ".$src_table;
}
}
//rekursywne nadanie wszystkim obiektom powiazan/sciezek, aby mozna bylo je przesortowac i poukladac po kolei - aby obiekty root znaly swoje powiazania
function find_connect_paths($src_table,$deepth=0) {
self::set_layer_deepth($src_table,$deepth);
$deepth++;
//najpierw zjezdzamy w dol po dzieciach dajac znac na sam dol o ID nadrzenego
//echo "
odpalam funkcje path dla ".$src_table;
//for($i = 1; $i <= 10; $i++) {
foreach($this->tables->$src_table->childs as $id_parent=>$child) {
// echo " Szumam dzieci..";
foreach($child->tables as $table=>$child_) {
foreach($child_ as $id ) {
// echo " Wpisalem do dziecka ".$table." , ze parent is ".$id_parent." /".$child_;echo " = ".$id;
$this->tables->$table->parents->$src_table->tables[$id][]=$id_parent;
if(!in_array($table, $tables_to_connect)) $tables_to_connect[]=$table;
}
}
foreach($this->tables->$src_table->parents as $parent_table=>$parent_data) {
//echo " 140: parent_table= ".$parent_table;
foreach($parent_data->tables as $src_id=>$parents) {
// echo " 142: (".$src_id.")";
foreach($parents as $dst_id) {
foreach($this->tables->$src_table->childs[$src_id]->tables as $child_table=>$child_id_arr) {
foreach($child_id_arr as $child_id) {
// if(!in_array($dst_id, $this->tables->$child_table->parents->$parent_table->tables[$child_id])) $this->tables->$child_table->parents->$parent_table->tables[$child_id][]=$dst_id;
self::notify_child_node_about_parents($child_table,$parent_table,$child_id,$dst_id);
self::add_link_from_recurse_struct($child_table,$parent_table,$child_id);
$this->tables->$parent_table->child_recurs[$dst_id]->tables[$child_table][$child_id]=1;
// $this->tables->$parent_table->size[$dst_id]->all++;
}
}
//$this->tables->$src_table->parents->$parent_table->tables[$id][]=$id_parent;
}
}
}
}
// }
//potem patrzymy czy wystepuje jakis obiekt naszego typu w dol, jezeli tak, to zapisujemy to , ze ma polaczenie przez obiekty podrzedne
foreach($tables_to_connect as $table) {
self::find_connect_paths($table,$deepth);
}
}
//funkcja informuje dzieci obiektu o tym, jakich ma rodzicow
function notify_child_node_about_parents($child_table,$parent_table,$child_id,$dst_id) {
if(!in_array($dst_id, $this->tables->$child_table->parents->$parent_table->tables[$child_id])) {
//DEBUG_S(-3,"Nadpisze parenta dla tabeli ".$parent_table."(".$dst_id.") w tabeli ".$src_table." child ".$child_table." = src ".$src_id." id parent ".$id_parent,null,__FILE__,__FUNCTION__,__LINE__);
$this->tables->$child_table->parents->$parent_table->tables[$child_id][]=$dst_id;
}
}
//funkcja informujaca, ze opt_wezly maja ze soba powiazania w links, na postawie tego, ze gdzies na dole wlokna ida poprzez strukture do tych wezlow
function add_link_from_recurse_struct($child_table,$parent_table,$child_id) {
if(count($this->tables->$child_table->parents->$parent_table->tables[$child_id])>1) {
DEBUG_S(3,'Moge powiazac tabele '.$parent_table.' na podstawie info z '.$child_table,$this->tables->$child_table->parents->$parent_table->tables[$child_id],__FILE__,__FUNCTION__,__LINE__);
$first=false;
foreach($this->tables->$child_table->parents->$parent_table->tables[$child_id] as $link) {
if(!$first) $first=$link;
else {
$this->tables->$parent_table->links->$first->$link=true;
$this->tables->$parent_table->links->$link->$first=true;
}
}
}
}
function set_layer_coords($src_table,$start_x,$start_y) {
$this->tables->$src_table->cursor->x=$start_x;
$this->tables->$src_table->cursor->y=$start_y;
}
function offset_layer_coords($src_table,$x,$y) {
$this->tables->$src_table->cursor->x+=$x;
$this->tables->$src_table->cursor->y+=$y;
}
function set_obj_coord_by_layer($src_table,$obj) {
$this->tables->$src_table->obj_cursor[$obj]->x=$this->tables->$src_table->cursor->x;
$this->tables->$src_table->obj_cursor[$obj]->y=$this->tables->$src_table->cursor->y;
}
function get_obj_cursor_layer($src_table,$obj,$xy) {
return $this->tables->$src_table->obj_cursor[$obj]->$xy;
}
function set_obj_size_width($src_table,$obj,$width) {
$this->tables->$src_table->obj_width[$obj]=$width+20;
}
function set_obj_min_y_size($src_table,$obj,$size) {
$this->tables->$src_table->min_y_size[$obj]=$size;
}
function set_obj_size_width_by_min_y_size($src_table,$obj) {
self::set_obj_size_width($src_table,$obj,$this->tables->$src_table->min_x_size[$obj]);
}
function set_obj_size_width_by_parent($parent_table,$parent_obj,$src_table,$obj,$opts) {
if(isset($opts['ratio']))
$this->tables->$src_table->obj_width[$obj]=$this->tables->$parent_table->obj_width[$parent_obj]*$opts['ratio'];
}
function get_obj_size_width($src_table,$obj) {
return $this->tables->$src_table->obj_width[$obj];
}
function set_obj_coords_by_parent($parent_table,$parent_obj,$src_table,$obj) {
echo "\n// set_obj_coords_by_parent (".$parent_table.",".$parent_obj.",".$src_table.",".$obj.") ";
$this->tables->$src_table->obj_cursor[$obj]->x=$this->tables->$parent_table->obj_cursor[$parent_obj]->x+10;
$this->tables->$src_table->obj_cursor[$obj]->y=$this->tables->$parent_table->obj_cursor[$parent_obj]->y+15;
echo " - i setted ".$this->tables->$parent_table->obj_cursor[$parent_obj]->x."/ ".$this->tables->$parent_table->obj_cursor[$parent_obj]->y;
}
function calculate_obj_size_by_child_recurs($src_table,$obj) {
$count=0;$width=0;
echo "\n//Licze size dla ".$src_table.' / '.$obj;
foreach($this->tables->$src_table->child_recurs[$obj]->tables as $child_table=>$child_table_arr) {
if(self::get_type_table($child_table)=='Connect') continue;
echo " - ".$child_table;
$count+=count($child_table_arr)*20;
if(strlen(self::get_obj_name($src_table,$obj)) > $width) $width=strlen(self::get_obj_name($src_table,$obj))*6; //TODO trzeba przesunac obiekt obok
}
$count_local=count($this->tables->$src_table->childs[$obj]->objects)*20;
if($width<100) $width=100;
if($count_local>$count) $count=$count_local;
$count=$count+15+self::get_layer_deepth($src_table)*20;
// $this->tables->$src_table->min_y_size[$obj]=$count;
self::set_obj_min_y_size($src_table,$obj,$count);
$this->tables->$src_table->min_x_size[$obj]=$width;
}
function get_obj_size_by_child_recurs($src_table,$obj) {
echo "\n // get_obj_size_by_child_recurs dla ".$src_table." wynosi ".$obj." = ".$this->tables->$src_table->min_y_size[$obj];
return $this->tables->$src_table->min_y_size[$obj];
}
function get_obj_name($src_table,$obj) {
return $this->tables->$src_table->data[$obj]->src_name;
}
//funkcja do zwracania pierwszego obiektu wg roznych kryteriow : najmniej_powiazan, powiazanie z poprzednim, etc...
function get_next_obj($src_table,$situation) {
echo "\n /* 313: Situation <-- for ".$src_table;
print_r($situation);
print_r($this->get_next_obj);
echo "*/\n";
$ret=self::get_next_obj_by_path($src_table);
if(!empty($ret)) { $this->get_next_obj->last_obj=$ret; return $ret; }
//die('327 Skonczyla sie nowa sciezka uzyc/przeliczyc!');
echo "\n //322 Skonczyla sie sciezka, nowa przeliczamy";
self::analyze_arrange_paths($src_table,self::get_next_obj_unlayed($src_table));
self::make_offset_layer_coords_by_fit_new_path($src_table);
$ret=self::get_next_obj_by_path($src_table);
if(!empty($ret)) {
$this->get_next_obj->last_obj=$ret;
if(!empty($ret)) return $ret;
}
if($situation->count>1) {
if($situation->min_links==0) $ret=$situation->min_links_id;
else if($situation->min_links==1) { echo "\n// 320:Sytuacja min_links==1";
//bierzemy pod uwage rozmieszczenie sciezek - sprobujemy analizowac tylko te, ktore sa wyswietlone
if(isset($this->get_next_obj->last_obj)) {
if(isset($this->get_next_obj->last_obj_count)) {
echo "\n //324::szukamy kogos, do kogo mamy podpiecie ";
$var=$this->get_next_obj->last_obj;
foreach(self::get_next_obj_unlayed($src_table) as $obj) {
if(isset($this->tables->$src_table->links->$obj->$var))
if(in_array($obj, $situation->min_links_id_arr))
$ret=$obj;
}
} else {
//poprzedni nie mial zadnego powiazania
$ret=$situation->min_links_id;
}
}
}
} else $ret=$situation->id;
$this->get_next_obj->last_obj=$ret;
if(!isset($ret)) $ret=$situation->id;
return $ret;
}
function analyze_arrange_paths($src_table,$unlayed) {
//do szukania najdluzszej sciezki
echo "\n /* 370 f.analyze_arrange_paths unlayed";
print_r($unlayed);
echo "*/";
$w = new Nodes_path_analys;
$sciezki=$w->trasuj_wezly($this->tables->$src_table->links,$unlayed);
$najdluzsza=$w->najdluzsza_sciezka();
$this->tables->$src_table->Nodes_path_analys->paths=$sciezki;
$this->tables->$src_table->Nodes_path_analys->longest=$najdluzsza;
//print_r($sciezki);
}
function make_offset_layer_coords_by_fit_new_path($src_table) {
//przyklad
//stara sceizka 41,23,24,31
//nowa sciezka 25,28,27,32,29,30
//wezel 25 ma powiazanie z 24, zatem sciezka nowa powinna wystartowac pod namalowanym wezlem 24
//offset_layer_coords(,,)
echo "\n /* 392: tables->".$src_table.">layed ";
print_r($this->tables->$src_table->layed);
//print_r($this->tables->$src_table->obj_cursor);
//szukam do ktorego moge sie przylozyc wezla na podstawie sciezki
$najdluzsza=$this->tables->$src_table->Nodes_path_analys->longest;
foreach($this->tables->$src_table->Nodes_path_analys->paths[$najdluzsza] as $wezel) {
// echo " 402: sprawdzam:".$wezel;
foreach($this->tables->$src_table->links->$wezel as $link=>$link_) {
// echo " sprawdzam:".$link;
if(isset($this->tables->$src_table->layed[$link])) {
echo "\n 403 znalazlem wezel do podl ".$link." TODO jest wiecej powiazan. Paper used=>y ".$this->paper_used->y; //TODO trzeba wiedziec jakie jest ulozenie max kursora etc...
$height=self::get_obj_size_by_child_recurs($src_table,$wezel);
echo "\n nowe dla(".$link.") xy:(".$this->tables->$src_table->layed[$link]->start_x."+100 y:".$this->tables->$src_table->layed[$link]->start_y."+".$this->tables->$src_table->layed[$link]->height." ";
$this->tables->$src_table->layed[$link]->start_y=+$height;
self::set_layer_coords($src_table,$this->tables->$src_table->layed[$link]->start_x+200+self::notify_lay_nextrow()*150,$this->paper_used->y+50);
//self::notify_layed_obj_xyh($src_table,$link,$this->tables->$src_table->layed[$link]->start_x+100,$this->tables->$src_table->layed[$link]->start_y+$this->tables->$src_table->layed[$link]->height+50);
print_r($this->tables->$src_table->layed);
echo "*/";
return ;
}
}
echo " 402:".$wezel;
}
echo "najdluzsza:".$najdluzsza." */";
}
function get_next_obj_by_path($src_table) {
//proba skorzystania z pierwszej sciezki
$longest=$this->tables->$src_table->Nodes_path_analys->longest;
foreach($this->tables->$src_table->Nodes_path_analys->paths[$longest] as $ret) {
foreach(self::get_next_obj_unlayed($src_table) as $obj) {
echo "\n //322: get_next_obj_unlayed testuje ".$obj." dla ".$src_table;
if($obj==$ret) {
echo "\n //327: zwracam ze sciezki ".$ret;
return $ret;
}
}
}
}
function analyze_arrange_situation($src_table) {
$var=$this->get_next_obj->last_obj;
if(isset($this->get_next_obj->last_obj)) {
if(isset($this->tables->$src_table->links->$var)) {
echo "\n // 354: analyze_arrange_situation dla ".$this->get_next_obj->last_obj." ";
$co=0;
foreach($this->tables->$src_table->links->$var as $cos=>$cos_) {
$co++;
}
$this->get_next_obj->last_obj_count=$co;
} else echo "\n //353: no exists links for ".$var;
}
$max_links=0;
foreach(self::get_next_obj_unlayed($src_table) as $obj) {
$cnt[]=$obj;
echo "\n //334: max_links=".$max_links." id ".$max_links_id." min is ".$min_links." id is ".$min_links_id." obj[".$obj."]";
$count=0;
if(isset($this->tables->$src_table->links->$obj)) {
foreach($this->tables->$src_table->links->$obj as $link) {
$count++;
}
}
echo "\n// 315:jeszcze nie pojawil sie ".$src_table." [".$obj."] count: ".$count;
if(isset($max_links)) {
if($count>$max_links) {
$max_links=$count;
$max_links_id=$obj;
unset($max_links_id_arr);
$max_links_id_arr[]=$obj;
} else if($count==$max_links) $max_links_id_arr[]=$obj;
}
if(isset($min_links)) {
if($count<$min_links) {
$min_links=$count;
$min_links_id=$obj;
unset($min_links_id_arr);
$min_links_id_arr[]=$obj;
} else if($count==$min_links) $min_links_id_arr[]=$obj;
}
if(!isset($min_links)) {
$min_links=$count;$min_links_id=$obj;$min_links_id_arr[]=$obj;
}
if(!isset($max_links)) {
$max_links=$count;$max_links_id=$obj;$max_links_id_arr[]=$obj;
}
}
$ret->min_links=$min_links;
$ret->max_links=$max_links;
$ret->min_links_id=$min_links_id;
$ret->max_links_id=$max_links_id;
$ret->max_links_id_arr=$max_links_id_arr;
$ret->min_links_id_arr=$min_links_id_arr;
$ret->count=count($cnt);
$ret->id=$cnt[0];
echo "\n/* Analiza wezlow do rozmieszczenia" ; print_r($ret); echo "*/\n";
return $ret;
}
function get_next_obj_unlayed($src_table) {
foreach($this->tables->$src_table->src_index as $obj) {
if(!self::check_if_obj_is_layed($src_table,$obj)) {
$ret[]=$obj;
}
}
return $ret;
}
function lay_object($src_table,$obj,$start_x,$start_y) {
$min_x=200;$min_y=0;
//wykryj jakie X/Y jest aktualne
//echo "\nvar ".$src_table."_".$obj." = new joint.shapes.basic.Rect({
$height=self::get_obj_size_by_child_recurs($src_table,$obj);
$width=self::get_obj_size_width($src_table,$obj);
echo "\nvar ".$src_table."_".$obj." = new joint.shapes.devs.".self::get_type_table($src_table)."({
position: { x: ".self::get_obj_cursor_layer($src_table,$obj,'x').", y: ".self::get_obj_cursor_layer($src_table,$obj,'y')." },
size: { width: ".$width.", height: ".$height." }
, attrs: {
text: { text: '".self::get_obj_name($src_table,$obj).$obj."', fill: 'black' , 'y-alignment': 'top', 'x-alignment': 'left' } ,
'inPorts circle': { fill: 'PaleGreen' }
} , label: { text: 'Dupa' }
".self::get_ports_for_obj($src_table,$obj)."
});\n";
self::notify_layed_object($src_table,$obj,self::get_obj_cursor_layer($src_table,$obj,'x'),self::get_obj_cursor_layer($src_table,$obj,'y'),$height,$width);
self::lay_object_child($src_table,$obj);
}
function check_if_obj_is_layed($src_table,$obj) {
return in_array($src_table."_".$obj, $this->cells);
}
function notify_layed_object($src_table,$obj,$start_x,$start_y,$height,$width) {
$this->cells[]=$src_table."_".$obj;
if(isset($this->paper_used)) {
if($this->paper_used->y<$start_y+$height) $this->paper_used->y=$start_y+$height;
} else $this->paper_used->y=$start_y+$height;
self::notify_layed_obj_xyh($src_table,$obj,$start_x,$start_y,$height);
}
function notify_lay_nextrow() {
if(isset($this->paper_used->rows)) $this->paper_used->rows++;
else $this->paper_used->rows=1;
return $this->paper_used->rows;
}
function notify_layed_obj_xyh($src_table,$obj,$start_x,$start_y,$height=null) {
$this->tables->$src_table->layed[$obj]->start_x=$start_x;
$this->tables->$src_table->layed[$obj]->start_y=$start_y;
if(isset($height)) $this->tables->$src_table->layed[$obj]->height=$height;
}
function lay_object_child($src_table,$obj) {
self::offset_layer_coords($src_table,5,0);
foreach($this->tables->$src_table->childs[$obj]->tables as $child_table=>$child_table_arr) {
foreach($child_table_arr as $child_id) {
if($this->tables->$child_table->set_type_table=='Atomic') {
self::calculate_obj_size_by_child_recurs($child_table,$child_id);
self::set_obj_coords_by_parent($src_table,$obj,$child_table,$child_id);
self::set_obj_size_width_by_parent($src_table,$obj,$child_table,$child_id,array('ratio'=>0.3) );
self::lay_object($child_table,$child_id);
} else if($this->tables->$child_table->set_type_table=='Ports') {
// echo "\n //282 Trafilem na Ports";
}
}
}
}
function get_ports_for_obj($src_table,$obj) {
//do wykrycia portow dla tabeli typu
echo "\n // 293 get_ports_for_obj".$src_table."/".$obj;
if(isset($this->tables->$src_table->childs[$obj]->tables)) {
foreach($this->tables->$src_table->childs[$obj]->tables as $child_tbl=>$child_id_arr) {
if(self::get_type_table($child_tbl)=='Ports') {
foreach($child_id_arr as $child_obj) {
$ret[]=$child_tbl."_".$child_obj;
$this->ports_obj[$child_tbl."_".$child_obj]=$src_table."_".$obj;
$this->ports_tables[$child_tbl]=1;
$this->ports_to_add_connect_link[]=array($child_tbl,$child_obj); //zapisanie do cache co ma sie wyzwolic potem
//self::add_connect_links($child_tbl,$child_obj);
}
}
}
}
if(!empty($ret)) {
$ret=",outPorts: ['".implode("','", $ret)."']";
return $ret;
}
}
function add_connect_links($src_table,$obj) {
echo "\n // 316 add_connect_links ".$src_table." / ".$obj;
foreach($this->ports_tables as $port_table=>$val) {
foreach($this->tables->$port_table->childs as $obj=>$val_) {
foreach($this->tables->$port_table->childs[$obj]->tables as $child_table=>$child_table_arr) {
foreach($child_table_arr as $child_obj) {
// echo " i znalzalem ".$child_table." ".$child_obj;
if(self::get_type_table($child_table)=='Connect') {
if(count($this->tables->$child_table->parents->$port_table->tables[$child_obj]==2)) {
// foreach($this->tables->$child_table->parents->$port_table->tables[$child_obj] as $link_id){
// echo " (324) dodatk.".$link_id." ".$port_table."_".$this->tables->$child_table->parents->$port_table->tables[$child_obj][0];
//jakia jest nazwa obiektu
if(!empty($this->tables->$child_table->parents->$port_table->tables[$child_obj][1]))
echo "\n connect(".$this->ports_obj[$port_table."_".$this->tables->$child_table->parents->$port_table->tables[$child_obj][0]].",'".$port_table."_".$this->tables->$child_table->parents->$port_table->tables[$child_obj][0]."',".$this->ports_obj[$port_table."_".$this->tables->$child_table->parents->$port_table->tables[$child_obj][1]].",'".$port_table."_".$this->tables->$child_table->parents->$port_table->tables[$child_obj][1]."'); ";
}
}
}
}
}
}
}
function joint_addCell_js() {
$cells=implode(').addCell(', $this->cells);
echo "\ngraph.addCell(".$cells.");\n";
}
function set_type_table($src_table,$type) {
$this->tables->$src_table->set_type_table=$type;
}
function get_type_table($src_table) {
return $this->tables->$src_table->set_type_table;
}
function DEBUG($src_table) {
DEBUG_S(-3,$src_table,$this->tables->$src_table,__FILE__,__FUNCTION__,__LINE__);
}
function DEBUG_ports_obj() {
DEBUG_S(-3,'DEBUG_ports_obj',$this->ports_obj,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'DEBUG_ports_tables',$this->ports_tables,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'ports_to_add_connect_link',$this->ports_to_add_connect_link,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'opt_przelacznice_mufy->links',$this->tables->opt_przelacznice_mufy->links,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'opt_lokalizacje->links',$this->tables->opt_lokalizacje->links,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'opt_przelacznice_mufy->Nodes_path_analys',$this->tables->opt_przelacznice_mufy->Nodes_path_analys,__FILE__,__FUNCTION__,__LINE__);
}
function to_html($src_table) {
// DEBUG_S(-3,'Graph obj',$this->graph,__FILE__,__FUNCTION__,__LINE__);
// DEBUG_S(-3,'tables',$this->tables,__FILE__,__FUNCTION__,__LINE__);
?>
}
}
function GIS_OPT_STRUCTURES2() {
global $db,$gdb;
$mysql_zas_id=36;
$gis_zas_id=13102;
$db = DB::getDB();
$gdb= DB::getDB($gis_zas_id);
DEBUG_S(-3,'db',$db);
DEBUG_S(-3,'gis',$gdb);
$cp=new GIS_OPT_STRUCTURES2;
$cp->init();
$cp->set_gis_zas_id($gis_zas_id);
//$wezly=$cp->get_opt_objects('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje',"where \"Nazwa\" like '%test%'");
$wezly=$cp->get_opt_objects('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje',"where \"id_0\" in(23,24,32,31,25,28,27,41) ");
$cp->set_type_table('opt_przelacznice_mufy','Coupled');
$tacki=$cp->get_opt_objects('opt_tacki','id_0',null,null,null,'id_przelac','opt_przelacznice_mufy');
$cp->set_type_table('opt_tacki','Atomic');
$spawy=$cp->get_opt_objects('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki');
$cp->set_type_table('opt_spawy','Ports');
$wlokna=$cp->get_opt_objects('opt_wlokna','id',null,null,null,'id_spaw_a','opt_spawy');
$cp->set_type_table('opt_wlokna','Connect');
$wlokna2=$cp->get_opt_objects('opt_wlokna','id',null,null,null,'id_spaw_b','opt_spawy');
$spawy_b=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_b','id'); //try to find splices which are in fibres as B
$spawy_b2=$cp->get_opt_objects_parent('opt_spawy','id_0',null,null,null,'id_tacka','opt_tacki','1=1','opt_wlokna','id_spaw_a','id'); //try to find splices which are in fibres as A
$tacki_b=$cp->get_opt_objects_parent('opt_tacki','id_0',null,null,null,'id_przelac','opt_przelacznice_mufy','1=1','opt_spawy','id_tacka','id_0'); //try to find splices which are in fibres as B
$wezly_b=$cp->get_opt_objects_parent('opt_przelacznice_mufy','id_0','Nazwa','id_wezel','Rozdzielcza_wezly','id_opt_lokalizacja','opt_lokalizacje','1=1','opt_tacki','id_przelac','id_0');
// $cp->layer_arrange(1,array('opt_przelacznice_mufy'));
/*
$cp->add_array_to_graph($wezly,'PROCES_INIT');
$cp->add_array_to_graph($tacki,null);
$cp->add_array_to_graph($spawy,null);
$cp->add_array_to_graph($wlokna,null);
$cp->add_array_to_graph($wlokna2,null);
$cp->add_array_to_graph($spawy_b,null);
$cp->add_array_to_graph($spawy_b2,null);
$cp->add_array_to_graph($tacki_b,null);
$cp->add_array_to_graph($wezly_b,'PROCES_INIT');
*/
$cp->find_connect_paths('opt_lokalizacje');
echo "
";
$cp->analyze_arrange_paths('opt_przelacznice_mufy'); //analizuje jakie sa sciezki glowne i ustalam dla nich rozmieszczenie
echo "
";
// $cp->find_connect_paths('opt_przelacznice_mufy');
$cp->invert_layer_deepth();
// $cp->arrange_objects_layer('opt_przelacznice_mufy');
DEBUG_S(-3,'Wezly do dodania',$wezly,__FILE__,__FUNCTION__,__LINE__);
DEBUG_S(-3,'tacki do dodania',$tacki,__FILE__,__FUNCTION__,__LINE__);
$cp->to_html('opt_przelacznice_mufy');
$cp->DEBUG('opt_lokalizacje');
$cp->DEBUG('opt_przelacznice_mufy'); $cp->DEBUG('opt_spawy');
$cp->DEBUG('opt_tacki');
$cp->DEBUG('opt_spawy');
$cp->DEBUG('opt_wlokna');
$cp->DEBUG_ports_obj();
// die();
// foreach($obj->INTERNAL_LINK as $link) graph__addNodeID($id, $graph,$tree->Viev_Zpc[$link]->DESC,null,$link,null);
// foreach($obj->EXTERNAL_LINK as $link) graph__addNodeID($link, $graph,$tree->Viev_Zpc[$link]->DESC,null,$id,'PROCES_INIT');
}
?>