graph_displayer_canvas.h
author alpar
Mon, 30 Oct 2006 12:16:25 +0000
changeset 174 95872af46fc4
parent 172 fc1e478697d3
child 177 40f3006fba2e
permissions -rw-r--r--
Add copyright headers
alpar@174
     1
/* -*- C++ -*-
alpar@174
     2
 *
alpar@174
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@174
     4
 *
alpar@174
     5
 * Copyright (C) 2003-2006
alpar@174
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@174
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@174
     8
 *
alpar@174
     9
 * Permission to use, modify and distribute this software is granted
alpar@174
    10
 * provided that this copyright notice appears in all copies. For
alpar@174
    11
 * precise terms see the accompanying LICENSE file.
alpar@174
    12
 *
alpar@174
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@174
    14
 * express or implied, and with no claim as to its suitability for any
alpar@174
    15
 * purpose.
alpar@174
    16
 *
alpar@174
    17
 */
ladanyi@6
    18
ladanyi@6
    19
#ifndef GRAPH_DISPLAYER_CANVAS_H
ladanyi@6
    20
#define GRAPH_DISPLAYER_CANVAS_H
ladanyi@6
    21
hegyi@21
    22
class GraphDisplayerCanvas;
hegyi@21
    23
ladanyi@53
    24
#include "all_include.h"
hegyi@96
    25
#include "nbtab.h"
ladanyi@6
    26
#include <libgnomecanvasmm.h>
ladanyi@6
    27
#include <libgnomecanvasmm/polygon.h>
hegyi@150
    28
#include <lemon/dim2.h>
ladanyi@6
    29
ladanyi@6
    30
///This class is the canvas, on which the graph can be drawn.
ladanyi@6
    31
class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
ladanyi@6
    32
{
ladanyi@98
    33
  friend class BrokenEdge;
ladanyi@147
    34
  friend class LoopEdge;
ladanyi@147
    35
ladanyi@147
    36
  class EdgeBase : public Gnome::Canvas::Group
ladanyi@147
    37
  {
ladanyi@147
    38
    protected:
ladanyi@147
    39
      ///Reference to the canvas, on which the graph is drawn.
ladanyi@147
    40
ladanyi@147
    41
      ///It is needed, because some datas needed from
ladanyi@147
    42
      ///graph can be accessed by this or should be sent
ladanyi@147
    43
      ///as parameter, but it would be complicated
ladanyi@147
    44
      GraphDisplayerCanvas& canvas;
ladanyi@147
    45
ladanyi@147
    46
      ///The edge that the class displays.
ladanyi@147
    47
ladanyi@147
    48
      ///It is needed, because some datas needed from
ladanyi@147
    49
      ///graph can be accessed by this or should be sent
ladanyi@147
    50
      ///as parameter, but it would be complicated
ladanyi@147
    51
      Edge edge;
ladanyi@147
    52
ladanyi@147
    53
      Gnome::Canvas::Polygon arrow;
ladanyi@147
    54
ladanyi@147
    55
      void drawArrow(XY);
ladanyi@147
    56
    public:
ladanyi@147
    57
      EdgeBase(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
ladanyi@147
    58
      virtual ~EdgeBase();
ladanyi@147
    59
      virtual void draw() = 0;
ladanyi@147
    60
      virtual void setLineWidth(int) = 0;
ladanyi@147
    61
      virtual void setFillColor(Gdk::Color) = 0;
hegyi@149
    62
      virtual Gnome::Canvas::Item * getLine() = 0;
ladanyi@147
    63
  };
ladanyi@98
    64
hegyi@118
    65
  ///Edge displayer class
hegyi@118
    66
hegyi@118
    67
  ///This class is responsible for displaying edges in graph.
hegyi@118
    68
  ///The displayed edge is broken in the middle. The
hegyi@118
    69
  ///aim of this is to be able to indicate direction of edges
hegyi@118
    70
  ///and to be able to display more then one edges between the
hegyi@118
    71
  ///same source and target
ladanyi@147
    72
  class BrokenEdge : public EdgeBase
hegyi@89
    73
  {
ladanyi@147
    74
    private:
ladanyi@147
    75
      Gnome::Canvas::Line line;
hegyi@118
    76
ladanyi@147
    77
      ///Indicates whether the button of mouse is pressed or not at the moment.
ladanyi@147
    78
      bool isbutton;
hegyi@118
    79
ladanyi@147
    80
      ///At this location was the mousebutton pressed. Horizontal component.
hegyi@118
    81
ladanyi@147
    82
      ///It helps to calculate the
ladanyi@147
    83
      ///distance of dragging.
ladanyi@147
    84
      double clicked_x;
hegyi@118
    85
ladanyi@147
    86
      ///At this location was the mousebutton pressed. Vertical component.
hegyi@118
    87
ladanyi@147
    88
      ///It helps to calculate the
ladanyi@147
    89
      ///distance of dragging.
ladanyi@147
    90
      double clicked_y;
hegyi@89
    91
ladanyi@147
    92
      ///event handler for forming broken edges
hegyi@89
    93
ladanyi@147
    94
      ///\param event the
ladanyi@147
    95
      ///event to handle
ladanyi@147
    96
      bool edgeFormerEventHandler(GdkEvent* event);
hegyi@89
    97
ladanyi@147
    98
    public:
ladanyi@147
    99
      ///Constructor of broken edge class.
hegyi@118
   100
ladanyi@147
   101
      ///\param g the group to which the edge belongs
ladanyi@147
   102
      ///\param _edge the represented edge
ladanyi@147
   103
      ///\param gc the canvas
ladanyi@147
   104
      BrokenEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
hegyi@118
   105
ladanyi@147
   106
      ///Destructor of broken edge class
hegyi@118
   107
ladanyi@147
   108
      ///Frees up
ladanyi@147
   109
      ///reserved memory
ladanyi@147
   110
      ~BrokenEdge();
hegyi@118
   111
ladanyi@147
   112
      ///The function that draws the edge based on collected data
ladanyi@147
   113
      void draw();
hegyi@118
   114
ladanyi@147
   115
      void setLineWidth(int);
ladanyi@147
   116
      void setFillColor(Gdk::Color);
hegyi@149
   117
hegyi@149
   118
      Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
ladanyi@147
   119
  };
hegyi@118
   120
ladanyi@147
   121
  class LoopEdge : public EdgeBase
ladanyi@147
   122
  {
ladanyi@147
   123
    private:
ladanyi@147
   124
      Gnome::Canvas::Ellipse line;
ladanyi@151
   125
      bool edgeFormerEventHandler(GdkEvent* e);
ladanyi@151
   126
      bool isbutton;
ladanyi@147
   127
    public:
ladanyi@147
   128
      LoopEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
ladanyi@147
   129
      ~LoopEdge();
ladanyi@147
   130
      void draw();
ladanyi@147
   131
      void setLineWidth(int);
ladanyi@147
   132
      void setFillColor(Gdk::Color);
hegyi@149
   133
      Gnome::Canvas::Item * getLine() { return (Gnome::Canvas::Item *)(&line); };
hegyi@89
   134
  };
hegyi@118
   135
hegyi@118
   136
  ///Type of canvas, on which the graph is drawn
ladanyi@6
   137
  typedef Gnome::Canvas::CanvasAA Parent;
ladanyi@6
   138
ladanyi@6
   139
public:
hegyi@118
   140
  ///Constructor
hegyi@118
   141
hegyi@118
   142
  ///\param nbt the tab of the window, in which the graph is displayed
hegyi@118
   143
  GraphDisplayerCanvas(NoteBookTab & nbt);
hegyi@118
   144
hegyi@118
   145
  ///destructor of the class
ladanyi@6
   146
  virtual ~GraphDisplayerCanvas();
ladanyi@6
   147
hegyi@118
   148
  ///Changes the width of edge(s) according to the given map.
hegyi@118
   149
hegyi@118
   150
  ///\param mapname is the name of the map which contains the values to be set
hegyi@118
   151
  ///\param edge if it is given, only the width of the given edge will be set, instead of all of them.
hegyi@118
   152
  int changeEdgeWidth (std::string mapname, Edge edge=INVALID);
hegyi@118
   153
hegyi@118
   154
  ///Resets width of edge(s) to the default value
hegyi@118
   155
hegyi@118
   156
  ///\param edge if it is given, only the width of the
hegyi@118
   157
  ///given edge will be reset, instead of all of them.
hegyi@118
   158
  int resetEdgeWidth (Edge edge=INVALID);
hegyi@118
   159
hegyi@118
   160
  ///Changes the color of edge(s) according to the given map.
hegyi@118
   161
ladanyi@6
   162
  ///\param mapname is the name of the map which contains the new values
hegyi@118
   163
  ///\param edge if it is given, only the color of the given edge will be set, instead of all of them.
hegyi@118
   164
  int changeEdgeColor (std::string mapname, Edge edge=INVALID);
ladanyi@6
   165
hegyi@118
   166
  ///Resets color of edge(s) to the default value
hegyi@118
   167
hegyi@118
   168
  ///\param edge if it is given, only the color of the
hegyi@118
   169
  ///given edge will be reset, instead of all of them.
hegyi@118
   170
  int resetEdgeColor (Edge edge=INVALID);
hegyi@118
   171
hegyi@118
   172
  ///Changes the label of edge(s) according to the given map.
hegyi@118
   173
ladanyi@6
   174
  ///\param mapname is the name of the map which contains the new values
hegyi@118
   175
  ///\param edge if it is given, only the label of the given edge will be set, instead of all of them.
hegyi@118
   176
  int changeEdgeText (std::string mapname, Edge edge=INVALID);
ladanyi@6
   177
hegyi@118
   178
  ///Resets label of edge(s) to the default value
hegyi@118
   179
hegyi@118
   180
  ///\param edge if it is given, only the color of the
hegyi@118
   181
  ///given edge will be reset, instead of all of them.
hegyi@118
   182
  int resetEdgeText (Edge edge=INVALID);
hegyi@118
   183
hegyi@118
   184
  ///Changes the radius of node(s) according to the given map.
hegyi@118
   185
ladanyi@6
   186
  ///\param mapname is the name of the map which contains the new values
hegyi@118
   187
  ///\param node if it is given, only the radius of the given node will be set, instead of all of them.
hegyi@118
   188
  int changeNodeRadius (std::string mapname, Node node=INVALID);
hegyi@28
   189
hegyi@118
   190
  ///Resets radius of node(s) to the default value
hegyi@118
   191
hegyi@118
   192
  ///\param node if it is given, only the radius of the
hegyi@118
   193
  ///given node will be reset, instead of all of them.
hegyi@118
   194
  int resetNodeRadius (Node node=INVALID);
hegyi@118
   195
hegyi@118
   196
  ///Changes the color of node(s) according to the given map.
hegyi@118
   197
hegyi@28
   198
  ///\param mapname is the name of the map which contains the new values
hegyi@118
   199
  ///\param node if it is given, only the color of the given node will be set, instead of all of them.
hegyi@118
   200
  int changeNodeColor (std::string mapname, Node node=INVALID);
hegyi@28
   201
hegyi@118
   202
  ///Resets color of node(s) to the default value
hegyi@118
   203
hegyi@118
   204
  ///\param node if it is given, only the color of the
hegyi@118
   205
  ///given node will be reset, instead of all of them.
hegyi@118
   206
  int resetNodeColor (Node node=INVALID);
hegyi@118
   207
hegyi@118
   208
  ///Changes the label of node(s) according to the given map.
hegyi@118
   209
hegyi@28
   210
  ///\param mapname is the name of the map which contains the new values
hegyi@118
   211
  ///\param node if it is given, only the label of the given node will be set, instead of all of them.
hegyi@118
   212
  int changeNodeText (std::string mapname, Node node=INVALID);
hegyi@28
   213
hegyi@118
   214
  ///Resets label of node(s) to the default value
ladanyi@6
   215
hegyi@118
   216
  ///\param node if it is given, only the label of the
hegyi@118
   217
  ///given node will be reset, instead of all of them.
hegyi@118
   218
  int resetNodeText (Node node=INVALID);
hegyi@94
   219
hegyi@118
   220
  ///This function is called, when any of the displayed attributes have to be updated, or changed
hegyi@118
   221
hegyi@118
   222
  ///\param itisedge if true, edge property has to be changed, else node property
hegyi@118
   223
  ///\param prop the id of property that has to changed or updated
hegyi@118
   224
  void propertyChange(bool itisedge, int prop);
hegyi@118
   225
hegyi@118
   226
  ///updates the given property
hegyi@118
   227
hegyi@118
   228
  ///\param edge if it is not INVALID, only the property of the given edge will be updated, instead of all of them
hegyi@118
   229
  ///\param prop the property to update
hegyi@118
   230
  void propertyUpdate(Edge edge, int prop);
hegyi@118
   231
hegyi@118
   232
  ///updates the given property
hegyi@118
   233
hegyi@118
   234
  ///\param node if it is not INVALID, only the property of the given node will be updated, instead of all of them
hegyi@118
   235
  ///\param prop the property to update
hegyi@118
   236
  void propertyUpdate(Node node, int prop);
hegyi@118
   237
hegyi@118
   238
  ///updates all the property for the given edge
hegyi@94
   239
  void propertyUpdate(Edge);
hegyi@118
   240
hegyi@118
   241
  ///updates all the property for the given node
hegyi@94
   242
  void propertyUpdate(Node);
hegyi@94
   243
ladanyi@6
   244
  ///Callback for 'ViewZoomIn' action.
ladanyi@6
   245
  virtual void zoomIn();
ladanyi@6
   246
  ///Callback for 'ViewZoomOut' action.
ladanyi@6
   247
  virtual void zoomOut();
ladanyi@6
   248
  ///Callback for 'ViewZoomFit' action.
ladanyi@6
   249
  virtual void zoomFit();
ladanyi@6
   250
  ///Callback for 'ViewZoom100' action.
ladanyi@6
   251
  virtual void zoom100();
ladanyi@6
   252
  ///Sets the scroll region of the convas to the bounding box of the graph.
ladanyi@6
   253
  void updateScrollRegion();
ladanyi@6
   254
hegyi@9
   255
  ///This function changes the tool in the graph-editor's hand
hegyi@9
   256
  void changeEditorialTool(int);
hegyi@9
   257
ladanyi@6
   258
protected:
ladanyi@6
   259
hegyi@118
   260
  //maximizing, minimizing, restoring window, etc.
ladanyi@6
   261
  virtual bool on_expose_event(GdkEventExpose *);
ladanyi@6
   262
ladanyi@6
   263
private:
ladanyi@6
   264
ladanyi@6
   265
  ///This function is responsible for the correct
ladanyi@6
   266
  ///reaction of any action happened in the territory
ladanyi@6
   267
  ///of the canvas
hegyi@25
   268
  ///DEPRECATED!!!!
hegyi@30
   269
  bool eventHandler(GdkEvent* e, Node n);
ladanyi@6
   270
hegyi@9
   271
  ///actual event handler
hegyi@9
   272
  ///
hegyi@9
   273
  ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
hegyi@9
   274
  sigc::connection actual_handler;
hegyi@9
   275
hegyi@9
   276
  ///event handler for the case when move-tool is active
hegyi@30
   277
  bool moveEventHandler(GdkEvent*);
hegyi@9
   278
  ///event handler for the case when create_node-tool is active
hegyi@30
   279
  bool createNodeEventHandler(GdkEvent*);
hegyi@9
   280
  ///event handler for the case when create_edge-tool is active
hegyi@30
   281
  bool createEdgeEventHandler(GdkEvent*);
hegyi@13
   282
  ///event handler for the case when eraser-tool is active
hegyi@30
   283
  bool eraserEventHandler(GdkEvent*);
hegyi@149
   284
  ///event handler for the case when map editor tool is active
hegyi@149
   285
  bool mapEditEventHandler(GdkEvent*);
hegyi@13
   286
hegyi@160
   287
private:
hegyi@160
   288
  ///moves node according to the given parameters
hegyi@160
   289
  void moveNode(double, double,  Gnome::Canvas::Item * item=NULL, Node node=INVALID);
hegyi@160
   290
hegyi@21
   291
public:
hegyi@25
   292
  ///Moves the text to new place
hegyi@150
   293
  void textReposition(XY);
hegyi@118
   294
ladanyi@147
   295
  ///Activates an edge belonging to an EdgeBase
hegyi@118
   296
hegyi@35
   297
  ///After we have activated an edge this way,
hegyi@35
   298
  ///the GDC object will know, which edge is under forming
hegyi@118
   299
  ///therefore it can redraw the necessary elements on the canvas,
ladanyi@147
   300
  ///for example the text belonging to the \ref EdgeBase can be
hegyi@35
   301
  ///redrawn (\ref textReposition).
ladanyi@147
   302
  void toggleEdgeActivity(EdgeBase*, bool);
hegyi@25
   303
hegyi@25
   304
public:
hegyi@118
   305
hegyi@118
   306
  ///Returns the actual tool in hand
hegyi@30
   307
  int getActualTool();
hegyi@21
   308
hegyi@154
   309
  ///Sets node representation settings
hegyi@157
   310
  void setView(bool, bool, double, double);
hegyi@154
   311
hegyi@154
   312
  ///Gets node representation settings
hegyi@157
   313
  void getView(bool &, bool &, double&, double&);
hegyi@154
   314
hegyi@118
   315
  ///draws the graph
hegyi@118
   316
hegyi@118
   317
  ///Called when opening a file.
ladanyi@53
   318
  void drawGraph();
hegyi@118
   319
hegyi@118
   320
  ///Clears the canvas
hegyi@118
   321
hegyi@118
   322
  ///It achieves this by deleting all data
hegyi@118
   323
  ///structure used to help handle the displayed graph.
ladanyi@53
   324
  void clear();
ladanyi@53
   325
hegyi@37
   326
  ///creates a new Nodemap
hegyi@118
   327
hegyi@118
   328
  ///\param init initial value of the map
hegyi@118
   329
  ///\param mapname name of new map
hegyi@118
   330
  int addNewNodeMap(double init,std::string mapname);
hegyi@37
   331
  ///creates a new Edgemap
hegyi@118
   332
hegyi@118
   333
  ///\param init initial value of the map
hegyi@118
   334
  ///\param mapname name of new map
hegyi@118
   335
  int addNewEdgeMap(double init,std::string mapname);
hegyi@37
   336
hegyi@160
   337
  void reDesignGraph();
hegyi@160
   338
hegyi@160
   339
  void get_design_data(double &, double &, int &);
hegyi@160
   340
  void set_attraction(double);
hegyi@160
   341
  void set_propulsation(double);
hegyi@160
   342
  void set_iteration(int);
hegyi@160
   343
hegyi@172
   344
  ///Show whether the graph is already drawn.
hegyi@172
   345
  bool is_drawn;
hegyi@172
   346
hegyi@21
   347
private:
hegyi@14
   348
  ///Deletes the given element.
alpar@62
   349
  void deleteItem(Node);
hegyi@14
   350
  ///Deletes the given element.
alpar@62
   351
  void deleteItem(Edge);
hegyi@9
   352
hegyi@21
   353
private:
hegyi@21
   354
ladanyi@6
   355
  ///Map of nodes of graph
ladanyi@6
   356
  Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
ladanyi@6
   357
ladanyi@6
   358
  ///Map of edges of graph
ladanyi@147
   359
  Graph::EdgeMap<EdgeBase*> edgesmap;
ladanyi@6
   360
ladanyi@6
   361
  ///Map of texts to write on edges
ladanyi@6
   362
  Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
ladanyi@6
   363
hegyi@28
   364
  ///Map of texts to write on nodes
hegyi@28
   365
  Graph::NodeMap<Gnome::Canvas::Text *> nodetextmap;
hegyi@28
   366
ladanyi@6
   367
  ///Group of graphical elements of displayed_graph
ladanyi@6
   368
  Gnome::Canvas::Group displayed_graph;
ladanyi@6
   369
hegyi@88
   370
private:
ladanyi@6
   371
  ///Indicates whether the button of mouse is pressed or not
hegyi@20
   372
  int isbutton;
ladanyi@6
   373
hegyi@21
   374
  ///Stores the actual tool in hand
hegyi@21
   375
  int actual_tool;
hegyi@21
   376
ladanyi@6
   377
  ///At this location was the mousebutton pressed.
ladanyi@6
   378
  ///It helps to calculate the distance of dragging.
ladanyi@6
   379
  double clicked_x, clicked_y;
ladanyi@6
   380
ladanyi@6
   381
  ///Remembers which Gnome::Canvas::Item was pressed.
hegyi@118
   382
hegyi@118
   383
  ///this variable is needed, to work on it after selection
hegyi@118
   384
  Gnome::Canvas::Item * active_item;
hegyi@118
   385
hegyi@118
   386
  ///Remembers which Gnome::Canvas::Item was pressed.
hegyi@118
   387
hegyi@118
   388
  ///this variable is used at edge creation, it will
hegyi@118
   389
  ///be the secondly selected node. No local variable
hegyi@118
   390
  ///can be used for this purpose inside the function,
hegyi@118
   391
  ///because the node selected by button press, and
hegyi@118
   392
  ///the edge is created by button release. Both of
hegyi@118
   393
  ///them is different function call.
hegyi@118
   394
  Gnome::Canvas::Item * target_item;
hegyi@118
   395
hegyi@118
   396
  ///selected node (for any editing)
alpar@62
   397
  Node active_node;
hegyi@118
   398
hegyi@118
   399
  ///selected edge (for any editing)
alpar@62
   400
  Edge active_edge;
hegyi@118
   401
hegyi@118
   402
  ///the edge that is selected by clicking on the red arrow in the middle of it
hegyi@118
   403
hegyi@118
   404
  ///This edge is stored only for the purpose of reshape it.
hegyi@118
   405
  ///That is why it is selected in a different manner.
alpar@62
   406
  Edge forming_edge;
hegyi@35
   407
hegyi@118
   408
  ///Map displayed by label can be edited.
hegyi@118
   409
  std::string nodemap_to_edit;
hegyi@118
   410
hegyi@118
   411
  ///Map displayed by label can be edited.
hegyi@118
   412
  std::string edgemap_to_edit;
ladanyi@6
   413
ladanyi@6
   414
  static const int zoom_step = 5;
hegyi@19
   415
hegyi@154
   416
  ///Is node radius autoscaled
hegyi@154
   417
  bool autoscale;
hegyi@154
   418
  
hegyi@156
   419
  ///Should we track zoomfactor changes
hegyi@156
   420
  bool zoomtrack;
hegyi@156
   421
hegyi@156
   422
  ///to store the zoom factor when it was "fixed"
hegyi@156
   423
  double fixed_zoom_factor;
hegyi@156
   424
  
hegyi@157
   425
  ///Node radius size
hegyi@157
   426
  double radius_size;
hegyi@154
   427
hegyi@157
   428
  ///Edge width
hegyi@157
   429
  double edge_width;
hegyi@154
   430
hegyi@160
   431
  ///Iteration number during graph design
hegyi@160
   432
  int iterations;
hegyi@160
   433
hegyi@160
   434
  ///Attraction factor during graph design
hegyi@160
   435
  double attraction;
hegyi@160
   436
hegyi@160
   437
  ///Propulsation factor during graph design
hegyi@160
   438
  double propulsation;
hegyi@166
   439
hegyi@166
   440
  ///Was redesign run on this graph already?
hegyi@166
   441
  ///
hegyi@166
   442
  ///If not, the layout will be modified randomly
hegyi@166
   443
  ///to avoid frozen layout because of wrong
hegyi@166
   444
  ///initial state
hegyi@166
   445
  bool was_redesigned;
hegyi@160
   446
  
hegyi@88
   447
private:
hegyi@88
   448
hegyi@118
   449
  ///reference to the container, in which the canvas is
hegyi@96
   450
  NoteBookTab & mytab;
hegyi@55
   451
hegyi@148
   452
  XY calcArrowPos(XY, XY, XY, XY, int);
ladanyi@6
   453
};
ladanyi@6
   454
ladanyi@6
   455
#endif //GRAPH_DISPLAYER_CANVAS_H