Commit f773bd1b authored by Claes Sjofors's avatar Claes Sjofors

ClassDef flags internal bit added to hide class in palette, and one extra...

ClassDef flags internal bit added to hide class in palette, and one extra classhier level in classvolumes allowed
parent ae135a2a
......@@ -527,7 +527,8 @@ union pwr_m_ClassDef {
pwr_Bits( HasCallBack , 1), /* object has DbCallBack */
pwr_Bits( RtReadOnly , 1), /* object is readonly in runtime */
pwr_Bits( fill_1 , 7),,,,,,,
pwr_Bits( Internal , 1), /* class is internal */
pwr_Bits( fill_1 , 6),,,,,,
pwr_Bits( fill_2 , 8),,,,,,,
) b;
......@@ -548,6 +549,7 @@ union pwr_m_ClassDef {
#define pwr_mClassDef_IOCard pwr_Bit(14)
#define pwr_mClassDef_HasCallBack pwr_Bit(15)
#define pwr_mClassDef_RtReadOnly pwr_Bit(16)
#define pwr_mClassDef_Internal pwr_Bit(17)
#define pwr_mClassDef_HasRef (pwr_mClassDef_ObjXRef|pwr_mClassDef_AttrXRef|\
pwr_mClassDef_ObjRef|pwr_mClassDef_AttrRef)
......
......@@ -46,6 +46,7 @@ SObject pwrb:Class
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -48,6 +48,7 @@ SObject pwrb:Class
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr PopEditor = 1
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -51,6 +51,7 @@ SObject pwrb:Class
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -47,6 +47,7 @@ SObject pwrb:Class
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -45,6 +45,7 @@ SObject pwrb:Class
Body SysBody
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_Standard
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -50,6 +50,7 @@ SObject pwrb:Class
Attr Editor = pwr_eEditor_AttrEd
Attr Method = pwr_eMethod_RtConnectionsAndDevBodies
Attr PopEditor = 2
Attr Flags |= pwr_mClassDef_Internal
EndBody
Object RtBody $ObjBodyDef 1
Body SysBody
......
......@@ -105,6 +105,11 @@ SObject pwrs:Class
! NoAdopt object can not have children
! Template object is a template object
! IO object is an IO object
! IOAgent object is an IO agent object
! IORack object is an IO rack object
! IOCard object is an IO card object
! RtReadOnly object is readonly in runtime
! Internal class is internal and not displayed in palettes
!*/
Object Flags pwr_eClass_Param
Body SysBody
......
......@@ -222,6 +222,17 @@ SObject pwrs:Type
Attr Value = 65536
EndBody
EndObject
!/**
! Class is internal, ie only used as superclass or attribute objects.
! It will not be displayed in palettes.
!*/
Object Internal $Bit
Body SysBody
Attr PgmName = "Internal"
Attr Text = "Internal"
Attr Value = 131072
EndBody
EndObject
EndObject
EndSObject
......
......@@ -46,10 +46,18 @@ static pwr_tStatus AnteCreate (
pwr_tObjid Father,
pwr_tClassId Class
) {
// ClassHier should be a top object
if ( Father.oix != 0)
return PWRS__POSCLASSHIER;
// ClassHier should be a top object or under object Class
if ( Father.oix != 0) {
pwr_tStatus sts;
pwr_tOName name;
int size;
sts = ldh_ObjidToName( Session, Father, ldh_eName_Hierarchy, name, sizeof(name), &size);
if ( EVEN(sts)) return sts;
if ( strcmp( name, "Class") != 0)
return PWRS__POSCLASSHIER;
}
return PWRS__SUCCESS;
}
......
......@@ -108,7 +108,32 @@ wb_cdrep::wb_cdrep( wb_mvrep *mvrep, wb_name name) : m_nRef(0), m_orep(0), m_mer
strcat( str, name.object());
wb_name n = wb_name( str);
m_orep = mvrep->object( &m_sts, n);
if ( EVEN(m_sts)) throw wb_error( m_sts);
if ( EVEN(m_sts)) {
wb_name n = wb_name( "Class");
wb_orep *c_orep = mvrep->object( &m_sts, n);
c_orep->ref();
for ( wb_orep *orep = mvrep->first( &m_sts, c_orep);
ODD(m_sts);) {
orep->ref();
if ( orep->cid() == pwr_eClass_ClassHier) {
strcpy( str, "Class-");
strcat( str, orep->name());
strcat( str, "-");
strcat( str, name.object());
wb_name nn = wb_name( str);
m_orep = mvrep->object( &m_sts, nn);
if ( ODD(m_sts))
break;
}
wb_orep *old = orep;
orep = mvrep->after( &m_sts, orep);
old->unref();
}
c_orep->unref();
}
if ( EVEN(m_sts))
throw wb_error( m_sts);
m_orep->ref();
m_sts = LDH__SUCCESS;
......
......@@ -166,8 +166,9 @@ int PalItemClassVolume::open( Pal *pal, double x, double y)
int found;
pwr_tObjid ref_objid;
pwr_tVolumeId volume;
pwr_tClassId classid;
pwr_tClassId classid, cid;
char volume_name[80];
pwr_tMask *flags;
if ( !is_root)
brow_GetNodePosition( node, &node_x, &node_y);
......@@ -223,8 +224,24 @@ int PalItemClassVolume::open( Pal *pal, double x, double y)
while ( ODD(sts))
{
child_exist = 1;
sts = ldh_GetObjectClass( pal->ldhses, child, &cid);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_eClass_ClassDef:
sts = ldh_GetObjectPar( pal->ldhses, child, "SysBody", "Flags",
(char **)&flags, &size);
if ( EVEN(sts)) return sts;
if ( !(*flags & pwr_mClassDef_Internal))
sts = pal->create_item( child, node, flow_eDest_IntoLast,
(void **) &item, 0);
free( flags);
break;
case pwr_eClass_ClassHier:
new PalItemClassMenu( pal, child, node, flow_eDest_IntoLast);
break;
}
sts = ldh_GetNextSibling( pal->ldhses, child, &child);
}
......@@ -437,6 +454,97 @@ PalItemObject::PalItemObject( Pal *pal, pwr_tObjid item_objid,
}
}
PalItemClassMenu::PalItemClassMenu( Pal *pal, pwr_tObjid item_objid,
brow_tNode dest, flow_eDest dest_code) :
PalItem( item_objid, 0)
{
int sts;
char name[80];
int size;
type = pal_ePalItemType_ClassMenu;
sts = ldh_ObjidToName( pal->ldhses, objid, ldh_eName_Object,
name, sizeof(name), &size);
brow_CreateNode( pal->brow_ctx, name, pal->nc,
dest, dest_code, NULL, 1, &node);
brow_SetAnnotPixmap( node, 0, pal->pixmap_map);
brow_SetAnnotation( node, 0, name, sizeof(name));
brow_SetUserData( node, (void *)this);
}
int PalItemClassMenu::open( Pal *pal, double x, double y)
{
if ( brow_IsOpen( node))
close( pal, x, y);
else {
// Display children
double node_x, node_y;
PalItem *item;
pwr_tCid cid;
pwr_tOid child;
int child_exist;
pwr_tStatus sts;
pwr_tMask *flags;
int size;
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( pal->brow_ctx);
child_exist = 0;
sts = ldh_GetChild( pal->ldhses, objid, &child);
while ( ODD(sts)) {
child_exist = 1;
sts = ldh_GetObjectClass( pal->ldhses, child, &cid);
if ( EVEN(sts)) return sts;
switch ( cid) {
case pwr_eClass_ClassDef:
sts = ldh_GetObjectPar( pal->ldhses, child, "SysBody", "Flags",
(char **)&flags, &size);
if ( EVEN(sts)) return sts;
if ( !(*flags & pwr_mClassDef_Internal))
sts = pal->create_item( child, node, flow_eDest_IntoLast,
(void **) &item, 0);
free( flags);
break;
case pwr_eClass_ClassHier:
new PalItemClassMenu( pal, child, node, flow_eDest_IntoLast);
break;
}
sts = ldh_GetNextSibling( pal->ldhses, child, &child);
}
if ( child_exist) {
brow_SetOpen( node, 1);
brow_SetAnnotPixmap( node, 0, pal->pixmap_openmap);
}
brow_ResetNodraw( pal->brow_ctx);
if ( child_exist)
brow_Redraw( pal->brow_ctx, node_y);
}
return 1;
}
int PalItemClassMenu::close( Pal *pal, double x, double y)
{
double node_x, node_y;
if ( brow_IsOpen( node)) {
// Close
brow_GetNodePosition( node, &node_x, &node_y);
brow_SetNodraw( pal->brow_ctx);
brow_CloseNode( pal->brow_ctx, node);
brow_SetAnnotPixmap( node, 0, pal->pixmap_map);
brow_ResetOpen( node, pal_mOpen_All);
brow_ResetNodraw( pal->brow_ctx);
brow_Redraw( pal->brow_ctx, node_y);
}
return 1;
}
PalItemMenu::PalItemMenu( Pal *pal, char *item_name,
brow_tNode dest, flow_eDest dest_code, PalFileMenu **item_child_list,
int item_is_root) :
......@@ -1178,6 +1286,9 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
case pal_ePalItemType_Menu:
((PalItemMenu *)item)->open( pal, 0, 0);
break;
case pal_ePalItemType_ClassMenu:
((PalItemClassMenu *)item)->open( pal, 0, 0);
break;
case pal_ePalItemType_Object:
((PalItemObject *)item)->open( pal, 0, 0);
break;
......@@ -1220,6 +1331,9 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
case pal_ePalItemType_Menu:
((PalItemMenu *)item)->open( pal, 0, 0);
break;
case pal_ePalItemType_ClassMenu:
((PalItemMenu *)item)->open( pal, 0, 0);
break;
case pal_ePalItemType_Object:
((PalItemObject *)item)->open( pal, 0, 0);
break;
......@@ -1263,6 +1377,10 @@ int Pal::brow_cb( FlowCtx *ctx, flow_tEvent event)
((PalItemMenu *)item)->open( pal,
event->object.x, event->object.y);
break;
case pal_ePalItemType_ClassMenu:
((PalItemClassMenu *)item)->open( pal,
event->object.x, event->object.y);
break;
case pal_ePalItemType_Object:
((PalItemObject *)item)->open( pal,
event->object.x, event->object.y);
......
......@@ -168,7 +168,8 @@ typedef enum {
pal_ePalItemType_Object,
pal_ePalItemType_Class,
pal_ePalItemType_ClassVolume,
pal_ePalItemType_Menu
pal_ePalItemType_Menu,
pal_ePalItemType_ClassMenu
} pal_ePalItemType;
class PalItem {
......@@ -208,6 +209,14 @@ class PalItemObject : public PalItem {
brow_tNode dest, flow_eDest dest_code, int item_is_root);
};
class PalItemClassMenu : public PalItem {
public:
PalItemClassMenu( Pal *pal, pwr_tObjid item_objid,
brow_tNode dest, flow_eDest dest_code);
int open( Pal *pal, double x, double y);
int close( Pal *pal, double x, double y);
};
class PalItemMenu : public PalItem {
public:
PalItemMenu( Pal *pal, char *item_name,
......
......@@ -2413,6 +2413,7 @@ bool wb_vrepmem::classeditorCheck( ldh_eDest dest_code, mem_object *dest, pwr_tC
case pwr_eClass_ClassHier:
switch ( cid) {
case pwr_eClass_ClassDef:
case pwr_eClass_ClassHier:
break;
default:
*sts = LDH__CLASSMISPLACED;
......@@ -2446,10 +2447,7 @@ bool wb_vrepmem::classeditorCheck( ldh_eDest dest_code, mem_object *dest, pwr_tC
switch ( cid) {
case pwr_eClass_ClassHier: {
// Top object, named Class
if ( fth) {
*sts = LDH__CLASSMISPLACED;
return false;
}
if ( !fth) {
if ( !import_paste) {
strcpy( name, "Class");
if ( !nameCheck( dest, name, dest_code)) {
......@@ -2457,6 +2455,14 @@ bool wb_vrepmem::classeditorCheck( ldh_eDest dest_code, mem_object *dest, pwr_tC
return false;
}
}
}
else {
if ( strcmp( fth->name(), "Class") != 0) {
*sts = LDH__CLASSMISPLACED;
return false;
}
sprintf( name, "O%u", *oix);
}
*oix = nextOix();
break;
}
......@@ -2829,8 +2835,9 @@ void wb_vrepmem::printPaletteFile()
int palette_found = 0;
PalFileMenu *menu = PalFile::config_tree_build( 0, pal_cLocalPaletteFile,
pal_eNameType_All, "", 0);
PalFileMenu *mp, *mp2, *mp3, *mp4;
mem_object *memch, *memcd, *memgn;
PalFileMenu *mp, *mp2, *mp3, *mp4, *mp5;
mem_object *memch, *memch2, *memcd, *memcd2, *memgn;
int hier_inserted;
// Add menu "NavigatorPalette-AllClasses-'volumename' if not found
for ( mp = menu; mp; mp = mp->next) {
......@@ -2912,6 +2919,8 @@ void wb_vrepmem::printPaletteFile()
for ( memch = root_object; memch; memch = memch->fws) {
if ( memch->m_cid == pwr_eClass_ClassHier) {
for ( memcd = memch->fch; memcd; memcd = memcd->fws) {
switch ( memcd->m_cid) {
case pwr_eClass_ClassDef:
for ( memgn = memcd->fch; memgn; memgn = memgn->fws) {
if ( memgn->m_cid == pwr_eClass_GraphPlcNode) {
// Add to menu
......@@ -2924,6 +2933,37 @@ void wb_vrepmem::printPaletteFile()
break;
}
}
break;
case pwr_eClass_ClassHier:
memch2 = memcd;
hier_inserted = 0;
for ( memcd2 = memch2->fch; memcd2; memcd2 = memcd2->fws) {
for ( memgn = memcd2->fch; memgn; memgn = memgn->fws) {
if ( memgn->m_cid == pwr_eClass_GraphPlcNode) {
if ( !hier_inserted) {
hier_inserted = 1;
// Add ClassHier to menu
mp4 = mp3;
mp3 = new PalFileMenu( memch2->m_name, pal_eMenuType_Menu, mp2);
if ( !mp2->child_list)
mp2->child_list = mp3;
else
mp4->next = mp3;
}
// Add ClassDef to menu
mp5 = mp4;
mp4 = new PalFileMenu( memcd2->m_name, pal_eMenuType_Class, mp3);
if ( !mp3->child_list)
mp3->child_list = mp4;
else
mp5->next = mp4;
break;
}
}
}
break;
}
}
break;
}
......
......@@ -349,6 +349,7 @@ static wbl_sSym attr_flags[] =
,{ "pwr_mClassDef_IOCard", pwr_mClassDef_IOCard }
,{ "pwr_mClassDef_HasCallBack", pwr_mClassDef_HasCallBack }
,{ "pwr_mClassDef_RtReadOnly", pwr_mClassDef_RtReadOnly }
,{ "pwr_mClassDef_Internal", pwr_mClassDef_Internal }
,{ 0, 0 }
};
......
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