Commit fc0de9ca authored by Claes Sjofors's avatar Claes Sjofors

Xtt tree window to view specific classes added

parent cba719f0
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef cow_tree_gtk_h
#define cow_tree_gtk_h
#include "cow_tree.h"
#include "cow_treenav.h"
#include "cow_wow_gtk.h"
/* cow_tree.h -- Tree viewer */
class CoWowRecall;
class CoWowEntryGtk;
class CowTreeNavGtk;
class CowTreeGtk : public CowTree {
public:
CowTreeGtk(
GtkWidget *a_parent_wid,
void *a_parent_ctx,
const char *title,
pwr_tAttrRef *itemlist,
int item_cnt,
unsigned int options,
pwr_tStatus (*get_object_info)( void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*get_node_info)( void *, char *, char *, int),
pwr_tStatus (*action)( void *, pwr_tAttrRef *));
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
GtkWidget *msg_label;
GtkWidget *button_ok;
GtkWidget *button_apply;
GtkWidget *button_cancel;
GtkWidget *pane;
void message( char severity, const char *message);
void pop();
static void activate_print( GtkWidget *w, gpointer data);
static void activate_close( GtkWidget *w, gpointer data);
static void activate_tree_layout( GtkWidget *w, gpointer data);
static void activate_list_layout( GtkWidget *w, gpointer data);
static void activate_zoom_in( GtkWidget *w, gpointer data);
static void activate_zoom_out( GtkWidget *w, gpointer data);
static void activate_zoom_reset( GtkWidget *w, gpointer data);
static void activate_help( GtkWidget *w, gpointer data);
static void activate_button_ok( GtkWidget *w, gpointer data);
static void activate_button_apply( GtkWidget *w, gpointer data);
static void activate_button_cancel( GtkWidget *w, gpointer data);
~CowTreeGtk();
};
#endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
/* cow_treenav.cpp -- Tree viewer */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "co_cdh.h"
#include "co_time.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "flow_browwidget_gtk.h"
#include "flow_msg.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "glow_growwidget_gtk.h"
#include "cow_tree_gtk.h"
#include "cow_treenav_gtk.h"
//
// Create the navigator widget
//
TreeNavGtk::TreeNavGtk(
void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
pwr_tAttrRef *xn_itemlist,
int xn_item_cnt,
unsigned int xn_options,
pwr_tStatus (*xn_get_object_info)(void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*xn_get_node_info)(void *, char *, char *, int),
GtkWidget **w,
pwr_tStatus *status) :
TreeNav( xn_parent_ctx, xn_itemlist, xn_item_cnt, xn_options, xn_get_object_info, xn_get_node_info, status),
parent_wid(xn_parent_wid)
{
form_widget = scrolledbrowwidgetgtk_new(
TreeNav::init_brow_cb, this, &brow_widget);
gtk_widget_show_all( brow_widget);
// Create the root item
*w = form_widget;
*status = 1;
}
//
// Delete a nav context
//
TreeNavGtk::~TreeNavGtk()
{
delete brow;
gtk_widget_destroy( form_widget);
}
void TreeNavGtk::set_inputfocus()
{
gtk_widget_grab_focus( brow_widget);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef cow_treenav_gtk_h
#define cow_treenav_gtk_h
/* cow_treenav_gtk.h -- Tree viewer */
#include <gtk/gtk.h>
#ifndef cow_treenav_h
# include "cow_treenav.h"
#endif
//! The navigation area of the attribute editor.
class TreeNavGtk : public TreeNav {
public:
TreeNavGtk(
void *xn_parent_ctx,
GtkWidget *xn_parent_wid,
pwr_tAttrRef *xn_itemlist,
int xn_item_cnt,
unsigned int xn_options,
pwr_tStatus (*xn_get_object_info)(void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*xn_get_node_info)(void *, char *, char *, int),
GtkWidget **w,
pwr_tStatus *status);
~TreeNavGtk();
GtkWidget *parent_wid;
GtkWidget *brow_widget;
GtkWidget *form_widget;
GtkWidget *toplevel;
void set_inputfocus();
};
#endif
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
/* xtt_tbl.cpp -- Display object attributes */
#include "glow_std.h"
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "co_cdh.h"
#include "co_time.h"
#include "cow_xhelp.h"
#include "co_dcli.h"
#include "cow_wow.h"
#include "co_cnf.h"
#include "flow.h"
#include "flow_browctx.h"
#include "flow_browapi.h"
#include "glow.h"
#include "glow_growctx.h"
#include "glow_growapi.h"
#include "flow_msg.h"
#include "glow_curvectx.h"
#include "cow_tree.h"
#include "cow_treenav.h"
CowTree::~CowTree()
{
}
CowTree::CowTree( void *xn_parent_ctx, pwr_tAttrRef *xn_itemlist, int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*xn_get_object_info_cb)( void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*xn_get_node_info_cb)( void *, char *, char *, int),
pwr_tStatus (*xn_action_cb)( void *, pwr_tAttrRef *)) :
parent_ctx(xn_parent_ctx), close_cb(0), wow(0)
{
get_object_info_cb = xn_get_object_info_cb;
get_node_info_cb = xn_get_node_info_cb;
action_cb = xn_action_cb;
}
void CowTree::message( void *cowtree, char severity, const char *message)
{
((CowTree *)cowtree)->message( severity, message);
}
void CowTree::activate_print()
{
pwr_tFileName filename;
pwr_tCmd cmd;
dcli_translate_filename( filename, "$pwrp_tmp/cow_tree.ps");
treenav->print( filename);
sprintf( cmd, "$pwr_exe/rt_print.sh %s", filename);
system(cmd);
}
void CowTree::activate_zoom_in()
{
double zoom_factor;
treenav->get_zoom( &zoom_factor);
if ( zoom_factor > 40)
return;
treenav->zoom( 1.18);
}
void CowTree::activate_zoom_out()
{
double zoom_factor;
treenav->get_zoom( &zoom_factor);
if ( zoom_factor < 15)
return;
treenav->zoom( 1.0 / 1.18);
}
void CowTree::activate_zoom_reset()
{
treenav->unzoom();
}
void CowTree::activate_help()
{
CoXHelp::dhelp("overview", "", navh_eHelpFile_Base, NULL, 0);
}
int CowTree::activate_button_ok()
{
TrItemBase *item;
pwr_tAttrRef aref;
pwr_tStatus sts;
if ( !treenav->get_select( &item)) {
message( 'E', "Select an object");
return 0;
}
switch ( item->type) {
case treenav_eItemType_Object:
case treenav_eItemType_TreeObject: {
TreeNav_object *hi = &((TrItemObject *)item)->item;
aref = hi->aref;
break;
}
default:
message( 'E', "Select an object");
return 0;
}
if ( action_cb)
sts = (action_cb)( parent_ctx, &aref);
return sts;
}
int CowTree::get_select_cb( void *ctx, pwr_tAttrRef *aref)
{
CowTree *cowtree = (CowTree *) ctx;
TrItemBase *item;
if ( !cowtree->treenav->get_select( &item)) {
cowtree->message( 'E', "Select an storage item");
return 0;
}
switch ( item->type) {
case treenav_eItemType_Object:
case treenav_eItemType_TreeObject: {
TreeNav_object *hi = &((TrItemObject *)item)->item;
*aref = hi->aref;
break;
}
default:
return 0;
}
return 1;
}
pwr_tStatus CowTree::get_object_info(void *ctx, pwr_tAttrRef *aref, char *name, int nsize, char *cname,
char *descr, int dsize)
{
CowTree *cowtree = (CowTree *)ctx;
return (cowtree->get_object_info_cb)( cowtree->parent_ctx, aref, name, nsize, cname, descr, dsize);
}
pwr_tStatus CowTree::get_node_info(void *ctx, char *name, char *descr, int dsize)
{
CowTree *cowtree = (CowTree *)ctx;
return (cowtree->get_node_info_cb)( cowtree->parent_ctx, name, descr, dsize);
}
pwr_tStatus CowTree::action(void *ctx, pwr_tAttrRef *aref)
{
CowTree *cowtree = (CowTree *)ctx;
return (cowtree->action_cb)( cowtree->parent_ctx, aref);
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef cow_tree_h
#define cow_tree_h
#ifndef pwr_privilege_h
#include "pwr_privilege.h"
#endif
#include "glow.h"
/* cow_tree.h -- Tree viewer */
typedef enum {
tree_mOptions_LayoutList = 1 << 0,
tree_mOptions_LayoutTree = 1 << 1,
tree_mOptions_AlphaOrder = 1 << 2
} tree_mOptions;
class TreeNav;
class CoWow;
class CowTree {
public:
CowTree( void *xn_parent_ctx, pwr_tAttrRef *xn_itemlist, int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*get_object_info)( void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*get_node_info)( void *, char *, char *, int),
pwr_tStatus (*action)( void *, pwr_tAttrRef *));
void *parent_ctx;
char name[80];
TreeNav *treenav;
void (*close_cb)( void *);
void (*object_info_cb)( void *, pwr_tAttrRef, char *, char *);
pwr_tStatus (*get_object_info_cb)( void *, pwr_tAttrRef *, char *, int, char *, char *, int);
pwr_tStatus (*get_node_info_cb)( void *, char *, char *, int);
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *);
CoWow *wow;
void activate_print();
void activate_zoom_in();
void activate_zoom_out();
void activate_zoom_reset();
void activate_help();
int activate_button_ok();
virtual void message( char sev, const char *text) {}
virtual void pop() {}
static void message( void *attr, char severity, const char *message);
static int cowtree_get_select_cb( void *ctx, pwr_tOid *oid, char *aname, char *oname);
static void cowtree_help_cb( void *ctx, const char *key);
static int get_select_cb( void *ctx, pwr_tAttrRef *aref);
static pwr_tStatus get_object_info(void *ctx, pwr_tAttrRef *aref, char *name, int nsize, char *cname,
char *descr, int dsize);
static pwr_tStatus get_node_info(void *ctx, char *name, char *descr, int dsize);
static pwr_tStatus action(void *ctx, pwr_tAttrRef *aref);
virtual ~CowTree();
};
#endif
This diff is collapsed.
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef cow_treenav_h
#define cow_treenav_h
/* cow_treenav.h -- Table Viewer */
#include <fstream>
#include <vector>
#ifndef pwr_h
# include "pwr.h"
#endif
#ifndef flow_h
#include "flow.h"
#endif
#ifndef flow_browctx_h
#include "flow_browapi.h"
#endif
#ifndef rt_qcom_h
#include "rt_qcom.h"
#endif
class TrItemBase;
typedef enum {
treenav_eItemType_Object,
treenav_eItemType_TreeObject,
treenav_eItemType_TreeNode,
} treenav_eItemType;
typedef enum {
treenav_mOpen_All = ~0,
treenav_mOpen_Children = 1 << 0
} treenav_mOpen;
class TreeNav_object {
public:
pwr_tAttrRef aref;
pwr_tAName name;
pwr_tObjName cname;
pwr_tString80 description;
TreeNav_object() {
memset( &aref, 0, sizeof(aref)); strcpy(name, ""); strcpy(cname, ""); strcpy(description, "");
}
TreeNav_object( const TreeNav_object& x) : aref(x.aref) {
strcpy( name, x.name);
strcpy( cname, x.cname);
strcpy( description, x.description);
}
};
typedef enum {
treenav_eTreeItemType_No,
treenav_eTreeItemType_Object,
treenav_eTreeItemType_ObjectAttr
} treenav_eTreeItemType;
class TreeNode {
public:
TreeNode() : fth(0), fch(0), fws(0), bws(0), type(treenav_eTreeItemType_No), idx(0), deleted(0)
{ strcpy( sname, ""); strcpy( descr, "");}
int fth;
int fch;
int fws;
int bws;
char sname[80];
pwr_tString80 descr;
treenav_eTreeItemType type;
int idx;
int deleted;
};
//! Class for handling of brow.
class TreeNavBrow {
public:
TreeNavBrow( BrowCtx *brow_ctx, void *xn) : ctx(brow_ctx), treenav(xn) {};
~TreeNavBrow();
BrowCtx *ctx;
void *treenav;
brow_tNodeClass nc_object;
brow_tNodeClass nc_node;
flow_sAnnotPixmap *pixmap_leaf;
flow_sAnnotPixmap *pixmap_map;
flow_sAnnotPixmap *pixmap_openmap;
void free_pixmaps();
void allocate_pixmaps();
void create_nodeclasses();
void brow_setup();
};
//! The navigation area of the attribute editor.
class TreeNav {
public:
TreeNav( void *xn_parent_ctx,
pwr_tAttrRef *xn_itemlist,
int xn_item_cnt,
unsigned int xn_options,
pwr_tStatus (*xn_get_object_info)(void *, pwr_tAttrRef *, char *, int, char *, char *, int),
pwr_tStatus (*xn_get_node_info)(void *, char *, char *, int),
pwr_tStatus *status);
virtual ~TreeNav();
void *parent_ctx;
TreeNavBrow *brow;
pwr_tAttrRef *itemlist;
vector<TreeNav_object> objectlist;
int item_cnt;
void (*message_cb)( void *, char, const char *);
vector<TreeNode> tree;
unsigned int options;
pwr_tStatus (*get_object_info)(void *, pwr_tAttrRef *, char *, int, char *, char *, int);
pwr_tStatus (*get_node_info)(void *, char *, char *, int);
void print( char *filename);
int create_items();
void build_tree();
void tree_add( char *name, int list_index, treenav_eTreeItemType type);
int get_select( TrItemBase **item);
int get_item( char *oname, TreeNav_object **hi);
void get_zoom( double *zoom_factor);
void zoom( double zoom_factor);
void unzoom();
void show_tree();
void show_list();
void delete_item( TreeNav_object *hi);
void create_objectlist( pwr_tAttrRef *xn_itemlist,
int xn_item_cnt,
pwr_tStatus *status);
void add_item_command( char *name, char *command);
int get_descr( char *name, int seg, int idx, char *descr);
virtual void message( char sev, const char *text);
virtual void set_inputfocus() {}
static int init_brow_cb( FlowCtx *fctx, void *client_data);
};
class TrItemBase {
public:
TrItemBase( treenav_eItemType t) : type(t) {}
virtual ~TrItemBase() {}
treenav_eItemType type;
virtual int close( TreeNav *treenav, double x, double y) {return 1;}
};
//! Item for an object in list layout.
class TrItemObject : public TrItemBase {
public:
TrItemObject( TreeNav *treenav, TreeNav_object *item, brow_tNode dest, flow_eDest dest_code);
virtual ~TrItemObject() {}
TreeNav_object item;
brow_tNode node;
int close( TreeNav *treenav, double x, double y);
};
//! Item for an object in tree layout.
class TrItemTreeObject : public TrItemObject {
public:
TrItemTreeObject( TreeNav *treenav, TreeNav_object *item, int index, brow_tNode dest, flow_eDest dest_code);
virtual ~TrItemTreeObject() {}
int idx;
};
//! Item for a tree node.
class TrItemNode : public TrItemBase {
public:
TrItemNode( TreeNav *treenav, char *name, char *descr, int index, brow_tNode dest, flow_eDest dest_code);
virtual ~TrItemNode() {}
brow_tNode node;
int idx;
int open_children( TreeNav *treenav, double x, double y);
int close( TreeNav *treenav, double x, double y);
};
#endif
......@@ -133,11 +133,13 @@ XttFastGtk::XttFastGtk( void *parent_ctx,
XttFastGtk::~XttFastGtk()
{
if ( timerid)
timerid->remove();
for ( int i = 0; i < fast_cnt; i++) {
gdh_UnrefObjectInfo( new_subid);
}
if ( curve)
delete curve;
if ( gcd)
delete gcd;
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "pwr.h"
#include "rt_gdh.h"
#include "xtt_otree_gtk.h"
#include "cow_tree_gtk.h"
/* xtt_otree_gtk.cpp -- Object tree viewer */
XttOTreeGtk::XttOTreeGtk( GtkWidget *parent_wid, void *xn_parent_ctx, const char *title, pwr_tAttrRef *xn_itemlist,
int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*xn_action_cb)( void *, pwr_tAttrRef *)) :
XttOTree( xn_parent_ctx, xn_itemlist, xn_item_cnt, xn_options, xn_action_cb)
{
cowtree = new CowTreeGtk( parent_wid, this, title, xn_itemlist, xn_item_cnt, xn_options, &get_object_info,
&get_node_info, &action);
cowtree->close_cb = close;
}
XttOTreeGtk::~XttOTreeGtk()
{
delete cowtree;
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef xtt_otree_gtk_h
#define xtt_otree_gtk_h
#include <gtk/gtk.h>
#ifndef xtt_otree_h
#include "xtt_otree.h"
#endif
/* xtt_otree.h -- Object tree viewer */
class XttOTreeGtk : public XttOTree {
public:
XttOTreeGtk( GtkWidget *parent_wid, void *xn_parent_ctx, const char *title, pwr_tAttrRef *xn_itemlist,
int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *));
virtual ~XttOTreeGtk();
};
#endif
......@@ -146,6 +146,8 @@ XttSevHistGtk::XttSevHistGtk( void *parent_ctx,
XttSevHistGtk::~XttSevHistGtk()
{
if ( otree)
delete otree;
if ( timerid)
timerid->remove();
if ( curve)
......@@ -156,6 +158,11 @@ XttSevHistGtk::~XttSevHistGtk()
delete wow;
}
XttOTree *XttSevHistGtk::tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *))
{
return new XttOTreeGtk( parent_widget, this, title, itemlist, itemcnt, layout, action_cb);
}
......
......@@ -42,6 +42,7 @@
#ifndef xtt_sevhist_h
# include "xtt_sevhist.h"
#endif
#include "xtt_otree_gtk.h"
class XttSevHistGtk : public XttSevHist {
public:
......@@ -71,6 +72,9 @@ class XttSevHistGtk : public XttSevHist {
void *basewidget,
int *sts);
~XttSevHistGtk();
XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *));
};
#endif
......
......@@ -59,6 +59,7 @@
#include "xtt_xnav.h"
#include "xtt_trend_gtk.h"
#include "ge_curve_gtk.h"
#include "xtt_otree_gtk.h"
XttTrendGtk::XttTrendGtk( void *parent_ctx,
GtkWidget *parent_wid,
......@@ -101,6 +102,7 @@ XttTrendGtk::XttTrendGtk( void *parent_ctx,
XttTrendGtk::~XttTrendGtk()
{
if ( timerid)
timerid->remove();
for ( int i = 0; i < trend_cnt; i++) {
......@@ -109,9 +111,17 @@ XttTrendGtk::~XttTrendGtk()
delete curve;
if ( gcd)
delete gcd;
if ( otree)
delete otree;
delete wow;
}
XttOTree *XttTrendGtk::tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *))
{
return new XttOTreeGtk( parent_widget, this, title, itemlist, itemcnt, layout, action_cb);
}
......
......@@ -59,6 +59,8 @@ class XttTrendGtk : public XttTrend {
int x_color_theme,
void *basewidget,
int *sts);
XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *));
~XttTrendGtk();
};
......
......@@ -91,6 +91,7 @@ typedef void *Widget;
#include "ge_curve_gtk.h"
#include "xtt_fileview_gtk.h"
#include "xtt_keyboard_gtk.h"
#include "xtt_otree_gtk.h"
#define max(Dragon,Eagle) ((Dragon) > (Eagle) ? (Dragon) : (Eagle))
#define min(Dragon,Eagle) ((Dragon) < (Eagle) ? (Dragon) : (Eagle))
......@@ -328,6 +329,12 @@ CLog *XNavGtk::clog_new( const char *name, pwr_tStatus *sts)
return new CLogGtk( this, parent_wid, name, sts);
}
XttOTree *XNavGtk::tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int options,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *))
{
return new XttOTreeGtk( parent_wid, this, title, itemlist, itemcnt, options, action_cb);
}
XttGe *XNavGtk::xnav_ge_new( const char *name, const char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
double scan_time, const char *object_name,
......
......@@ -121,6 +121,8 @@ class XNavGtk : public XNav {
pwr_tStatus *status);
XttKeyboard *keyboard_new( const char *name, keyboard_eKeymap keymap, keyboard_eType type,
int color_theme, pwr_tStatus *status);
XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int options,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *));
void bell( int time);
void get_popup_menu( pwr_sAttrRef attrref,
xmenu_eItemType item_type,
......
......@@ -69,7 +69,7 @@ XttFast::XttFast( void *parent_ctx,
pwr_sAttrRef *fast_arp,
int xn_color_theme,
int *sts) :
xnav(parent_ctx), fast_cnt(0), timerid(0), close_cb(0), help_cb(0), first_scan(1),
xnav(parent_ctx), fast_cnt(0), gcd(0), curve(0), timerid(0), close_cb(0), help_cb(0), first_scan(1),
axis_configured(false), color_theme(xn_color_theme)
{
pwr_sAttrRef aref = pwr_cNAttrRef;
......
......@@ -181,7 +181,7 @@ void Op::activate_blocklist()
void Op::activate_trend()
{
char cmd[200] = "show objectlist/class=dstrend,dstrendcurve/title=\"Trend List\"/sort";
char cmd[200] = "show objecttree/class=dstrend,dstrendcurve/title=\"Trend List\"/alpha/global";
if ( command_cb)
command_cb( parent_ctx, cmd);
......@@ -189,7 +189,7 @@ void Op::activate_trend()
void Op::activate_fast()
{
char cmd[200] = "show objectlist/class=dsfastcurve/title=\"Fast Curve List\"";
char cmd[200] = "show objecttree/class=dsfastcurve/title=\"Fast Curve List\"/alpha/global";
if ( command_cb)
command_cb( parent_ctx, cmd);
......@@ -197,14 +197,14 @@ void Op::activate_fast()
void Op::activate_history()
{
char cmd[200] = "show objectlist/class=sevhist,sevhistobject/title=\"Process History List\"/sort";
char cmd[200] = "show objecttree/class=sevhist,sevhistobject/title=\"Process History List\"/alpha/global";
if ( command_cb)
command_cb( parent_ctx, cmd);
}
void Op::activate_graph()
{
char cmd[200] = "show objectlist/class=xttgraph/title=\"Process Graphic List\"";
char cmd[200] = "show objecttree/class=xttgraph/title=\"Process Graphic List\"";
if ( command_cb)
command_cb( parent_ctx, cmd);
......
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#include "pwr.h"
#include "rt_gdh.h"
#include "co_cdh.h"
#include "xtt_otree.h"
/* xtt_otree.h -- Object tree viewer */
XttOTree::XttOTree( void *xn_parent_ctx, pwr_tAttrRef *xn_itemlist, int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*xn_action_cb)( void *, pwr_tAttrRef *)) :
parent_ctx(xn_parent_ctx), close_cb(0)
{
action_cb = xn_action_cb;
// cowtree = new CowTree( this, xn_itemlist, xn_item_cnt, xn_layout, get_object_info, get_node_info);
}
void XttOTree::pop()
{
cowtree->pop();
}
pwr_tStatus XttOTree::get_object_info( void *ctx, pwr_tAttrRef *aref, char *name, int nsize, char *cname,
char *descr, int dsize)
{
pwr_tStatus sts;
pwr_tAttrRef daref;
pwr_tCid cid;
sts = gdh_AttrrefToName( aref, name, nsize, cdh_mNName);
if ( EVEN(sts)) return sts;
sts = gdh_GetAttrRefTid( aref, &cid);
if ( EVEN(sts)) return sts;
sts = gdh_ObjidToName( cdh_ClassIdToObjid(cid), cname, sizeof(pwr_tObjName), cdh_mName_object);
if ( EVEN(sts)) return sts;
sts = gdh_ArefANameToAref( aref, "Description", &daref);
if ( ODD(sts)) {
sts = gdh_GetObjectInfoAttrref( &daref, descr, dsize);
}
if ( EVEN(sts))
strcpy( descr, "");
return 1;
}
pwr_tStatus XttOTree::get_node_info( void *ctx, char *name, char *descr, int dsize)
{
pwr_tStatus sts;
pwr_tAName dname;
strncpy( dname, name, sizeof(dname));
strncat( dname, ".Description", sizeof(dname));
sts = gdh_GetObjectInfo( dname, descr, dsize);
if ( EVEN(sts))
strcpy( descr, "");
return sts;
}
pwr_tStatus XttOTree::action( void *ctx, pwr_tAttrRef *aref)
{
XttOTree *otree = (XttOTree *)ctx;
if ( otree->action_cb)
return (otree->action_cb)( otree->parent_ctx, aref);
return 0;
}
void XttOTree::close( void *ctx)
{
XttOTree *otree = (XttOTree *)ctx;
if ( otree->close_cb)
(otree->close_cb)( otree->parent_ctx);
else
delete otree;
}
XttOTree::~XttOTree() {
}
/*
* Proview Open Source Process Control.
* Copyright (C) 2005-2016 SSAB EMEA AB.
*
* This file is part of Proview.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Proview. If not, see <http://www.gnu.org/licenses/>
*
* Linking Proview statically or dynamically with other modules is
* making a combined work based on Proview. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
*
* In addition, as a special exception, the copyright holders of
* Proview give you permission to, from the build function in the
* Proview Configurator, combine Proview with modules generated by the
* Proview PLC Editor to a PLC program, regardless of the license
* terms of these modules. You may copy and distribute the resulting
* combined work under the terms of your choice, provided that every
* copy of the combined work is accompanied by a complete copy of
* the source code of Proview (the version used to produce the
* combined work), being distributed under the terms of the GNU
* General Public License plus this exception.
**/
#ifndef xtt_otree_h
#define xtt_otree_h
#ifndef cow_tree_h
#include "cow_tree.h"
#endif
/* xtt_otree.h -- Object tree viewer */
class XttOTree {
protected:
void *parent_ctx;
CowTree *cowtree;
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *);
public:
XttOTree( void *xn_parent_ctx, pwr_tAttrRef *xn_itemlist, int xn_item_cnt, unsigned int xn_options,
pwr_tStatus (*xn_action_cb)( void *, pwr_tAttrRef *));
void pop();
void (*close_cb)( void *);
static pwr_tStatus get_object_info( void *ctx, pwr_tAttrRef *aref, char *name, int nsize, char *cname,
char *descr, int dsize);
static pwr_tStatus get_node_info( void *ctx, char *name, char *descr, int dsize);
static pwr_tStatus action( void *ctx, pwr_tAttrRef *aref);
static void close( void *ctx);
virtual ~XttOTree();
};
#endif
......@@ -74,7 +74,7 @@ XttSevHist::XttSevHist( void *parent_ctx,
int *sts) :
xnav(parent_ctx), gcd(0), curve(0), rows(0), vsize(0), timerid(0), close_cb(0), help_cb(0),
get_select_cb(0), first_scan(1), scctx(xn_scctx), wow(0), time_low_old(0), time_high_old(0),
initial_period(time_ePeriod_), color_theme(xn_color_theme)
initial_period(time_ePeriod_), color_theme(xn_color_theme), otree(0)
{
pwr_tTime from, to;
......@@ -888,6 +888,35 @@ void XttSevHist::sevhist_next_period_cb( void *ctx)
void XttSevHist::sevhist_add_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *) ctx;
if ( !sevhist->get_select_cb) {
if ( sevhist->otree)
sevhist->otree->pop();
else {
pwr_tAttrRef *list;
int listcnt;
pwr_tCid cid[2] = {pwr_cClass_SevHist, pwr_cClass_SevHistObject};
int options = 0;
pwr_tStatus sts;
sts = gdh_GetGlobalClassList( 2, cid, 1, &list, &listcnt);
if ( EVEN(sts)) return;
if ( !listcnt)
return;
if ( listcnt > 20)
options |= tree_mOptions_LayoutTree;
else
options |= tree_mOptions_LayoutList;
options |= tree_mOptions_AlphaOrder;
sevhist->otree = sevhist->tree_new( "Add attribute", list, listcnt, options, sevhist_otree_action_cb);
sevhist->otree->close_cb = sevhist_otree_close_cb;
free( (char *)list);
}
}
else {
pwr_tOid oid;
pwr_tOName aname, oname;
int sts;
......@@ -899,11 +928,56 @@ void XttSevHist::sevhist_add_cb( void *ctx)
if ( EVEN(sts)) return;
sevhist->curve_add( oid, aname, oname, false);
}
}
pwr_tStatus XttSevHist::sevhist_otree_action_cb( void *ctx, pwr_tAttrRef *aref)
{
XttSevHist *sevhist = (XttSevHist *)ctx;
pwr_tStatus sts;
pwr_tAttrRef aaref;
pwr_tAName oname;
pwr_tAName aname;
char *s;
pwr_tCid cid;
sts = gdh_GetAttrRefTid( aref, &cid);
if ( EVEN(sts)) return sts;
sts = gdh_ArefANameToAref( aref, "Attribute", &aaref);
if ( EVEN(sts)) return sts;
sts = gdh_GetObjectInfoAttrref( &aaref, &aaref, sizeof(pwr_tAttrRef));
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( &aaref, oname, sizeof(oname), cdh_mNName);
if ( EVEN(sts)) return sts;
s = strrchr( oname, '.');
if ( s) {
*s = 0;
strncpy( aname, s+1, sizeof(aname));
}
sevhist->curve_add( aaref.Objid, aname, oname, cid == pwr_cClass_SevHistObject);
if ( EVEN(sts))
printf( "SevHist add failure\n");
return sts;
}
void XttSevHist::sevhist_otree_close_cb( void *ctx)
{
XttSevHist *sevhist = (XttSevHist *)ctx;
if ( sevhist->otree) {
delete sevhist->otree;
sevhist->otree = 0;
}
}
void XttSevHist::sevhist_remove_cb( void *ctx)
{
// Do do
// To do
}
int XttSevHist::sevhist_export_cb( void *ctx, pwr_tTime *from, pwr_tTime *to, int rows, int idx,
......
......@@ -96,6 +96,7 @@ class XttSevHist {
bool sevhistobjectv[XTT_SEVHIST_MAX]; //!< Indicates that it is a SevHistObject
time_ePeriod initial_period;
int color_theme;
XttOTree *otree;
//! Constructor
XttSevHist( void *xn_parent_ctx,
......@@ -127,6 +128,11 @@ class XttSevHist {
void setup();
void update_color_theme( int ct) { curve->update_color_theme(ct);}
virtual XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *)) {return 0;}
static pwr_tStatus sevhist_otree_action_cb( void *ctx, pwr_tAttrRef *aref);
static void sevhist_otree_close_cb( void *ctx);
static void sevhist_close_cb( void *ctx);
static void sevhist_increase_period_cb( void *ctx);
static void sevhist_decrease_period_cb( void *ctx);
......
......@@ -60,6 +60,7 @@
#include "xtt_xnav.h"
#include "xtt_trend.h"
#include "xtt_otree.h"
#include "ge_curve.h"
......@@ -70,8 +71,9 @@ XttTrend::XttTrend( void *parent_ctx,
unsigned int x_options,
int xn_color_theme,
int *sts) :
xnav(parent_ctx), trend_cnt(0), update_time(1000), options(x_options),
close_cb(0), help_cb(0), command_cb(0), get_select_cb(0), color_theme(xn_color_theme)
xnav(parent_ctx), trend_cnt(0), gcd(0), curve(0), update_time(1000), options(x_options), timerid(0),
close_cb(0), help_cb(0), command_cb(0), get_select_cb(0), color_theme(xn_color_theme),
otree(0)
{
pwr_sAttrRef *aref_list;
pwr_sAttrRef *aref_p;
......@@ -501,6 +503,9 @@ void XttTrend::pop()
void XttTrend::setup()
{
if ( !curve)
return;
if ( trend_tid == pwr_cClass_DsTrendCurve)
curve->setup( curve_mEnable_Snapshot | curve_mEnable_Add);
else
......@@ -528,160 +533,63 @@ void XttTrend::trend_snapshot_cb( void *ctx)
(trend->command_cb)( trend->xnav, cmd);
}
class AttrList {
public:
AttrList( char *a, char *t) : attr(a), trend(t) {}
string attr;
string trend;
};
class AttrListCtx {
public:
AttrListCtx( XttTrend *t) : trend(t) {}
XttTrend *trend;
vector<AttrList> v;
};
static void add_objectlist_cb( void *ctx, char *text, int ok_pressed)
void XttTrend::trend_madd_cb( void *ctx)
{
printf( "%s\n", text);
XttTrend *trend = (XttTrend *) ctx;
if ( trend->otree)
trend->otree->pop();
else {
pwr_tAttrRef *list;
int listcnt;
pwr_tCid cid[2] = {pwr_cClass_DsTrend, pwr_cClass_DsTrendCurve};
int options = 0;
pwr_tStatus sts;
pwr_tAttrRef trend_aref, attr_aref;
AttrListCtx *vctx = (AttrListCtx *)ctx;
unsigned int i;
int found = 0;
for ( i = 0; i < vctx->v.size(); i++) {
if ( strcmp( vctx->v[i].attr.c_str(), text) == 0) {
found = 1;
break;
}
}
if ( !found)
return;
sts = gdh_NameToAttrref( pwr_cNOid, vctx->v[i].attr.c_str(), &attr_aref);
sts = gdh_GetGlobalClassList( 2, cid, 1, &list, &listcnt);
if ( EVEN(sts)) return;
sts = gdh_NameToAttrref( pwr_cNOid, vctx->v[i].trend.c_str(), &trend_aref);
if ( EVEN(sts)) return;
if ( !listcnt)
return;
vctx->trend->curve_add( &attr_aref, &trend_aref, &sts);
if ( EVEN(sts))
printf( "Trend add failure\n");
if ( listcnt > 20)
options |= tree_mOptions_LayoutTree;
else
options |= tree_mOptions_LayoutList;
options |= tree_mOptions_AlphaOrder;
delete vctx;
}
trend->otree = trend->tree_new( "Add attribute", list, listcnt, options, trend_otree_action_cb);
trend->otree->close_cb = trend_otree_close_cb;
static void add_objectlist_cancel_cb( void *ctx)
{
delete (AttrListCtx *)ctx;
free( (char *)list);
}
}
void XttTrend::trend_madd_cb( void *ctx)
pwr_tStatus XttTrend::trend_otree_action_cb( void *ctx, pwr_tAttrRef *aref)
{
XttTrend *trend = (XttTrend *) ctx;
pwr_tAttrRef trend_aref, attr_aref;
pwr_tAName trend_name, attr_name;
XttTrend *trend = (XttTrend *)ctx;
pwr_tStatus sts;
pwr_tAName *names;
printf( "Madd\n");
AttrListCtx *vctx = new AttrListCtx(trend);
for ( sts = gdh_GetClassListAttrRef( trend->trend_tid, &trend_aref);
ODD(sts);
sts = gdh_GetNextAttrRef( trend->trend_tid, &trend_aref, &trend_aref)) {
switch ( trend->trend_tid) {
case pwr_cClass_DsTrend: {
pwr_tAttrRef dataname_aref;
sts = gdh_ArefANameToAref( &trend_aref, "DataName", &dataname_aref);
if ( EVEN(sts)) return;
sts = gdh_GetObjectInfoAttrref( &dataname_aref, &attr_aref, sizeof(attr_aref));
if ( EVEN(sts)) return;
sts = gdh_AttrrefToName( &attr_aref, attr_name, sizeof(attr_name),
cdh_mNName);
if ( EVEN(sts)) continue;
sts = gdh_AttrrefToName( &trend_aref, trend_name, sizeof(trend_name),
cdh_mNName);
if ( EVEN(sts)) continue;
AttrList l( attr_name, trend_name);
vctx->v.push_back(l);
break;
}
case pwr_cClass_DsTrendCurve: {
pwr_sClass_DsTrendCurve tp;
unsigned int asize = sizeof(tp.Attribute)/sizeof(tp.Attribute[0]);
sts = gdh_GetObjectInfoAttrref( &trend_aref, &tp, sizeof(tp));
if ( EVEN(sts)) return;
sts = gdh_AttrrefToName( &trend_aref, trend_name, sizeof(trend_name),
cdh_mNName);
if ( EVEN(sts)) continue;
for ( unsigned int j = 0; j < asize; j++) {
if ( cdh_ObjidIsNull(tp.Attribute[j].Objid))
break;
sts = gdh_AttrrefToName( &tp.Attribute[j], attr_name, sizeof(attr_name),
cdh_mNName);
if (EVEN(sts)) continue;
AttrList l( attr_name, trend_name);
vctx->v.push_back(l);
}
break;
}
default: ;
}
}
trend->curve_add( aref, 0, &sts);
if ( EVEN(sts))
printf( "Trend add failure\n");
return sts;
}
names = (pwr_tAName *)calloc( vctx->v.size() + 1, sizeof(pwr_tAName));
for ( unsigned int i = 0; i < vctx->v.size(); i++) {
strcpy( names[i], vctx->v[i].attr.c_str());
}
void XttTrend::trend_otree_close_cb( void *ctx)
{
XttTrend *trend = (XttTrend *)ctx;
// Sort
pwr_tAName tmp;
for ( unsigned int i = vctx->v.size() - 1; i > 0; i--) {
for ( unsigned int j = 0; j < i; j++) {
if ( strcmp(names[j], names[j+1]) > 0) {
strcpy( tmp, names[j+1]);
strcpy( names[j+1], names[j]);
strcpy( names[j], tmp);
}
}
if ( trend->otree) {
delete trend->otree;
trend->otree = 0;
}
trend->wow->CreateList( "Add attribute", (char *)names, sizeof(names[0]),
add_objectlist_cb, add_objectlist_cancel_cb, vctx);
free( names);
}
void XttTrend::trend_add_cb( void *ctx)
{
XttTrend *trend = (XttTrend *) ctx;
pwr_tAttrRef aref;
int is_attr;
pwr_tStatus sts;
if ( !trend->get_select_cb)
return;
sts = trend->get_select_cb( trend->xnav, &aref, &is_attr);
if ( EVEN(sts)) return;
trend->curve_add( &aref, 0, &sts);
if ( EVEN(sts))
printf( "Trend add failure\n");
trend_madd_cb( ctx);
}
void XttTrend::trend_help_cb( void *ctx)
......
......@@ -85,6 +85,7 @@ class XttTrend {
int (*get_select_cb)( void *, pwr_tAttrRef *, int *); //!< Get selected trend object.
CoWow *wow;
int color_theme;
XttOTree *otree;
XttTrend( void *xn_parent_ctx,
char *xn_name,
......@@ -98,7 +99,11 @@ class XttTrend {
void setup();
void curve_add( pwr_tAttrRef *arp, pwr_tAttrRef *trend_arp, pwr_tStatus *sts);
void update_color_theme( int ct) { curve->update_color_theme(ct);}
virtual XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int layout,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *)) {return 0;}
static pwr_tStatus trend_otree_action_cb( void *ctx, pwr_tAttrRef *aref);
static void trend_otree_close_cb( void *ctx);
static void trend_close_cb( void *ctx);
static void trend_help_cb( void *ctx);
static void trend_snapshot_cb( void *ctx);
......
......@@ -115,6 +115,10 @@ extern "C" {
#include "xtt_keyboard.h"
#endif
#ifndef xtt_otree_h
#include "xtt_otree.h"
#endif
#define xnav_cVersion "X3.0b"
#define XNAV_BROW_MAX 25
#define XNAV_LOGG_MAX 10
......@@ -411,6 +415,8 @@ class XNav {
pwr_tStatus *status) { return 0;}
virtual XttKeyboard *keyboard_new( const char *name, keyboard_eKeymap keymap, keyboard_eType type,
int color_theme, pwr_tStatus *status) {return 0;}
virtual XttOTree *tree_new( const char *title, pwr_tAttrRef *itemlist, int itemcnt, unsigned int options,
pwr_tStatus (*action_cb)( void *, pwr_tAttrRef *)) {return 0;}
virtual void bell( int time) {}
virtual int confirm_dialog( char *title, char *text) { return 0; }
virtual void set_clock_cursor() {}
......
......@@ -100,6 +100,7 @@
#include "xtt_fileview.h"
#include "xtt_log.h"
#include "xtt_stream.h"
#include "xtt_otree.h"
class xnav_file {
public:
......@@ -200,6 +201,7 @@ static void xnav_colortheme_selector_ok_cb( void *ctx, char *text, int ok_presse
static void xnav_keyboard_key_pressed_cb( void *, int);
static void xnav_keyboard_close_cb( void *);
static int xnav_replace_node_str( char *out, char *object_str);
static pwr_tStatus xnav_otree_action_cb( void *xnav, pwr_tAttrRef *aref);
static int xnav_help_func( void *client_data,
void *client_flag);
......@@ -273,7 +275,7 @@ dcli_tCmdTable xnav_command_table[] = {
"/OPTION", "/ENTRY", "/NEW", "/TITLE", "/WINDOW",
"/ALARMVIEW", "/WIDTH", "/HEIGHT", "/XPOSITION", "/YPOSITION",
"/FULLSCREEN", "/MAXIMIZE", "/FULLMAXIMIZE",
"/SORT", "/TEXT", ""}
"/SORT", "/TEXT", "/LAYOUT", "/GLOBAL", "/ALPHAORDER", ""}
},
{
"OPEN",
......@@ -2702,6 +2704,87 @@ static int xnav_show_func( void *client_data,
xnav_show_objectlist_cancel_cb, ctx);
free( names);
}
else if ( cdh_NoCaseStrncmp( arg1_str, "OBJECTTREE", strlen( arg1_str)) == 0)
{
char class_str[80];
// Command is "SHOW OBJECTTREE"
if ( ODD( dcli_get_qualifier( "/CLASS", class_str, sizeof(class_str)))) {
pwr_tCid cid[20];
pwr_tObjName class_array[20];
int class_num;
pwr_tAttrRef *list;
int listcnt;
unsigned int options = 0;
char layout_str[40];
int i;
int global;
int alphaorder;
global = ODD( dcli_get_qualifier( "/GLOBAL", 0, 0));
alphaorder = ODD( dcli_get_qualifier( "/ALPHAORDER", 0, 0));
// The class string can contain several classes separated by ','
class_num = dcli_parse( class_str, ",", "",
(char *) class_array, sizeof( class_array)/sizeof( class_array[0]),
sizeof( class_array[0]), 0);
for ( i = 0; i < class_num; i++) {
sts = gdh_ClassNameToId( class_array[i], &cid[i]);
if ( EVEN(sts)) {
xnav->message('E', "Unknown class");
return XNAV__HOLDCOMMAND;
}
}
if ( global)
sts = gdh_GetGlobalClassList( class_num, cid, 1, &list, &listcnt);
else
sts = gdh_GetLocalClassList( class_num, cid, 1, &list, &listcnt);
if ( EVEN(sts)) {
xnav->message('E', "Class list error");
return XNAV__HOLDCOMMAND;
}
if ( listcnt == 0) {
xnav->message('E', "No objects found");
return XNAV__HOLDCOMMAND;
}
if ( ODD( dcli_get_qualifier( "/LAYOUT", layout_str, sizeof(layout_str)))) {
if ( cdh_NoCaseStrcmp( layout_str, "list") == 0)
options |= tree_mOptions_LayoutList;
else if ( cdh_NoCaseStrcmp( layout_str, "tree") == 0)
options |= tree_mOptions_LayoutTree;
else if ( cdh_NoCaseStrcmp( layout_str, "default") == 0) {
if ( listcnt > 20)
options |= tree_mOptions_LayoutTree;
else
options |= tree_mOptions_LayoutList;
}
else {
xnav->message('E', "No such layout");
return XNAV__HOLDCOMMAND;
}
}
else {
if ( listcnt > 20)
options |= tree_mOptions_LayoutTree;
else
options |= tree_mOptions_LayoutList;
}
if ( alphaorder)
options |= tree_mOptions_AlphaOrder;
xnav->tree_new( "Objects", list, listcnt, options, xnav_otree_action_cb);
free( (char *)list);
return XNAV__SUCCESS;
}
else {
xnav->message('E', "Syntax error");
return XNAV__HOLDCOMMAND;
}
}
else
{
/* This might be a system picture */
......@@ -4513,7 +4596,7 @@ static int xnav_open_func( void *client_data,
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
hist->close_cb = xnav_sevhist_close_cb;
hist->get_select_cb = xnav_sevhist_get_select_cb;
// hist->get_select_cb = xnav_sevhist_get_select_cb;
xnav->appl.insert( applist_eType_SevHist, (void *)hist, pwr_cNOid, "",
NULL);
}
......@@ -4768,7 +4851,7 @@ static int xnav_open_func( void *client_data,
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
hist->close_cb = xnav_sevhist_close_cb;
hist->get_select_cb = xnav_sevhist_get_select_cb;
//hist->get_select_cb = xnav_sevhist_get_select_cb;
xnav->appl.insert( applist_eType_SevHist, (void *)hist, oidv[0], "",
NULL);
}
......@@ -4780,7 +4863,7 @@ static int xnav_open_func( void *client_data,
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
hist->close_cb = xnav_sevhist_close_cb;
hist->get_select_cb = xnav_sevhist_get_select_cb;
//hist->get_select_cb = xnav_sevhist_get_select_cb;
xnav->appl.insert( applist_eType_SevHist, (void *)hist, oidv[0], "",
NULL);
}
......@@ -4792,7 +4875,7 @@ static int xnav_open_func( void *client_data,
if ( ODD(sts)) {
hist->help_cb = xnav_sevhist_help_cb;
hist->close_cb = xnav_sevhist_close_cb;
hist->get_select_cb = xnav_sevhist_get_select_cb;
//hist->get_select_cb = xnav_sevhist_get_select_cb;
xnav->appl.insert( applist_eType_SevHist, (void *)hist, oidv[0], "",
NULL);
}
......@@ -9635,7 +9718,6 @@ int XNav::show_symbols()
return XNAV__SUCCESS;
}
void xnav_popup_menu_cb( void *xnav, pwr_sAttrRef attrref,
unsigned long item_type,
unsigned long utility, char *arg, int x, int y)
......@@ -9662,6 +9744,7 @@ void xnav_start_trace_cb( void *xnav, pwr_tObjid objid, char *name)
((XNav *)xnav)->start_trace( objid, name);
}
static void xnav_clog_close_cb( void *ctx)
{
XNav *xnav = (XNav *)ctx;
......@@ -9845,6 +9928,44 @@ static void xnav_keyboard_close_cb( void *ctx)
xnav->close_keyboard( keyboard_mAction_Close | keyboard_mAction_ResetInput);
}
static pwr_tStatus xnav_otree_action_cb( void *ctx, pwr_tAttrRef *aref)
{
XNav *xnav = (XNav *)ctx;
pwr_tStatus sts;
pwr_tAName aname;
pwr_tCmd cmd;
pwr_tCid cid;
sts = gdh_GetAttrRefTid( aref, &cid);
if ( EVEN(sts)) return sts;
sts = gdh_AttrrefToName( aref, aname, sizeof(aname), cdh_mNName);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_cClass_DsTrend:
case pwr_cClass_DsTrendCurve:
sprintf( cmd, "open trend/name=%s/title=\"%s\"", aname, aname);
break;
case pwr_cClass_DsFastCurve:
sprintf( cmd, "open fast/name=%s/title=\"%s\"", aname, aname);
break;
case pwr_cClass_SevHist:
case pwr_cClass_SevHistObject:
sprintf( cmd, "open history/name=%s/title=\"%s\"", aname, aname);
break;
case pwr_cClass_XttGraph:
sprintf( cmd, "open graph/object=%s", aname);
break;
default:
sprintf( cmd, "open graph/class/inst=%s", aname);
}
xnav->command( cmd);
return 1;
}
void XNav::open_graph( const char *name, const char *filename, int scrollbar, int menu,
int navigator, int width, int height, int x, int y,
const char *object_name, const char *focus_name, int input_focus_empty,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment